commit c510a406a8ea80843774ed972284df4fd9d2b36c
parent 8fc820ac0ab0014b80ec629b8e8669f306badf82
Author: Amin Mesbah <dev@aminmesbah.com>
Date: Wed, 8 May 2019 22:26:30 -0700
Note that we aren't retrieving the correct rooms
Try going down.
Diffstat:
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/game.c b/src/game.c
@@ -209,7 +209,17 @@ void game_update_and_render(struct GameMemory *game_memory, struct GameInput *ga
v2i current_room_i = game_state->player.pos.room;
struct Room *r = world_room_get(game_state->world, current_room_i);
+
assert(r);
+
+ printf("------------\n");
+ printf("Current Player Room: ");
+ math_print(current_room_i);
+ printf("Current Actual Room: ");
+ math_print(r->index);
+
+ assert(math_v2i_eq(current_room_i, r->index));
+
u32 *tiles = r->tiles;
// render tiles
diff --git a/src/world.c b/src/world.c
@@ -130,7 +130,7 @@ internal size_t world_room_get_index_within_chunk(v2i room_i)
assert(room_i_lower_bits.x < CHUNK_ROOMS_PER_SIDE);
assert(room_i_lower_bits.y < CHUNK_ROOMS_PER_SIDE);
- size_t room_i_within_chunk = room_i_lower_bits.x + room_i_lower_bits.y * CHUNK_ROOMS_PER_SIDE;
+ size_t room_i_within_chunk = room_i_lower_bits.x + (room_i_lower_bits.y * CHUNK_ROOMS_PER_SIDE);
assert(room_i_within_chunk < CHUNK_NUM_ROOMS);
return room_i_within_chunk;
}