Skip to content

Commit

Permalink
Small format change
Browse files Browse the repository at this point in the history
  • Loading branch information
Yesim Zaim committed Jan 24, 2024
1 parent d361c67 commit c350710
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
5 changes: 3 additions & 2 deletions include/meta.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <fcntl.h>
#include <stdbool.h>
#include <limits.h>
#include <math.h>

#include "timer.h"
#include "libft.h"
Expand Down Expand Up @@ -81,8 +82,8 @@
#define VIEWPORT_COLOR_WALL_NS 0x4B0082FF
#define VIEWPORT_COLOR_WALL_EW 0x8A30E2FF

// #define FOV 0.66
#define FOV 0.85
#define FOV M_PI / 4
// #define FOV 0.85

typedef bool (t_ray_hitfunc) (const void *p, uint32_t x, uint32_t y);

Expand Down
10 changes: 4 additions & 6 deletions src/game/floorcaster.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: yzaim <[email protected]> +#+ */
/* +#+ */
/* Created: 2024/01/24 13:13:37 by yzaim #+# #+# */
/* Updated: 2024/01/24 16:06:35 by yzaim ######## odam.nl */
/* Updated: 2024/01/24 17:05:20 by yzaim ######## odam.nl */
/* */
/* ************************************************************************** */

Expand All @@ -19,10 +19,10 @@ t_vray floorcaster(t_vec2d pp, t_vec2d dir, t_vec2d cam_plane, uint32_t y)
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;
double row_distance = posZ / p;
Expand All @@ -32,7 +32,5 @@ t_vray floorcaster(t_vec2d pp, t_vec2d dir, t_vec2d cam_plane, uint32_t y)
ray.floor.x = pp.x + row_distance + raydir_left.x;
ray.floor.y = pp.y + row_distance + raydir_left.y;



return (ray);
}
2 changes: 1 addition & 1 deletion src/game/player.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: yzaim <[email protected]> +#+ */
/* +#+ */
/* Created: 2024/01/08 15:27:23 by yzaim #+# #+# */
/* Updated: 2024/01/24 16:09:02 by yzaim ######## odam.nl */
/* Updated: 2024/01/24 17:09:42 by yzaim ######## odam.nl */
/* */
/* ************************************************************************** */

Expand Down
13 changes: 7 additions & 6 deletions src/game/render_viewport.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: yzaim <[email protected]> +#+ */
/* +#+ */
/* Created: 2024/01/08 15:28:08 by yzaim #+# #+# */
/* Updated: 2024/01/24 16:06:25 by yzaim ######## odam.nl */
/* Updated: 2024/01/24 17:08:29 by yzaim ######## odam.nl */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -74,10 +74,10 @@ void draw_fc(mlx_image_t *image, t_vray *vray, mlx_texture_t *f_tex, mlx_texture

vray->floor = vec2d_add(vray->floor, vray->step);

const uint32_t c_color = pixel_picker(c_tex, c_t.x, c_t.y);
const uint32_t f_color = pixel_picker(f_tex, f_t.x, f_t.y);
mlx_put_pixel(image, col, WINDOW_HEIGHT - row - 1, c_color);
mlx_put_pixel(image, col, row, f_color);
const uint32_t c_pixel = pixel_picker(c_tex, c_t.x, c_t.y);
const uint32_t f_pixel = pixel_picker(f_tex, f_t.x, f_t.y);
mlx_put_pixel(image, col, WINDOW_HEIGHT - row - 1, c_pixel);
mlx_put_pixel(image, col, row, f_pixel);
}

void render_viewport(mlx_image_t *image, t_player *p)
Expand All @@ -88,7 +88,6 @@ void render_viewport(mlx_image_t *image, t_player *p)

if (p->should_render)
{
row = 0;
while (row < image->height)
{
col = 0;
Expand All @@ -101,6 +100,8 @@ void render_viewport(mlx_image_t *image, t_player *p)
}
p->should_render = false;
}


col = 0;
while(col < image->width)
{
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/pixel_picker.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: yzaim <[email protected]> +#+ */
/* +#+ */
/* Created: 2024/01/08 15:26:51 by yzaim #+# #+# */
/* Updated: 2024/01/24 15:49:05 by yzaim ######## odam.nl */
/* Updated: 2024/01/24 16:46:58 by yzaim ######## odam.nl */
/* */
/* ************************************************************************** */

Expand Down

0 comments on commit c350710

Please sign in to comment.