Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Yesim Zaim committed Dec 14, 2023
1 parent 85942bd commit fe9bf7a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 41 deletions.
22 changes: 6 additions & 16 deletions src/game.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
14 changes: 14 additions & 0 deletions src/parser/check_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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++;
Expand Down
24 changes: 0 additions & 24 deletions src/raycaster.c

This file was deleted.

2 changes: 1 addition & 1 deletion test_maps/valid.cub
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ C 12, 34,3
1000000001
100000000111
100000000001
1000000N011
1000000E011
1111111111

0 comments on commit fe9bf7a

Please sign in to comment.