-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Joppe Boeve
committed
Jan 17, 2024
1 parent
437cdd8
commit a108cc0
Showing
3 changed files
with
9 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: yzaim <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2024/01/08 15:24:47 by yzaim #+# #+# */ | ||
/* Updated: 2024/01/17 13:25:18 by jboeve ######## odam.nl */ | ||
/* Updated: 2024/01/17 16:28:16 by jboeve ######## odam.nl */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -118,7 +118,7 @@ int cub3d(int argc, char **argv) | |
mlx_set_cursor_mode(meta.mlx, MLX_MOUSE_HIDDEN); | ||
mlx_loop_hook(meta.mlx, game_loop, &meta); | ||
mlx_loop_hook(meta.mlx, fps_hook, &meta); | ||
// mlx_cursor_hook(meta.mlx, cursor_hook, &meta); | ||
mlx_cursor_hook(meta.mlx, cursor_hook, &meta); | ||
mlx_loop(meta.mlx); | ||
mlx_terminate(meta.mlx); | ||
meta_free(&meta); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: yzaim <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2024/01/08 15:27:33 by yzaim #+# #+# */ | ||
/* Updated: 2024/01/17 15:58:39 by jboeve ######## odam.nl */ | ||
/* Updated: 2024/01/17 16:27:30 by jboeve ######## odam.nl */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -126,10 +126,11 @@ t_ray raycaster_cast(t_vec2d pp, t_vec2d dir, t_ray_hitfunc hit, const void *par | |
r.line_point.y = r.line_height / 2 + ((double)WINDOW_HEIGHT) / 2; | ||
if (r.line_point.y >= WINDOW_HEIGHT) | ||
r.line_point.y = WINDOW_HEIGHT - 1; | ||
|
||
if (r.hit_side == SIDE_N || r.hit_side == SIDE_S) | ||
r.wall_x = r.map_pos.y + r.length * r.direction.y; | ||
r.wall_x = pp.y + r.length * r.direction.y; | ||
else | ||
r.wall_x = r.map_pos.x + r.length * r.direction.x; | ||
r.wall_x = pp.x + r.length * r.direction.x; | ||
r.wall_x -= floor(r.wall_x); | ||
return (r); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: yzaim <[email protected]> +#+ */ | ||
/* +#+ */ | ||
/* Created: 2024/01/08 15:28:08 by yzaim #+# #+# */ | ||
/* Updated: 2024/01/17 16:10:04 by jboeve ######## odam.nl */ | ||
/* Updated: 2024/01/17 16:22:52 by jboeve ######## odam.nl */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -38,20 +38,15 @@ static void draw_column(t_meta *meta, t_vec2i line, t_ray *ray, uint32_t col, ui | |
|
||
texture = get_texture(ray->hit_side, meta->attributes); | ||
|
||
ray->texture_point.x = (int)(ray->wall_x * (int)texture->width); | ||
|
||
ray->texture_point.x = (int)(ray->wall_x * (double)texture->width); | ||
if ((ray->hit_side == SIDE_N || ray->hit_side == SIDE_S) && ray->direction.x > 0) | ||
{ | ||
ray->texture_point.x = texture->width - ray->texture_point.x - 1; | ||
} | ||
if ((ray->hit_side == SIDE_E || ray->hit_side == SIDE_W) && ray->direction.y < 0) | ||
{ | ||
ray->texture_point.x = texture->width - ray->texture_point.x - 1; | ||
} | ||
|
||
ray->step = 1.0 * texture->height / ray->line_height; | ||
ray->texture_position = (ray->line_point.x + (ray->line_height - h) / 2) * ray->step; | ||
|
||
ray->texture_position = ((ray->line_point.x - (double) (h / 2.0) + ray->line_height / 2.0) * ray->step); | ||
|
||
printf("line_height [%lf]\n", ray->line_height); | ||
printf("step [%lf]\n", ray->step); | ||
|
@@ -62,16 +57,10 @@ static void draw_column(t_meta *meta, t_vec2i line, t_ray *ray, uint32_t col, ui | |
y = 0; | ||
while (y < (int32_t) h) | ||
{ | ||
// ceiling | ||
if (y < line.x) | ||
{ | ||
color = find_color(meta->attributes.ceiling_c); | ||
} | ||
// floor | ||
else if (y > line.y) | ||
{ | ||
color = find_color(meta->attributes.floor_c); | ||
} | ||
else | ||
{ | ||
ray->texture_point.y = ((int) ray->texture_position) & (texture->height - 1); | ||
|