diff --git a/src/game.c b/src/game.c index 20be8af..abe1822 100644 --- a/src/game.c +++ b/src/game.c @@ -37,33 +37,23 @@ t_cell_type MAP[] = { MAP_WALL, MAP_WALL, MAP_WALL, MAP_WALL, MAP_WALL, MAP_WALL, MAP_WALL, MAP_WALL, }; -static void init_map(t_map *m) -{ - // m->level = MAP; - // m->width = MAP_WIDTH; - // m->height = MAP_HEIGHT; -} - - - void game_init(t_meta *meta) { t_player* const p = &meta->player; timer_init(&meta->update_timer, mlx_get_time); timer_start(&meta->update_timer); - - init_map(&meta->map); - // Give player a reference to meta struct. p->meta = meta; - // Setup player initial position, later this correspond with the PLAYER_START in the map. - p->position[VEC_X] = (float) meta->map.width * CELL_WIDTH / 2; - p->position[VEC_Y] = (float) meta->map.height * CELL_WIDTH/ 2; + printf("Player direction X: %f Y: %f\n", meta->player.direction[VEC_X], meta->player.direction[VEC_Y]); + printf("Player position X: %f Y: %f\n", meta->player.position[VEC_X], meta->player.position[VEC_Y]); + // // Setup player initial position, later this correspond with the PLAYER_START in the map. + // p->position[VEC_X] = (float) meta->map.width * CELL_WIDTH / 2; + // p->position[VEC_Y] = (float) meta->map.height * CELL_WIDTH/ 2; - player_look(p, deg_to_rad(180.0f)); + // player_look(p, deg_to_rad(180.0f)); } // This function handles all the "simulation" type stuff such as moving players opening doors, etc. diff --git a/src/parser/check_map.c b/src/parser/check_map.c index 80e975a..ce2344a 100644 --- a/src/parser/check_map.c +++ b/src/parser/check_map.c @@ -54,6 +54,19 @@ int flood_fill(t_meta *meta, char *map, int x, int y) return (ret); } +// change if statements +void save_start_direction(t_meta *meta, char p) +{ + if (p == 'N') + meta->player.direction[VEC_Y] = 1; + if (p == 'S') + meta->player.direction[VEC_Y] = -1; + if (p == 'E') + meta->player.direction[VEC_X] = 1; + if (p == 'W') + meta->player.direction[VEC_X] = -1; +} + bool save_start_pos(t_meta *meta, char *map) { uint32_t x; @@ -71,6 +84,7 @@ bool save_start_pos(t_meta *meta, char *map) { meta->player.position[VEC_Y] = y; meta->player.position[VEC_X] = x; + save_start_direction(meta, map[find_index(meta, x, y)]); found = true; } x++; diff --git a/src/raycaster.c b/src/raycaster.c deleted file mode 100644 index 1e92a5d..0000000 --- a/src/raycaster.c +++ /dev/null @@ -1,24 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* raycaster.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: yzaim +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/11/09 17:58:20 by yzaim #+# #+# */ -/* Updated: 2023/11/09 18:05:01 by yzaim ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "meta.h" - -void raycaster(t_meta *meta) -{ - int x; - - x = -1; - while (++x < MAP_WIDTH) - { - //search the intersections with x-lines - } -} diff --git a/test_maps/valid.cub b/test_maps/valid.cub index 73a1f95..c857f4b 100644 --- a/test_maps/valid.cub +++ b/test_maps/valid.cub @@ -13,5 +13,5 @@ C 12, 34,3 1000000001 100000000111 100000000001 -1000000N011 +1000000E011 1111111111