Allow player to be pushed off moving blocks

This commit is contained in:
James Campbell
2026-07-25 13:13:48 -04:00
parent 3ad36d2911
commit 8e077ff09d
6 changed files with 75 additions and 13 deletions

View File

@@ -113,6 +113,46 @@ traps:
assert g.player.rect.x < start_x # got shoved along
def test_ride_into_wall_stops_no_crush(make_game):
# Riding a horizontally-moving platform into a stationary wall must NOT
# crush the player: they stop at the wall while the block slides underneath.
# The wall sits one row *above* the platform's track (col 8, row 2), so it
# catches the player's body while the platform passes below it.
g = make_game("""
name: t
tile_size: 32
map: |
###########
#.........#
#.......#.#
#.........#
#........G#
###########
traps:
- type: block
at: [1, 3]
move: [8, 0]
speed: 200
trigger: always
""")
# stand the player on top of the platform at its left end (body in row 2)
place(g, 1, 2)
g.player.fy = float(3 * 32 - g.player.h) # feet on the block's top
g.player._sync_rect()
wall_left = 8 * 32
hit_wall = False
for _ in range(180):
step(g)
if g.state != "playing":
break
assert not g.player.crushed # never crushed
assert g.player.rect.right <= wall_left + 1 # stopped at the wall
if g.player.rect.right >= wall_left - 1:
hit_wall = True
assert g.state == "playing" # survived the whole time
assert hit_wall # actually reached the wall
def test_corner_clip_does_not_warp(make_game):
# Walking into a moving block near its corner must not fling the player
# across it (the old velocity-sign resolver bug).