2025-07-29 12:14:44 +02:00
|
|
|
/* ************************************************************************** */
|
|
|
|
|
/* */
|
|
|
|
|
/* ::: :::::::: */
|
|
|
|
|
/* player.c :+: :+: :+: */
|
|
|
|
|
/* +:+ +:+ +:+ */
|
2025-08-06 11:24:15 +02:00
|
|
|
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
2025-07-29 12:14:44 +02:00
|
|
|
/* +#+#+#+#+#+ +#+ */
|
2025-08-06 11:24:15 +02:00
|
|
|
/* Created: 2025/08/06 11:29:14 by kcolin #+# #+# */
|
2025-09-01 15:43:30 +02:00
|
|
|
/* Updated: 2025/09/01 15:36:43 by tchampio ### ########.fr */
|
2025-07-29 12:14:44 +02:00
|
|
|
/* */
|
|
|
|
|
/* ************************************************************************** */
|
|
|
|
|
|
|
|
|
|
#include "player.h"
|
|
|
|
|
#include "../map/mapdata.h"
|
|
|
|
|
#include "../consts.h"
|
|
|
|
|
|
|
|
|
|
// east west
|
|
|
|
|
void init_lon(t_player *player, char dir)
|
|
|
|
|
{
|
|
|
|
|
if (dir == 'N')
|
|
|
|
|
{
|
|
|
|
|
player->dir_x = 0;
|
|
|
|
|
player->dir_y = -1;
|
|
|
|
|
player->plane_x = PLANE_VALUE;
|
|
|
|
|
player->plane_y = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
player->dir_x = 0;
|
|
|
|
|
player->dir_y = 1;
|
|
|
|
|
player->plane_x = -PLANE_VALUE;
|
|
|
|
|
player->plane_y = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-07-29 20:13:43 +02:00
|
|
|
|
2025-07-29 12:14:44 +02:00
|
|
|
// north south
|
|
|
|
|
void init_lat(t_player *player, char dir)
|
|
|
|
|
{
|
|
|
|
|
if (dir == 'E')
|
|
|
|
|
{
|
|
|
|
|
player->dir_x = 1;
|
|
|
|
|
player->dir_y = 0;
|
|
|
|
|
player->plane_x = 0;
|
|
|
|
|
player->plane_y = PLANE_VALUE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
player->dir_x = -1;
|
|
|
|
|
player->dir_y = 0;
|
|
|
|
|
player->plane_x = 0;
|
|
|
|
|
player->plane_y = -PLANE_VALUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void init_player(t_player *player, t_mapdata *map)
|
|
|
|
|
{
|
|
|
|
|
char dir;
|
|
|
|
|
|
|
|
|
|
dir = map->map[map->starty][map->startx];
|
|
|
|
|
player->x = map->startx + 0.5;
|
|
|
|
|
player->y = map->starty + 0.5;
|
|
|
|
|
player->health = 100;
|
2025-09-01 15:43:30 +02:00
|
|
|
player->points = 500;
|
2025-07-29 12:14:44 +02:00
|
|
|
if (dir == 'N' || dir == 'S')
|
|
|
|
|
init_lon(player, dir);
|
|
|
|
|
else
|
|
|
|
|
init_lat(player, dir);
|
|
|
|
|
}
|