refactor: floats to doubles

This commit is contained in:
Quinten Mennen 2025-05-06 15:23:53 +02:00
parent 15c47e36ac
commit 06156e5436
15 changed files with 276 additions and 285 deletions

View File

@ -6,7 +6,7 @@
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/22 14:40:47 by qmennen #+# #+# */
/* Updated: 2025/04/22 14:42:35 by qmennen ### ########.fr */
/* Updated: 2025/05/06 15:20:37 by qmennen ### ########.fr */
/* */
/* ************************************************************************** */
@ -15,7 +15,7 @@
#include "cub3d.h"
int collision_horizontal(t_map *map, t_player *player, float xa);
int collision_vertical(t_map *map, t_player *player, float ya);
int collision_horizontal(t_map *map, t_player *player, double xa);
int collision_vertical(t_map *map, t_player *player, double ya);
#endif

View File

@ -6,7 +6,7 @@
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/15 18:53:27 by qmennen #+# #+# */
/* Updated: 2025/04/22 15:23:45 by qmennen ### ########.fr */
/* Updated: 2025/05/06 15:20:37 by qmennen ### ########.fr */
/* */
/* ************************************************************************** */
@ -17,6 +17,6 @@
int player_create(t_game **game);
void player_render(t_screen *screen, t_player *player);
void player_update(t_game *game, float delta_time);
void player_update(t_game *game, double delta_time);
#endif

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* types.h :+: :+: */
/* +:+ */
/* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */
/* ::: :::::::: */
/* types.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/15 15:52:44 by qmennen #+# #+# */
/* Updated: 2025/05/06 13:58:16 by whaffman ######## odam.nl */
/* Updated: 2025/05/06 15:20:37 by qmennen ### ########.fr */
/* */
/* ************************************************************************** */
@ -26,8 +26,8 @@ typedef enum TILE
typedef struct s_vec2
{
float x;
float y;
double x;
double y;
} t_vec2;
typedef struct s_vec2_int
@ -47,8 +47,8 @@ typedef struct s_player
t_vec2 pos;
t_vec2 dir;
t_vec2 camera;
float speed;
float fov;
double speed;
double fov;
} t_player;
typedef struct s_map
@ -90,9 +90,9 @@ typedef enum e_side
typedef struct s_render
{
float perp_dist;
double perp_dist;
t_side side;
float wall_x;
double wall_x;
} t_render;
typedef struct s_game

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* vec_math.h :+: :+: */
/* +:+ */
/* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */
/* ::: :::::::: */
/* vec_math.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/25 10:11:44 by whaffman #+# #+# */
/* Updated: 2025/04/25 10:44:33 by whaffman ######## odam.nl */
/* Updated: 2025/05/06 15:20:37 by qmennen ### ########.fr */
/* */
/* ************************************************************************** */
@ -14,41 +14,40 @@
#define VEC_MATH_H
#include "types.h"
/**
* @brief Calculates the distance between two 2D vectors.
*
* @param a The first 2D vector.
* @param b The second 2D vector.
* @return The distance between vector a and vector b as a float.
* @return The distance between vector a and vector b as a double.
*/
float dist(t_vec2 a, t_vec2 b);
double dist(t_vec2 a, t_vec2 b);
/**
* @brief Calculates the norm (length) of a 2D vector.
*
* @param a The 2D vector.
* @return The norm of vector a as a float.
* @return The norm of vector a as a double.
*/
float norm(t_vec2 a);
double norm(t_vec2 a);
/**
* @brief Calculates the dot product of two 2D vectors.
*
* @param a The first 2D vector.
* @param b The second 2D vector.
* @return The dot product of vector a and vector b as a float.
* @return The dot product of vector a and vector b as a double.
*/
float dot(t_vec2 a, t_vec2 b);
double dot(t_vec2 a, t_vec2 b);
/**
* @brief Calculates the distance from a point to a line.
*
* @param point The point to calculate the distance from.
* @param line The line defined by a (support)point and a direction.
* @return The distance from the point to the line as a float.
* @return The distance from the point to the line as a double.
*/
float dist_point_line(t_vec2 point, t_vec2_line line);
double dist_point_line(t_vec2 point, t_vec2_line line);
/**
* @brief Adds two 2D vectors.
@ -75,7 +74,7 @@ t_vec2 sub(t_vec2 a, t_vec2 b);
* @param b The scalar to multiply the vector by.
* @return The result of multiplying vector a by scalar b as a new 2D vector.
*/
t_vec2 mul(t_vec2 a, float b);
t_vec2 mul(t_vec2 a, double b);
/**
* @brief Rotates a 2D vector by a given angle.
@ -84,7 +83,7 @@ t_vec2 mul(t_vec2 a, float b);
* @param angle The angle in radians to rotate the vector by.
* @return The rotated vector as a new 2D vector.
*/
t_vec2 rot(t_vec2 a, float angle);
t_vec2 rot(t_vec2 a, double angle);
/**
* @brief Calculates the perpendicular vector of a 2D vector.

View File

@ -1,18 +1,18 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* collision.c :+: :+: */
/* +:+ */
/* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */
/* ::: :::::::: */
/* collision.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/22 14:40:59 by qmennen #+# #+# */
/* Updated: 2025/05/06 14:18:07 by whaffman ######## odam.nl */
/* Updated: 2025/05/06 15:20:18 by qmennen ### ########.fr */
/* */
/* ************************************************************************** */
#include "collision.h"
int collision_horizontal(t_map *map, t_player *player, float xa)
int collision_horizontal(t_map *map, t_player *player, double xa)
{
t_tile tile;
@ -20,7 +20,7 @@ int collision_horizontal(t_map *map, t_player *player, float xa)
return (tile != TILE_WALL && tile != TILE_VOID);
}
int collision_vertical(t_map *map, t_player *player, float ya)
int collision_vertical(t_map *map, t_player *player, double ya)
{
t_tile tile;

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* game.c :+: :+: */
/* +:+ */
/* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */
/* ::: :::::::: */
/* game.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/15 15:46:08 by qmennen #+# #+# */
/* Updated: 2025/05/06 14:18:50 by whaffman ######## odam.nl */
/* Updated: 2025/05/06 15:20:18 by qmennen ### ########.fr */
/* */
/* ************************************************************************** */
@ -41,7 +41,7 @@ void free_game(t_game **game)
void game_loop(void *param)
{
t_game *game;
float delta_time;
double delta_time;
static int framecount = 0;
static int fps = 0;

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* dist.c :+: :+: */
/* +:+ */
/* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */
/* ::: :::::::: */
/* dist.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/25 10:07:59 by whaffman #+# #+# */
/* Updated: 2025/04/25 10:39:59 by whaffman ######## odam.nl */
/* Updated: 2025/05/06 15:20:18 by qmennen ### ########.fr */
/* */
/* ************************************************************************** */
@ -14,7 +14,7 @@
#include "math.h"
#include "vec_math.h"
float dist(t_vec2 a, t_vec2 b)
double dist(t_vec2 a, t_vec2 b)
{
return (sqrtf((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)));
}

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* dist_point_line.c :+: :+: */
/* +:+ */
/* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */
/* ::: :::::::: */
/* dist_point_line.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/25 10:09:45 by whaffman #+# #+# */
/* Updated: 2025/04/25 10:46:06 by whaffman ######## odam.nl */
/* Updated: 2025/05/06 15:20:18 by qmennen ### ########.fr */
/* */
/* ************************************************************************** */
@ -14,9 +14,9 @@
#include "math.h"
#include "vec_math.h"
float dist_point_line(t_vec2 point, t_vec2_line line)
double dist_point_line(t_vec2 point, t_vec2_line line)
{
float d;
double d;
t_vec2 ps;
ps = sub(line.support, point);

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* dot.c :+: :+: */
/* +:+ */
/* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */
/* ::: :::::::: */
/* dot.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/25 09:58:29 by whaffman #+# #+# */
/* Updated: 2025/04/25 10:40:02 by whaffman ######## odam.nl */
/* Updated: 2025/05/06 15:20:18 by qmennen ### ########.fr */
/* */
/* ************************************************************************** */
@ -14,7 +14,7 @@
#include "math.h"
#include "vec_math.h"
float dot(t_vec2 a, t_vec2 b)
double dot(t_vec2 a, t_vec2 b)
{
return (a.x * b.x + a.y * b.y);
}

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* mul.c :+: :+: */
/* +:+ */
/* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */
/* ::: :::::::: */
/* mul.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/25 09:56:39 by whaffman #+# #+# */
/* Updated: 2025/04/25 10:40:05 by whaffman ######## odam.nl */
/* Updated: 2025/05/06 15:20:18 by qmennen ### ########.fr */
/* */
/* ************************************************************************** */
@ -14,7 +14,7 @@
#include "math.h"
#include "vec_math.h"
t_vec2 mul(t_vec2 a, float b)
t_vec2 mul(t_vec2 a, double b)
{
t_vec2 result;

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* norm.c :+: :+: */
/* +:+ */
/* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */
/* ::: :::::::: */
/* norm.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/25 09:59:13 by whaffman #+# #+# */
/* Updated: 2025/04/25 10:40:13 by whaffman ######## odam.nl */
/* Updated: 2025/05/06 15:20:18 by qmennen ### ########.fr */
/* */
/* ************************************************************************** */
@ -14,7 +14,7 @@
#include "math.h"
#include "vec_math.h"
float norm(t_vec2 a)
double norm(t_vec2 a)
{
return (sqrtf(a.x * a.x + a.y * a.y));
}

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* rot.c :+: :+: */
/* +:+ */
/* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */
/* ::: :::::::: */
/* rot.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/25 10:35:58 by whaffman #+# #+# */
/* Updated: 2025/04/25 10:40:23 by whaffman ######## odam.nl */
/* Updated: 2025/05/06 15:20:18 by qmennen ### ########.fr */
/* */
/* ************************************************************************** */
@ -14,11 +14,11 @@
#include "math.h"
#include "vec_math.h"
t_vec2 rot(t_vec2 a, float angle)
t_vec2 rot(t_vec2 a, double angle)
{
t_vec2 result;
float cos_angle;
float sin_angle;
double cos_angle;
double sin_angle;
cos_angle = cosf(angle);
sin_angle = sinf(angle);

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* parse_map.c :+: :+: */
/* +:+ */
/* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */
/* ::: :::::::: */
/* parse_map.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/22 13:12:04 by whaffman #+# #+# */
/* Updated: 2025/05/04 15:07:44 by whaffman ######## odam.nl */
/* Updated: 2025/05/06 15:20:18 by qmennen ### ########.fr */
/* */
/* ************************************************************************** */
@ -17,8 +17,8 @@ t_vec2 parse_dir(int x, int y)
{
t_vec2 dir;
dir.x = (float)x;
dir.y = (float)y;
dir.x = (double)x;
dir.y = (double)y;
return (dir);
}
@ -27,8 +27,8 @@ int parse_player(t_game *game, int y, int x, char c)
t_player *player;
player = game->player;
player->pos.x = ((float)x + 0.5f);
player->pos.y = ((float)y + 0.5f);
player->pos.x = ((double)x + 0.5f);
player->pos.y = ((double)y + 0.5f);
if (c == 'N')
player->dir = parse_dir(0, -1);

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* player.c :+: :+: */
/* +:+ */
/* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */
/* ::: :::::::: */
/* player.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/15 18:53:19 by qmennen #+# #+# */
/* Updated: 2025/05/06 14:20:37 by whaffman ######## odam.nl */
/* Updated: 2025/05/06 15:20:18 by qmennen ### ########.fr */
/* */
/* ************************************************************************** */
@ -31,10 +31,10 @@ int player_create(t_game **game)
return (SUCCESS);
}
static void move(t_map *map, t_player *player, int dir, float delta)
static void move(t_map *map, t_player *player, int dir, double delta)
{
float xa;
float ya;
double xa;
double ya;
xa = dir * player->dir.x * player->speed * delta;
ya = dir * player->dir.y * player->speed * delta;
@ -44,10 +44,10 @@ static void move(t_map *map, t_player *player, int dir, float delta)
player->pos.y += ya;
}
static void strave(t_map *map, t_player *player, int dir, float delta)
static void strave(t_map *map, t_player *player, int dir, double delta)
{
float xa;
float ya;
double xa;
double ya;
xa = dir * perp(player->dir).x * player->speed * delta;
ya = dir * perp(player->dir).y * player->speed * delta;
@ -57,13 +57,13 @@ static void strave(t_map *map, t_player *player, int dir, float delta)
player->pos.y += ya;
}
static void rotate(t_player *player, float rot_speed)
static void rotate(t_player *player, double rot_speed)
{
player->dir = rot(player->dir, rot_speed);
player->camera = rot(player->camera, rot_speed);
}
void player_update(t_game *game, float delta_time)
void player_update(t_game *game, double delta_time)
{
if (get_key(game, MLX_KEY_W))
move(game->map, game->player, 1, delta_time);
@ -83,10 +83,7 @@ void player_render(t_screen *screen, t_player *player)
{
t_vec2 direction;
if (player->pos.x < 0
|| player->pos.x >= screen->width
|| player->pos.y < 0
|| player->pos.y >= screen->height)
if (player->pos.x < 0 || player->pos.x >= screen->width || player->pos.y < 0 || player->pos.y >= screen->height)
return;
render_circle(screen, mul(player->pos, TILE_SIZE), 4, 0x111111ff);
direction = add(mul(player->pos, TILE_SIZE), mul(player->dir, TILE_SIZE));

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* DDAscratch.c :+: :+: */
/* +:+ */
/* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */
/* ::: :::::::: */
/* DDAscratch.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/05/02 11:58:09 by whaffman #+# #+# */
/* Updated: 2025/05/06 14:25:00 by whaffman ######## odam.nl */
/* Updated: 2025/05/06 15:21:22 by qmennen ### ########.fr */
/* */
/* ************************************************************************** */
@ -18,10 +18,15 @@ t_vec2 get_delta_dist(t_vec2 ray_dir)
{
t_vec2 delta_dist;
delta_dist.x = (ray_dir.x == 0) * 1e30
+ (ray_dir.x != 0) * fabs(1 / ray_dir.x);
delta_dist.y = (ray_dir.y == 0) * 1e30
+ (ray_dir.y != 0) * fabs(1 / ray_dir.y);
if (ray_dir.x == 0)
delta_dist.x = 1e30;
else
delta_dist.x = fabs(1 / ray_dir.x);
if (ray_dir.y == 0)
delta_dist.y = 1e30;
else
delta_dist.y = fabs(1 / ray_dir.y);
return (delta_dist);
}
@ -41,10 +46,8 @@ t_vec2 get_side_dist(t_vec2 ray_dir, t_vec2 pos, t_vec2 delta_dist)
const int raydir_y_pos = (ray_dir.y >= 0);
t_vec2 side_dist;
side_dist.x = ((1 - raydir_x_pos) * frac_pos.x
+ raydir_x_pos * (1 - frac_pos.x)) * delta_dist.x;
side_dist.y = ((1 - raydir_y_pos) * frac_pos.y
+ raydir_y_pos * (1 - frac_pos.y)) * delta_dist.y;
side_dist.x = ((1 - raydir_x_pos) * frac_pos.x + raydir_x_pos * (1 - frac_pos.x)) * delta_dist.x;
side_dist.y = ((1 - raydir_y_pos) * frac_pos.y + raydir_y_pos * (1 - frac_pos.y)) * delta_dist.y;
return (side_dist);
}
@ -63,8 +66,7 @@ int dda_main(t_vec2 ray_dir, t_vec2_int map_pos, t_vec2 *side_dist, t_map *map)
side_dist->y += delta_dist.y * side;
map_pos.x += step.x * (1 - side);
map_pos.y += step.y * side;
if (map_pos.x < 0 || map_pos.x >= map->width
|| map_pos.y < 0 || map_pos.y >= map->height)
if (map_pos.x < 0 || map_pos.x >= map->width || map_pos.y < 0 || map_pos.y >= map->height)
printf("Out of bounds: %d %d\n", map_pos.x, map_pos.y);
hit = (map->grid[map_pos.y][map_pos.x] == TILE_WALL);
}
@ -74,7 +76,7 @@ int dda_main(t_vec2 ray_dir, t_vec2_int map_pos, t_vec2 *side_dist, t_map *map)
// Returns the distance to the wall hit if the wall is hit in y
// direction the result is negative, if the wall is hit
// in x direction the result is positive
float dda(t_vec2 ray_dir, t_vec2 pos, t_map *map)
double dda(t_vec2 ray_dir, t_vec2 pos, t_map *map)
{
const t_vec2 delta_dist = get_delta_dist(ray_dir);
t_vec2 side_dist;
@ -85,11 +87,10 @@ float dda(t_vec2 ray_dir, t_vec2 pos, t_map *map)
(t_vec2_int){(int)pos.x, (int)pos.y},
&side_dist,
map);
return ((1 - side) * (side_dist.x - delta_dist.x)
- side * (side_dist.y - delta_dist.y));
return ((1 - side) * (side_dist.x - delta_dist.x) - side * (side_dist.y - delta_dist.y));
}
t_side get_side(t_vec2 ray_dir, float perp_dist)
t_side get_side(t_vec2 ray_dir, double perp_dist)
{
if (perp_dist > 0)
{
@ -112,34 +113,30 @@ t_render cast_ray(t_game *game, int x)
t_vec2 ray_dir;
t_vec2 pos;
t_render render;
float perp_dist;
double perp_dist;
ray_dir = add(game->player->dir,
mul(game->player->camera,
(2.0f * x / (float)game->screen->width - 1)));
(2.0f * x / (double)game->screen->width - 1)));
pos = game->player->pos;
perp_dist = dda(ray_dir, pos, game->map);
render.perp_dist = fabs(perp_dist);
render.side = get_side(ray_dir, perp_dist);
render.wall_x = (perp_dist > 0) * (pos.x + ray_dir.x * perp_dist)
+ (perp_dist <= 0) * (pos.y + ray_dir.y * perp_dist);
render.wall_x = (perp_dist > 0) * (pos.x + ray_dir.x * perp_dist) + (perp_dist <= 0) * (pos.y + ray_dir.y * perp_dist);
render.wall_x -= floor(render.wall_x);
return (render);
}
unsigned int get_color(t_render render)
{
float dist;
double dist;
const unsigned int color[4] = {
0x488B49,
0x4AAD52,
0x6EB257,
0xC5E063
};
0xC5E063};
dist = (render.perp_dist == 0) * 1e30
+ (render.perp_dist > 1) * render.perp_dist
+ (render.perp_dist <= 1) * 1;
dist = (render.perp_dist == 0) * 1e30 + (render.perp_dist > 1) * render.perp_dist + (render.perp_dist <= 1) * 1;
return (color[render.side] << 8 | (int)(1.0 / dist * 255));
}
@ -162,11 +159,9 @@ void draw_line(t_game *game, t_render render, int x)
while (y < game->screen->height)
{
if (y < drawStart)
color = game->map->ceiling_color << 8
| (int)fabs(2 * y * 0xFF / (float)game->screen->height - 0xFF);
color = game->map->ceiling_color << 8 | (int)fabs(2 * y * 0xFF / (double)game->screen->height - 0xFF);
else if (y > drawEnd)
color = game->map->floor_color << 8
| (int)fabs(2 * y * 0xFF / (float)game->screen->height - 0xFF);
color = game->map->floor_color << 8 | (int)fabs(2 * y * 0xFF / (double)game->screen->height - 0xFF);
else
color = get_color(render);
mlx_put_pixel(game->screen->img, x, y, color);