a-game

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

commit 907a6cf49cc23e2e9a34e1efd9e820bfab90d9a1
parent b27f37b973503385c93e0ce37cf021d95dc0d46d
Author: amin <dev@aminmesbah.com>
Date:   Sun, 21 Apr 2019 00:04:32 +0000

Increase accuracy by absurdly increasing steps

FossilOrigin-Name: e986cb69b2d5a61b7fb693f381d0f9d9b715b578c971fd284b70a62fe1748e73
Diffstat:
Msrc/game.c | 10+++++++---
1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/game.c b/src/game.c @@ -151,7 +151,9 @@ void game_update_and_render(struct GameMemory *game_memory, struct GameInput *ga struct Entity *player = &game_state->player; f32 dt = game_input->dt; f32 max_meters_per_second = 5.0f; - f32 acceleration_rate = 50.0f; + // TODO: restore acceleration rate + //f32 acceleration_rate = 50.0f; + f32 acceleration_rate = 10.0f; // TODO: restore friction //f32 friction = 0.7f; f32 friction = 1.0f; @@ -246,10 +248,12 @@ void game_update_and_render(struct GameMemory *game_memory, struct GameInput *ga { v2 player_direction = glmth_v2_normalize(player->velocity); - i32 max_cast = glmth_round(glmth_v2_length((v2) {ROOM_TILE_DIM_X, ROOM_TILE_DIM_Y})); + f32 step_size = 0.001f; + i32 max_cast = (f32)(1.0f / step_size) * glmth_round(glmth_v2_length((v2) {ROOM_TILE_DIM_X, ROOM_TILE_DIM_Y})); + printf("max_cast: %d\n", max_cast); for (i32 i = 0; i < max_cast; i++) { - v2 cast_pos = glmth_v2_a(player->pos, glmth_v2f_m(player_direction, i)); + v2 cast_pos = glmth_v2_a(player->pos, glmth_v2f_m(player_direction, i * step_size)); rect cast_aabb = { .min = {cast_pos.x - half_w, cast_pos.y - half_h}, .max = {cast_pos.x + half_w, cast_pos.y + half_h},