tmp push merge resolution not finished
This commit is contained in:
parent
2568aa69a6
commit
00dc0e9e67
16 changed files with 454 additions and 59 deletions
80
mlx_layer/mooves.c
Normal file
80
mlx_layer/mooves.c
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* mooves.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/11/28 14:10:44 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/11/28 14:50:48 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "cub3d.h"
|
||||
#include "cub3d_struct.h"
|
||||
|
||||
void move_straight(t_info *data)
|
||||
{
|
||||
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});
|
||||
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)});
|
||||
if (tile_y->tile_type == EMPTY)
|
||||
data->player.pos.y += data->player.dir.y * MOVE_SPEED;
|
||||
}
|
||||
|
||||
void move_backward(t_info *data)
|
||||
{
|
||||
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});
|
||||
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)});
|
||||
if (tile_y->tile_type == EMPTY)
|
||||
data->player.pos.y -= data->player.dir.y * MOVE_SPEED;
|
||||
}
|
||||
|
||||
void move_left(t_info *data)
|
||||
{
|
||||
t_dpoint pplayer;
|
||||
t_tile *tile_x;
|
||||
t_tile *tile_y;
|
||||
|
||||
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});
|
||||
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)});
|
||||
if (tile_y->tile_type == EMPTY)
|
||||
data->player.pos.y += pplayer.y * MOVE_SPEED;
|
||||
}
|
||||
|
||||
void move_right(t_info *data)
|
||||
{
|
||||
t_dpoint pplayer;
|
||||
t_tile *tile_x;
|
||||
t_tile *tile_y;
|
||||
|
||||
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});
|
||||
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)});
|
||||
if (tile_y->tile_type == EMPTY)
|
||||
data->player.pos.y -= pplayer.y * MOVE_SPEED;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue