commit 52a4c62c5f688cd670043e034ab7532068df5ee8
parent fcf3f977dc68f406ef820e81f98650b83d282822
Author: amin <dev@aminmesbah.com>
Date: Sat, 9 Nov 2019 04:51:05 +0000
Improve room dimension constant name
FossilOrigin-Name: 0165d2029af73d0d76562946a70546ab959987a28a626c0ac4cb3ba0282235c4
Diffstat:
3 files changed, 23 insertions(+), 23 deletions(-)
diff --git a/src/game.c b/src/game.c
@@ -169,16 +169,16 @@ void game_update_and_render(struct GameMemory *game_memory, struct GameInput *ga
f32 screen_aspect_ratio = (f32)framebuffer.width / (f32)framebuffer.height;
if (screen_aspect_ratio < ROOM_ASPECT_RATIO)
{
- ppm = (f32)framebuffer.width / (f32)ROOM_TILE_DIM_X;
+ ppm = (f32)framebuffer.width / (f32)ROOM_DIM_X;
}
else
{
- ppm = (f32)framebuffer.height / (f32)ROOM_TILE_DIM_Y;
+ ppm = (f32)framebuffer.height / (f32)ROOM_DIM_Y;
}
v2 viewport_size = {
- ppm * (f32)ROOM_TILE_DIM_X,
- ppm * (f32)ROOM_TILE_DIM_Y,
+ ppm * (f32)ROOM_DIM_X,
+ ppm * (f32)ROOM_DIM_Y,
};
f32 h_pad_size = (framebuffer.width - viewport_size.width) / 2.0f;
@@ -516,13 +516,13 @@ void game_update_and_render(struct GameMemory *game_memory, struct GameInput *ga
// game_render_tiles
{
- for (size_t y = 0; y < ROOM_TILE_DIM_Y; y++)
+ for (size_t y = 0; y < ROOM_DIM_Y; y++)
{
- for (size_t x = 0; x < ROOM_TILE_DIM_X; x++)
+ for (size_t x = 0; x < ROOM_DIM_X; x++)
{
v2 tile_pos = {
x,
- ROOM_TILE_DIM_Y - 1.0f - y,
+ ROOM_DIM_Y - 1.0f - y,
};
m4 model = math_m4_init_id();
diff --git a/src/world.c b/src/world.c
@@ -6,23 +6,23 @@ internal struct AbsolutePos world_pos_recanonicalize(struct AbsolutePos p)
if (p.local.x < 0.0f)
{
room_index_delta.x -= 1;
- p_final.local.x = math_wrap(p.local.x, 0.0f, ROOM_TILE_DIM_X);
+ p_final.local.x = math_wrap(p.local.x, 0.0f, ROOM_DIM_X);
}
- else if (p.local.x > ROOM_TILE_DIM_X)
+ else if (p.local.x > ROOM_DIM_X)
{
room_index_delta.x += 1;
- p_final.local.x = math_wrap(p.local.x, 0.0f, ROOM_TILE_DIM_X);
+ p_final.local.x = math_wrap(p.local.x, 0.0f, ROOM_DIM_X);
}
if (p.local.y < 0.0f)
{
room_index_delta.y -= 1;
- p_final.local.y = math_wrap(p.local.y, 0.0f, ROOM_TILE_DIM_Y);
+ p_final.local.y = math_wrap(p.local.y, 0.0f, ROOM_DIM_Y);
}
- else if (p.local.y > ROOM_TILE_DIM_Y)
+ else if (p.local.y > ROOM_DIM_Y)
{
room_index_delta.y += 1;
- p_final.local.y = math_wrap(p.local.y, 0.0f, ROOM_TILE_DIM_Y);
+ p_final.local.y = math_wrap(p.local.y, 0.0f, ROOM_DIM_Y);
}
p_final.room = math_v2i_a(p.room, room_index_delta);
@@ -230,18 +230,18 @@ internal u8 get_tile_value(u8 *tiles, v2 tile_pos)
v2u tile_i_2d = {
tile_pos.x,
- ROOM_TILE_DIM_Y - 1.0f - tile_pos.y,
+ ROOM_DIM_Y - 1.0f - tile_pos.y,
};
assert(math_v2_lt(
(v2) {tile_i_2d.x, tile_i_2d.y},
- (v2) {ROOM_TILE_DIM_X, ROOM_TILE_DIM_Y}));
+ (v2) {ROOM_DIM_X, ROOM_DIM_Y}));
assert(math_v2_ge(
(v2) {tile_i_2d.x, tile_i_2d.y},
(v2) {0}));
- u32 tile_i_linearized = (ROOM_TILE_DIM_X * tile_i_2d.y) + tile_i_2d.x;
+ u32 tile_i_linearized = (ROOM_DIM_X * tile_i_2d.y) + tile_i_2d.x;
assert(tile_i_linearized < ROOM_TILE_COUNT);
u8 tile_value = tiles[tile_i_linearized];
@@ -280,15 +280,15 @@ internal bool wall_is_screen_edge(segment wall)
assert(wall_is_vertical || wall_is_horizontal);
assert(math_v2_ge(wall.min, (v2) {0}));
- assert(math_v2_le(wall.max, (v2) {ROOM_TILE_DIM_X, ROOM_TILE_DIM_Y}));
+ assert(math_v2_le(wall.max, (v2) {ROOM_DIM_X, ROOM_DIM_Y}));
if (wall_is_vertical)
{
- is_screen_edge = wall.min.x == 0.0f || wall.min.x == ROOM_TILE_DIM_X;
+ is_screen_edge = wall.min.x == 0.0f || wall.min.x == ROOM_DIM_X;
}
else
{
- is_screen_edge = wall.min.y == 0.0f || wall.min.y == ROOM_TILE_DIM_Y;
+ is_screen_edge = wall.min.y == 0.0f || wall.min.y == ROOM_DIM_Y;
}
return is_screen_edge;
diff --git a/src/world.h b/src/world.h
@@ -1,10 +1,10 @@
// TODO: delete
#define MAX_ROOMS 120
-#define ROOM_TILE_DIM_X 25
-#define ROOM_TILE_DIM_Y 10
-#define ROOM_TILE_COUNT ROOM_TILE_DIM_X * ROOM_TILE_DIM_Y
-#define ROOM_ASPECT_RATIO (f32)ROOM_TILE_DIM_X / (f32)ROOM_TILE_DIM_Y
+#define ROOM_DIM_X 25
+#define ROOM_DIM_Y 10
+#define ROOM_TILE_COUNT ROOM_DIM_X * ROOM_DIM_Y
+#define ROOM_ASPECT_RATIO (f32)ROOM_DIM_X / (f32)ROOM_DIM_Y
#define NUM_CHUNK_BUCKETS 2048
static_assert(