commit 3c3f5d7c977341ea36ea02f806f37cd9b40ba294
parent 40e2c03d9bc6d4af446d4765930abfe754b08d16
Author: Amin Mesbah <dev@aminmesbah.com>
Date: Sun, 9 Jun 2019 13:09:25 -0700
Don't consider tiles past world edge for collision
Diffstat:
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/src/game.c b/src/game.c
@@ -222,7 +222,7 @@ void game_update_and_render(struct GameMemory *game_memory, struct GameInput *ga
{
v2i c_i = world_room_get_chunk_index(current_room_i);
- struct WorldChunk* c = world_chunk_get(game_state->world, c_i);
+ struct WorldChunk *c = world_chunk_get(game_state->world, c_i);
assert(c);
printf("------------\n");
printf("Current Player Room: ");
@@ -400,13 +400,21 @@ void game_update_and_render(struct GameMemory *game_memory, struct GameInput *ga
// NOTE(amin): pointer alias
u32 *tile_set = tiles;
+ bool tile_is_past_world_edge = false;
if (!math_v2i_eq(tile_pos.room, current_room_i))
{
struct Room *room_containing_tile = world_room_get(game_state->world, tile_pos.room);
- tile_set = room_containing_tile->tiles;
+ if (room_containing_tile)
+ {
+ tile_set = room_containing_tile->tiles;
+ }
+ else
+ {
+ tile_is_past_world_edge = true;
+ }
}
- if (tile_is_solid(tile_set, tile_pos.local))
+ if ((!tile_is_past_world_edge) && tile_is_solid(tile_set, tile_pos.local))
{
rect tile_aabb = {
.min = {tile_x, tile_y},