From 0a017863752ea321adf9ed234c55967a5ea09813 Mon Sep 17 00:00:00 2001 From: Joppe Boeve Date: Wed, 24 Jan 2024 18:24:31 +0100 Subject: [PATCH] WRKS!!???!?!? --- src/game/floorcaster.c | 16 +++++++--------- src/game/player.c | 4 ++-- src/game/render_viewport.c | 6 +++--- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/game/floorcaster.c b/src/game/floorcaster.c index d8a0d4b..4657465 100644 --- a/src/game/floorcaster.c +++ b/src/game/floorcaster.c @@ -1,12 +1,12 @@ /* ************************************************************************** */ /* */ /* :::::::: */ -/* floorcaster.c :+: :+: */ +/* floorcaster.c :+: :+: */ /* +:+ */ /* By: yzaim +#+ */ /* +#+ */ /* Created: 2024/01/24 13:13:37 by yzaim #+# #+# */ -/* Updated: 2024/01/24 17:05:20 by yzaim ######## odam.nl */ +/* Updated: 2024/01/24 18:23:45 by jboeve ######## odam.nl */ /* */ /* ************************************************************************** */ @@ -14,14 +14,12 @@ t_vray floorcaster(t_vec2d pp, t_vec2d dir, t_vec2d cam_plane, uint32_t y) { - t_vray ray; t_vec2d raydir_left; t_vec2d raydir_right; - raydir_left = ((t_vec2d){dir.x - cam_plane.x, dir.y - cam_plane.y}); - raydir_right = ((t_vec2d){dir.x + cam_plane.x, dir.y + cam_plane.y}); - + raydir_left = ((t_vec2d){dir.x - cam_plane.x, dir.y - cam_plane.y}); + raydir_right = ((t_vec2d){dir.x + cam_plane.x, dir.y + cam_plane.y}); int p = y - WINDOW_HEIGHT / 2; double posZ = 0.5 * WINDOW_HEIGHT; @@ -29,8 +27,8 @@ t_vray floorcaster(t_vec2d pp, t_vec2d dir, t_vec2d cam_plane, uint32_t y) ray.step.x = row_distance * (raydir_right.x - raydir_left.x) / WINDOW_WIDTH; ray.step.y = row_distance * (raydir_right.y - raydir_left.y) / WINDOW_WIDTH; - ray.floor.x = pp.x + row_distance + raydir_left.x; - ray.floor.y = pp.y + row_distance + raydir_left.y; + ray.floor.x = pp.x + row_distance * raydir_left.x; + ray.floor.y = pp.y + row_distance * raydir_left.y; return (ray); -} \ No newline at end of file +} diff --git a/src/game/player.c b/src/game/player.c index f1121df..9d6339a 100644 --- a/src/game/player.c +++ b/src/game/player.c @@ -1,12 +1,12 @@ /* ************************************************************************** */ /* */ /* :::::::: */ -/* player.c :+: :+: */ +/* player.c :+: :+: */ /* +:+ */ /* By: yzaim +#+ */ /* +#+ */ /* Created: 2024/01/08 15:27:23 by yzaim #+# #+# */ -/* Updated: 2024/01/24 17:09:42 by yzaim ######## odam.nl */ +/* Updated: 2024/01/24 18:21:22 by jboeve ######## odam.nl */ /* */ /* ************************************************************************** */ diff --git a/src/game/render_viewport.c b/src/game/render_viewport.c index 46f3796..fa696ad 100644 --- a/src/game/render_viewport.c +++ b/src/game/render_viewport.c @@ -1,12 +1,12 @@ /* ************************************************************************** */ /* */ /* :::::::: */ -/* render_viewport.c :+: :+: */ +/* render_viewport.c :+: :+: */ /* +:+ */ /* By: yzaim +#+ */ /* +#+ */ /* Created: 2024/01/08 15:28:08 by yzaim #+# #+# */ -/* Updated: 2024/01/24 17:08:29 by yzaim ######## odam.nl */ +/* Updated: 2024/01/24 18:17:54 by jboeve ######## odam.nl */ /* */ /* ************************************************************************** */ @@ -71,7 +71,7 @@ void draw_fc(mlx_image_t *image, t_vray *vray, mlx_texture_t *f_tex, mlx_texture (int)(c_tex->height * (vray->floor.y - cell.y)) & (c_tex->height - 1)}; const t_vec2i f_t = (t_vec2i){(int)(f_tex->width * (vray->floor.x - cell.x)) & (f_tex->width - 1), (int)(f_tex->height * (vray->floor.y - cell.y)) & (f_tex->height - 1)}; - + vray->floor = vec2d_add(vray->floor, vray->step); const uint32_t c_pixel = pixel_picker(c_tex, c_t.x, c_t.y);