a-game

2D platformer written from scratch.
git clone git://git.amin.space/a-game.git
Log | Files | Refs | README | LICENSE

commit 94cf8fa278e32716a73b27d56628b1c9b3e7ee61
parent 0158648bfb858b9d8ad813a31ffce4d43a95c995
Author: amin <dev@aminmesbah.com>
Date:   Sun,  2 Jun 2019 22:44:14 +0000

Explicitly floor rather than zero truncate

FossilOrigin-Name: bac60b799fe3e86da6fa8c8aa32387911cec774484e84d48d459b6f546013180
Diffstat:
Msrc/am_math.h | 6++++++
Msrc/game.c | 8++++----
2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/am_math.h b/src/am_math.h @@ -38,6 +38,12 @@ internal inline f32 math_wrap(f32 n, f32 min, f32 max) } } +internal inline i32 math_floor(f32 x) +{ + i32 result = floorf(x); + return result; +} + internal inline f32 math_rand(f32 min, f32 max) { assert(min < max); diff --git a/src/game.c b/src/game.c @@ -372,12 +372,12 @@ void game_update_and_render(struct GameMemory *game_memory, struct GameInput *ga rect tile_search_range = { .min = { - (i32)math_max(0.0f, player_traversal_occupancy_bb.min.x - 1), - (i32)math_max(0.0f, player_traversal_occupancy_bb.min.y - 1), + math_floor(math_max(0.0f, player_traversal_occupancy_bb.min.x - 1)), + math_floor(math_max(0.0f, player_traversal_occupancy_bb.min.y - 1)), }, .max = { - (i32)math_min(ROOM_TILE_DIM_X, player_traversal_occupancy_bb.max.x + 2), - (i32)math_min(ROOM_TILE_DIM_Y, player_traversal_occupancy_bb.max.y + 2), + math_floor(math_min(ROOM_TILE_DIM_X, player_traversal_occupancy_bb.max.x + 2)), + math_floor(math_min(ROOM_TILE_DIM_Y, player_traversal_occupancy_bb.max.y + 2)), }, };