style: normed all the repo (except the debug function and the too_many_args

This commit is contained in:
Raphael 2024-12-01 18:59:17 +01:00
parent 57c7893501
commit 954c5f76d6
12 changed files with 244 additions and 207 deletions

View file

@ -6,12 +6,13 @@
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/11/28 14:10:44 by bgoulard #+# #+# */
/* Updated: 2024/12/01 17:15:27 by bgoulard ### ########.fr */
/* Updated: 2024/12/01 18:36:26 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "cub3d.h"
#include "cub3d_struct.h"
#include "cub3d_parsing.h"
void update_pos_i(t_player *player)
{
@ -21,15 +22,17 @@ void update_pos_i(t_player *player)
void move_straight(t_info *data)
{
t_tile *tile_x;
t_tile *tile_y;
t_tile *tile_x;
t_tile *tile_y;
tile_x = c3_get_cell(data->map.map, data->map.size,
(t_ipoint){(int)(data->player.pos.x + data->player.dir.x * MOVE_SPEED), (int)data->player.pos.y});
tile_x = c3_get_cell(data->map.map, data->map.size, \
(t_ipoint){(int)(data->player.pos.x + data->player.dir.x * MOVE_SPEED), \
(int)data->player.pos.y});
if (tile_x->tile_type == EMPTY)
data->player.pos.x += data->player.dir.x * MOVE_SPEED;
tile_y = c3_get_cell(data->map.map, data->map.size,
(t_ipoint){(int)data->player.pos.x, (int)(data->player.pos.y + data->player.dir.y * MOVE_SPEED)});
tile_y = c3_get_cell(data->map.map, data->map.size, \
(t_ipoint){(int)data->player.pos.x, (int)(data->player.pos.y \
+ data->player.dir.y * MOVE_SPEED)});
if (tile_y->tile_type == EMPTY)
data->player.pos.y += data->player.dir.y * MOVE_SPEED;
update_pos_i(&data->player);
@ -37,15 +40,17 @@ void move_straight(t_info *data)
void move_backward(t_info *data)
{
t_tile *tile_x;
t_tile *tile_y;
t_tile *tile_x;
t_tile *tile_y;
tile_x = c3_get_cell(data->map.map, data->map.size,
(t_ipoint){(int)(data->player.pos.x - data->player.dir.x * MOVE_SPEED), (int)data->player.pos.y});
tile_x = c3_get_cell(data->map.map, data->map.size, \
(t_ipoint){(int)(data->player.pos.x - data->player.dir.x * MOVE_SPEED), \
(int)data->player.pos.y});
if (tile_x->tile_type == EMPTY)
data->player.pos.x -= data->player.dir.x * MOVE_SPEED;
tile_y = c3_get_cell(data->map.map, data->map.size,
(t_ipoint){(int)data->player.pos.x, (int)(data->player.pos.y - data->player.dir.y * MOVE_SPEED)});
tile_y = c3_get_cell(data->map.map, data->map.size, \
(t_ipoint){(int)data->player.pos.x, (int)(data->player.pos.y \
- data->player.dir.y * MOVE_SPEED)});
if (tile_y->tile_type == EMPTY)
data->player.pos.y -= data->player.dir.y * MOVE_SPEED;
update_pos_i(&data->player);
@ -59,12 +64,14 @@ void move_left(t_info *data)
pplayer.x = -data->player.dir.y;
pplayer.y = data->player.dir.x;
tile_x = c3_get_cell(data->map.map, data->map.size,
(t_ipoint){(int)(data->player.pos.x + pplayer.x * MOVE_SPEED), (int)data->player.pos.y});
tile_x = c3_get_cell(data->map.map, data->map.size, \
(t_ipoint){(int)(data->player.pos.x + pplayer.x * MOVE_SPEED), \
(int)data->player.pos.y});
if (tile_x->tile_type == EMPTY)
data->player.pos.x += pplayer.x * MOVE_SPEED;
tile_y = c3_get_cell(data->map.map, data->map.size,
(t_ipoint){(int)data->player.pos.x, (int)(data->player.pos.y + pplayer.y * MOVE_SPEED)});
tile_y = c3_get_cell(data->map.map, data->map.size, \
(t_ipoint){(int)data->player.pos.x, (int)(data->player.pos.y + \
pplayer.y * MOVE_SPEED)});
if (tile_y->tile_type == EMPTY)
data->player.pos.y += pplayer.y * MOVE_SPEED;
update_pos_i(&data->player);
@ -78,12 +85,14 @@ void move_right(t_info *data)
pplayer.x = -data->player.dir.y;
pplayer.y = data->player.dir.x;
tile_x = c3_get_cell(data->map.map, data->map.size,
(t_ipoint){(int)(data->player.pos.x - pplayer.x * MOVE_SPEED), (int)data->player.pos.y});
tile_x = c3_get_cell(data->map.map, data->map.size, \
(t_ipoint){(int)(data->player.pos.x - pplayer.x * MOVE_SPEED), \
(int)data->player.pos.y});
if (tile_x->tile_type == EMPTY)
data->player.pos.x -= pplayer.x * MOVE_SPEED;
tile_y = c3_get_cell(data->map.map, data->map.size,
(t_ipoint){(int)data->player.pos.x, (int)(data->player.pos.y - pplayer.y * MOVE_SPEED)});
tile_y = c3_get_cell(data->map.map, data->map.size, \
(t_ipoint){(int)data->player.pos.x, (int)(data->player.pos.y - pplayer.y \
* MOVE_SPEED)});
if (tile_y->tile_type == EMPTY)
data->player.pos.y -= pplayer.y * MOVE_SPEED;
update_pos_i(&data->player);