Cub3D
Loading...
Searching...
No Matches
set_direction.c
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* set_direction.c :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: kamitsui <kamitsui@student.42tokyo.jp> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2024/09/12 16:27:02 by kamitsui #+# #+# */
9/* Updated: 2024/11/16 03:03:59 by kamitsui ### ########.fr */
10/* */
11/* ************************************************************************** */
12
13#include "cub3d.h"
14
15static void set_north_direction(
16 t_vector *ray_dir, t_vector *camera_forcal_plane)
17{
18 ray_dir->x = 0;
19 ray_dir->y = -1;
20 camera_forcal_plane->x = 0.66;
21 camera_forcal_plane->y = 0;
22}
23
24static void set_south_direction(
25 t_vector *ray_dir, t_vector *camera_forcal_plane)
26{
27 ray_dir->x = 0;
28 ray_dir->y = 1;
29 camera_forcal_plane->x = -0.66;
30 camera_forcal_plane->y = 0;
31}
32
33static void set_west_direction(
34 t_vector *ray_dir, t_vector *camera_forcal_plane)
35{
36 ray_dir->x = -1;
37 ray_dir->y = 0;
38 camera_forcal_plane->x = 0;
39 camera_forcal_plane->y = -0.66;
40}
41
42static void set_east_direction(
43 t_vector *ray_dir, t_vector *camera_forcal_plane)
44{
45 ray_dir->x = 1;
46 ray_dir->y = 0;
47 camera_forcal_plane->x = 0;
48 camera_forcal_plane->y = 0.66;
49}
50
51void set_direction(char direction, t_player *player)
52{
53 if (direction == 'N')
54 set_north_direction(&player->ray_dir, &player->camera_forcal_plane);
55 else if (direction == 'S')
56 set_south_direction(&player->ray_dir, &player->camera_forcal_plane);
57 else if (direction == 'W')
58 set_west_direction(&player->ray_dir, &player->camera_forcal_plane);
59 else if (direction == 'E')
60 set_east_direction(&player->ray_dir, &player->camera_forcal_plane);
61}
keyboard event flag
Definition type_cub3d.h:226
vector
Definition type_cub3d.h:74