diff --git a/assets/barrel.png b/assets/barrel.png new file mode 100755 index 0000000..eea212d Binary files /dev/null and b/assets/barrel.png differ diff --git a/assets/bluestone.png b/assets/bluestone.png new file mode 100755 index 0000000..e3bc499 Binary files /dev/null and b/assets/bluestone.png differ diff --git a/assets/colorstone.png b/assets/colorstone.png new file mode 100755 index 0000000..507f12e Binary files /dev/null and b/assets/colorstone.png differ diff --git a/assets/eagle.png b/assets/eagle.png new file mode 100755 index 0000000..f9394d6 Binary files /dev/null and b/assets/eagle.png differ diff --git a/assets/greenlight.png b/assets/greenlight.png new file mode 100755 index 0000000..2345e8e Binary files /dev/null and b/assets/greenlight.png differ diff --git a/assets/greystone.png b/assets/greystone.png new file mode 100755 index 0000000..18b51dd Binary files /dev/null and b/assets/greystone.png differ diff --git a/assets/mossy.png b/assets/mossy.png new file mode 100755 index 0000000..22ca59f Binary files /dev/null and b/assets/mossy.png differ diff --git a/assets/pillar.png b/assets/pillar.png new file mode 100755 index 0000000..f5b4766 Binary files /dev/null and b/assets/pillar.png differ diff --git a/assets/purplestone.png b/assets/purplestone.png new file mode 100755 index 0000000..425bd71 Binary files /dev/null and b/assets/purplestone.png differ diff --git a/assets/redbrick.png b/assets/redbrick.png new file mode 100755 index 0000000..3eb620f Binary files /dev/null and b/assets/redbrick.png differ diff --git a/assets/wood.png b/assets/wood.png new file mode 100755 index 0000000..c30c317 Binary files /dev/null and b/assets/wood.png differ diff --git a/cub3d b/cub3d index 49cbff8..56b7fde 100755 Binary files a/cub3d and b/cub3d differ diff --git a/cub3d.h b/cub3d.h index e19c24a..5b64db1 100644 --- a/cub3d.h +++ b/cub3d.h @@ -6,7 +6,7 @@ /* By: houtworm +#+ */ /* +#+ */ /* Created: 2023/10/26 10:46:35 by houtworm #+# #+# */ -/* Updated: 2023/10/26 10:47:00 by houtworm ######## odam.nl */ +/* Updated: 2023/10/26 13:56:49 by houtworm ######## odam.nl */ /* */ /* ************************************************************************** */ @@ -23,8 +23,8 @@ typedef struct s_varlist mlx_t *mlx; //mlx instance mlx_image_t *img; //mlx img mlx_image_t *font[30]; //mlx font image - int w; //actual window width used everywhere - int h; //actual window height used everywhere + int w; //actual window width used everywhere + int h; //actual window height used everywhere } t_varlist; #endif diff --git a/src/main.c b/src/main.c index ed42b70..64d635d 100644 --- a/src/main.c +++ b/src/main.c @@ -5,13 +5,92 @@ /* +:+ */ /* By: houtworm +#+ */ /* +#+ */ -/* Created: 2023/10/26 10:46:22 by houtworm #+# #+# */ -/* Updated: 2023/10/26 10:46:24 by houtworm ######## odam.nl */ +/* Created: 2023/10/26 14:13:07 by houtworm #+# #+# */ +/* Updated: 2023/10/26 15:01:26 by houtworm ######## odam.nl */ /* */ /* ************************************************************************** */ #include "../cub3d.h" +void ft_getnextframe(t_varlist *vl) +{ + int y; + int x; + + y = 1; + while (vl->h > y) + { + x = 1; + while (vl->w > x) + { + mlx_put_pixel(vl->img, x, y, 0x000000FF); + x++; + } + y++; + } +} + +void framehook(void *param) +{ + t_varlist *vl; + + vl = param; + mlx_delete_image(vl->mlx, vl->img); + vl->img = mlx_new_image(vl->mlx, vl->w, vl->h); + ft_getnextframe(vl); + if (!vl->img || (mlx_image_to_window(vl->mlx, vl->img, 0, 0) < 0)) + exit (1); + ft_putendl("frame"); +} + +void keyhook(mlx_key_data_t kd, void *param) +{ + t_varlist *vl; + + vl = param; + vl->w =vl->w; + if (mlx_is_mouse_down(vl->mlx, MLX_MOUSE_BUTTON_LEFT)) + ft_putendl("shoot"); + if (mlx_is_key_down(vl->mlx, MLX_KEY_ESCAPE)) + { + ft_putendl("escape is pressed"); + mlx_close_window(vl->mlx); + return ; + } + if (kd.key == MLX_KEY_W && kd.action == MLX_PRESS) + ft_putendl("W is pressed"); + if (kd.key == MLX_KEY_A && kd.action == MLX_PRESS) + ft_putendl("A is pressed"); + if (kd.key == MLX_KEY_S && kd.action == MLX_PRESS) + ft_putendl("S is pressed"); + if (kd.key == MLX_KEY_D && kd.action == MLX_PRESS) + ft_putendl("D is pressed"); +} + +void scrollhook(double xdelta, double ydelta, void *param) +{ + t_varlist *vl; + + vl = param; + vl = vl; + xdelta++; + if (ydelta > 0) + ft_putendl("scroll up"); + if (ydelta < 0) + ft_putendl("scroll down"); +} + +void resizehook(int x, int y, void *param) +{ + t_varlist *vl; + + vl = param; + vl->h = y; + vl->w = x; + vl->mlx->height = y; + vl->mlx->width = x; +} + t_varlist initvarlist(void) { t_varlist vl; @@ -20,26 +99,27 @@ t_varlist initvarlist(void) vl.h = 600; vl.mlx = mlx_init(vl.w, vl.h, "Cub3D", true); if (!vl.mlx) - exit(1); + exit (1); vl.img = mlx_new_image(vl.mlx, vl.w, vl.h); return (vl); } -void redrawimage(t_varlist *vl) -{ - mlx_delete_image(vl->mlx, vl->img); - vl->img = mlx_new_image(vl->mlx, vl->w, vl->h); -} - -int32_t main(void) +int main(int argc, char **argv) { t_varlist vl; + if (argc > 2) + exit(2); + argv = argv; vl = initvarlist(); if (!vl.img || (mlx_image_to_window(vl.mlx, vl.img, 0, 0) < 0)) exit (1); + mlx_key_hook(vl.mlx, &keyhook, &vl); + mlx_resize_hook(vl.mlx, &resizehook, &vl); + mlx_scroll_hook(vl.mlx, &scrollhook, &vl); + mlx_loop_hook(vl.mlx, &framehook, &vl); mlx_loop(vl.mlx); mlx_delete_image(vl.mlx, vl.img); mlx_terminate(vl.mlx); - exit (EXIT_SUCCESS); + exit (0); }