Cub3D
Loading...
Searching...
No Matches
get_player_info.c
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* get_player_info.c :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: hnagasak <hnagasak@student.42tokyo.jp> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2024/10/07 01:17:48 by kamitsui #+# #+# */
9/* Updated: 2024/12/20 18:00:01 by kamitsui ### ########.fr */
10/* */
11/* ************************************************************************** */
12
13#include "cub3d.h"
14
15static int process_map_grid(t_map *map, t_player *player, t_parse *parse)
16{
17 t_point grid;
18
19 grid.y = 0;
20 while (grid.y < map->height)
21 {
22 grid.x = 0;
23 while (grid.x < map->width)
24 {
25 if (find_player_and_set(map->data, grid, parse, player)
26 != EXIT_SUCCESS)
27 return (EXIT_FAILURE);
28 grid.x++;
29 }
30 grid.y++;
31 }
32 return (EXIT_SUCCESS);
33}
34
38int get_player_info(const char *line, t_parse *parse)
39{
40 t_map *map;
41 t_player *player;
42
43 (void)line;
44 map = &parse->game->map;
45 player = &parse->game->player;
46 if (process_map_grid(map, player, parse) != EXIT_SUCCESS)
47 return (EXIT_FAILURE);
48 if ((parse->flag & BIT_PLAYER) == 0x00)
49 {
50 ft_eprintf("%s%s\n", ERR_PROMPT, EMSG_MAP_PLAYER_MISS);
51 return (EXIT_FAILURE);
52 }
53 player->move_speed = MOVE_SPEED;
54 player->rotate_speed = ROTATE_SPEED;
55 return (EXIT_SUCCESS);
56}
57 //debug_map_data(*map, "get_player_info()");
58 //debug_player(map->debug.fd, *player, "get_player_info()");
game map
Definition type_cub3d.h:237
keyboard event flag
Definition type_cub3d.h:226