Move_to_contact: handle allowed overlap correctly

This commit is contained in:
Pyrex 2024-02-28 12:03:23 -08:00
parent c5c677320b
commit 84b7a09383
2 changed files with 5 additions and 4 deletions

View File

@ -88,8 +88,9 @@ game_collision game_collision_move_to_contact(
// figure out what tile we're still in
sys_i32 tile_x0 = round_down(body_x0, TILE_SZ_MICROPIXEL);
sys_i32 tile_y0 = round_down(body_y0, TILE_SZ_MICROPIXEL);
sys_i32 tile_x1 = round_up(body_x1, TILE_SZ_MICROPIXEL);
sys_i32 tile_y1 = round_up(body_y1, TILE_SZ_MICROPIXEL);
sys_i32 max_overlap = PIXEL_SZ_MICROPIXEL - 1;
sys_i32 tile_x1 = round_up(body_x1 - max_overlap, TILE_SZ_MICROPIXEL) + max_overlap;
sys_i32 tile_y1 = round_up(body_y1 - max_overlap, TILE_SZ_MICROPIXEL) + max_overlap;
// but we want the _next_ tile
if (tile_x0 == body_x0) { tile_x0 -= TILE_SZ_MICROPIXEL; }

View File

@ -48,7 +48,7 @@ void game_player_update() {
if (collision.collided_y) { game_player_dy = 0; }
game_player_grounded = !game_collision_can_move(
game_player_bbox, 0, PIXEL_SZ_MICROPIXEL
game_player_bbox, 0, 1
);
{