commit 9384ef0ecc5332bd44c2d8c64f63e6905d463114
parent 5cc25f9446efa0f359a40402f45ce1ba32b5adac
Author: amin <dev@aminmesbah.com>
Date: Thu, 25 Apr 2019 00:36:35 +0000
Clean up debugging stuff
FossilOrigin-Name: 3d72f08167d6a6f3667cec43bdd00fbb5a32a7cadf346f2cab96d7b6ae384924
Diffstat:
D | .gdbinit | | | 28 | ---------------------------- |
M | src/game.c | | | 49 | +++++++------------------------------------------ |
2 files changed, 7 insertions(+), 70 deletions(-)
diff --git a/.gdbinit b/.gdbinit
@@ -1,28 +0,0 @@
-break game.c:458 if tile_b.min.y > 7 && new_p.y > tile_b.min.y && new_p.x < tile_b.max.x && new_p.x > tile_b.min.x
-commands
-print player->pos
-print new_p
-print tile_b.min
-cont
-end
-
-break game.c:128 if wall.min.y > 7 && entity_p_final.y > wall.min.y && entity_p_final.x < wall.max.x && entity_p_final.x > wall.min.x
-commands
-print player_delta
-cont
-end
-
-break game.c:533
-commands
-print player->pos
-cont
-end
-
-break game.c:562
-commands
-print player_aabb.max
-print tile_aabb.min
-print dt
-end
-
-r
diff --git a/src/game.c b/src/game.c
@@ -2,8 +2,6 @@
#include "glad.c"
#include "shader.c"
-#define FIX_TUNNELING_BUG
-
#ifdef PLATFORM_HOTLOAD_GAME_CODE
void game_load_opengl_symbols(void)
{
@@ -16,7 +14,7 @@ internal void game_init(struct GameMemory *game_memory, v2u framebuffer)
struct GameState *game_state = game_memory->game_state;
// init player
- game_state->player.pos = (v2) {12.5f, 7.70844983f};//game_state->player.pos = (v2) {12.5f, 5.0f};
+ game_state->player.pos = (v2) {12.5f, 5.0f};
// In Knytt, the player is 9 by 14 texels and a tile is 24 by 24 texels.
// These dimensions are relative to a square 'meter', one tile
@@ -117,12 +115,12 @@ internal struct WallCollision get_wall_collision(v2 entity_p_initial, v2 entity_
if (collision_point.E[wall_axis] >= wall.min.E[wall_axis]
&& collision_point.E[wall_axis] <= wall.max.E[wall_axis])
{
- result.collision_occurred = true;
-#ifdef FIX_TUNNELING_BUG
- result.distance_scale_factor = glmth_max(0.0f, segment_scale_factor);
-#else
- result.distance_scale_factor = glmth_max(0.0f, segment_scale_factor - 0.0001f);
-#endif
+ if (collision_point.E[wall_axis] >= wall.min.E[wall_axis]
+ && collision_point.E[wall_axis] <= wall.max.E[wall_axis])
+ {
+ result.collision_occurred = true;
+ result.distance_scale_factor = glmth_max(0.0f, segment_scale_factor);
+ }
}
}
}
@@ -299,9 +297,6 @@ void game_update_and_render(struct GameMemory *game_memory, struct GameInput *ga
dt = 1.0f / 60.0f;
}
- // TODO: remove this absurdly small test dt
- dt = 0.00068f;
-
f32 max_meters_per_second = 5.0f;
f32 acceleration_rate = 50.0f;
f32 friction = 0.7f;
@@ -334,9 +329,6 @@ void game_update_and_render(struct GameMemory *game_memory, struct GameInput *ga
player->velocity.x = player->velocity.x * friction;
}
- // TODO: remove this constant acceleration which is just for debugging
- player->acceleration = (v2) {0.0f, 50.0f};
-
// Semi implicit Euler integration: https://gafferongames.com/post/integration_basics/
player->velocity = glmth_v2_a(player->velocity, glmth_v2f_m(player->acceleration, dt));
glmth_clamp(&player->velocity.x, -max_meters_per_second, max_meters_per_second);
@@ -427,7 +419,6 @@ void game_update_and_render(struct GameMemory *game_memory, struct GameInput *ga
{
assert(tile_x < ROOM_TILE_DIM_X);
assert(tile_y < ROOM_TILE_DIM_Y);
-
v2u tile_index = {tile_x, ROOM_TILE_DIM_Y - tile_y - 1};
u32 tile_id = tiles[tile_index.y][tile_index.x];
@@ -439,12 +430,10 @@ void game_update_and_render(struct GameMemory *game_memory, struct GameInput *ga
};
rect tile_player_sum = glmth_minkowski_sum_rect_rect(tile_aabb, player->dimensions);
-#ifdef FIX_TUNNELING_BUG
f32 collision_border_epsilon = 0.0001f;
tile_player_sum = glmth_minkowski_sum_rect_rect(
tile_player_sum,
(v2) {collision_border_epsilon, collision_border_epsilon});
-#endif
RENDER_COLLISION_DEBUG_QUAD(tile_player_sum, ((v3) {0.8f, 0.4f, 0.4f}));
v2 tile_nw = {tile_player_sum.min.x, tile_player_sum.max.y};
@@ -540,30 +529,6 @@ void game_update_and_render(struct GameMemory *game_memory, struct GameInput *ga
remaining_time_factor -= smallest_distance_scale_factor;
}
-
- {
- v2 tile_pos = {12.0f, 8.0f};
- f32 half_w = 0.5f * player->dimensions.width;
- f32 half_h = 0.5f * player->dimensions.height;
- rect player_aabb = {
- .min = {player->pos.x - half_w, player->pos.y - half_h},
- .max = {player->pos.x + half_w, player->pos.y + half_h},
- };
- rect tile_aabb = {
- .min = tile_pos,
- .max = {tile_pos.x + tile_size, tile_pos.y + tile_size},
- };
- bool player_is_in_tile = glmth_intersect_aabb_aabb(player_aabb, tile_aabb);
- if (player_is_in_tile)
- {
- printf("!!!!!!!!!!!!!!!!\n");
- printf("player aabb: ");
- glmth_print(player_aabb);
- printf("tile aabb: ");
- glmth_print(tile_aabb);
- printf("!!!!!!!!!!!!!!!!\n");
- }
- }
}
#undef RENDER_COLLISION_DEBUG_QUAD
#endif