commit c1a890e3923571dd5f7891ce3fc639d32b62d363
parent add0db961b682ac7a0e310c7169a71a1a112e2c4
Author: Amin Mesbah <dev@aminmesbah.com>
Date: Sat, 20 Apr 2019 17:04:32 -0700
Increase accuracy by absurdly increasing steps
Diffstat:
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},