From 87eb97b21c5e309a414dde32cbb8a7fea4ddfad8 Mon Sep 17 00:00:00 2001 From: djonker Date: Sun, 29 Oct 2023 22:32:27 +0100 Subject: [PATCH] small tweaks --- Readme.md | 3 ++- config.cub | 4 ++-- src/keys.c | 18 +++++++++--------- src/map.c | 14 +++++++------- 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/Readme.md b/Readme.md index 500e547..6aa48dd 100644 --- a/Readme.md +++ b/Readme.md @@ -13,6 +13,7 @@ Cub3D is a simple raycasting game using the mlx library - Minimap - Animated Sprites ### Extra +- Help screen? - Levels? - Barrels? - Collectables @@ -20,7 +21,6 @@ Cub3D is a simple raycasting game using the mlx library - Moving Enemies? - Weapon Sprite that fires? - Zoom with right mouse button? -- Help screen? - Skybox? - Sounds? - Music? @@ -45,6 +45,7 @@ Cub3D is a simple raycasting game using the mlx library - FPS counter - Player can walk in 8 directions - Player can Run +- Map sizes up to 1 Megabyte (1000x1000) --- ## Bugs diff --git a/config.cub b/config.cub index 689bdcf..73e2d65 100644 --- a/config.cub +++ b/config.cub @@ -12,8 +12,8 @@ WE ./assets/wood.png 1 1 1 1 1 1 1 1 11111111111 11111111111 111111111111111111111 1 1111111111 1111111111 1 1B C B1 1 1 1 1 1 D K K 1 1 -1 1 K K 1 1 K K D 1 C 1 K K D 1 1 K K K K K K 1 -1 1 1 1 1 1 1 1 1111111111 K K K K 1 +1 1 K K 1 1 K K D 1 C 1 K K D 1 1 K K K K K K K K 1 +1 1 1 1 1 1 1 1 1111111111 K K K K K K 1 1 11111 11111 11111111111 D K K K 11111111111 1 1 K K K K 1 1 1 1 1 K K 1 1 D K K 1 K K 1 1 1 K K D 1 1 K K D 1 1 1 diff --git a/src/keys.c b/src/keys.c index e107225..12b4130 100644 --- a/src/keys.c +++ b/src/keys.c @@ -6,7 +6,7 @@ /* By: houtworm +#+ */ /* +#+ */ /* Created: 2023/10/26 16:50:23 by houtworm #+# #+# */ -/* Updated: 2023/10/29 18:57:04 by houtworm ######## odam.nl */ +/* Updated: 2023/10/29 19:33:50 by houtworm ######## odam.nl */ /* */ /* ************************************************************************** */ @@ -26,12 +26,12 @@ void ft_movementkeys(t_varlist *vl) ft_putendl("shoot"); if (mlx_is_key_down(vl->mlx, MLX_KEY_W)) { - if (vl->map[(int)(vl->posx + vl->dirx * vl->movespeed)][(int)vl->posy] == '0' && distance > 0.5) + if (vl->map[(int)(vl->posx + vl->dirx * vl->movespeed)][(int)vl->posy] == '0' && distance > 0.4) { vl->posx += vl->dirx * vl->movespeed * vl->run; vl->posy += vl->diry * vl->movespeed * vl->run; } - if (vl->map[(int)vl->posx][(int)(vl->posy + vl->diry * vl->movespeed)] == '0' && distance > 0.5) + if (vl->map[(int)vl->posx][(int)(vl->posy + vl->diry * vl->movespeed)] == '0' && distance > 0.4) { vl->posx += vl->dirx * vl->movespeed * vl->run; vl->posy += vl->diry * vl->movespeed * vl->run; @@ -39,12 +39,12 @@ void ft_movementkeys(t_varlist *vl) } if (mlx_is_key_down(vl->mlx, MLX_KEY_A)) { - if (vl->map[(int)(vl->posx - vl->dirx * vl->movespeed)][(int)vl->posy] == '0' && distance > 0.5) + if (vl->map[(int)(vl->posx - vl->dirx * vl->movespeed)][(int)vl->posy] == '0' && distance > 0.4) { vl->posx -= vl->diry * vl->movespeed * vl->run; vl->posy += vl->dirx * vl->movespeed * vl->run; } - if (vl->map[(int)vl->posx][(int)(vl->posy - vl->diry * vl->movespeed)] == '0' && distance > 0.5) + if (vl->map[(int)vl->posx][(int)(vl->posy - vl->diry * vl->movespeed)] == '0' && distance > 0.4) { vl->posx -= vl->diry * vl->movespeed * vl->run; vl->posy += vl->dirx * vl->movespeed * vl->run; @@ -52,12 +52,12 @@ void ft_movementkeys(t_varlist *vl) } if (mlx_is_key_down(vl->mlx, MLX_KEY_S)) { - if (vl->map[(int)(vl->posx - vl->dirx * vl->movespeed)][(int)vl->posy] == '0' && distance > 0.5) + if (vl->map[(int)(vl->posx - vl->dirx * vl->movespeed)][(int)vl->posy] == '0' && distance > 0.4) { vl->posx -= vl->dirx * vl->movespeed * vl->run; vl->posy -= vl->diry * vl->movespeed * vl->run; } - if (vl->map[(int)vl->posx][(int)(vl->posy - vl->diry * vl->movespeed)] == '0' && distance > 0.5) + if (vl->map[(int)vl->posx][(int)(vl->posy - vl->diry * vl->movespeed)] == '0' && distance > 0.4) { vl->posx -= vl->dirx * vl->movespeed * vl->run; vl->posy -= vl->diry * vl->movespeed * vl->run; @@ -65,12 +65,12 @@ void ft_movementkeys(t_varlist *vl) } if (mlx_is_key_down(vl->mlx, MLX_KEY_D)) { - if (vl->map[(int)(vl->posx + vl->dirx * vl->movespeed)][(int)vl->posy] == '0' && distance > 0.5) + if (vl->map[(int)(vl->posx + vl->dirx * vl->movespeed)][(int)vl->posy] == '0' && distance > 0.4) { vl->posx += vl->diry * vl->movespeed * vl->run; vl->posy -= vl->dirx * vl->movespeed * vl->run; } - if (vl->map[(int)vl->posx][(int)(vl->posy + vl->diry * vl->movespeed)] == '0' && distance > 0.5) + if (vl->map[(int)vl->posx][(int)(vl->posy + vl->diry * vl->movespeed)] == '0' && distance > 0.4) { vl->posx += vl->diry * vl->movespeed * vl->run; vl->posy -= vl->dirx * vl->movespeed * vl->run; diff --git a/src/map.c b/src/map.c index c1ee5e9..0d68bac 100644 --- a/src/map.c +++ b/src/map.c @@ -6,7 +6,7 @@ /* By: houtworm +#+ */ /* +#+ */ /* Created: 2023/10/26 17:33:50 by houtworm #+# #+# */ -/* Updated: 2023/10/29 17:53:01 by houtworm ######## odam.nl */ +/* Updated: 2023/10/29 19:30:54 by houtworm ######## odam.nl */ /* */ /* ************************************************************************** */ @@ -56,14 +56,14 @@ char **ft_getmap(t_varlist *vl, int fd) char **map; char *line; - map = ft_calloc(512, 8); + map = ft_calloc(1024, 8); y = 0; ret = 1; - while (y <= 512 && ret > 0) + while (y <= 1024 && ret > 0) { - if (y > 500) + if (y > 1000) return (NULL); - map[y] = ft_calloc(512, 8); + map[y] = ft_calloc(1024, 8); while (ret > 0) { ret = get_next_line(fd, &line); @@ -77,9 +77,9 @@ char **ft_getmap(t_varlist *vl, int fd) return (map); } x = 0; - while (x <= 512 && line[x]) + while (x <= 1024 && line[x]) { - if (x > 500) + if (x > 1000) return (NULL); if (ft_strchr(" 0", line[x])) map[y][x] = '0';