Format code with black
This commit is contained in:
@@ -18,10 +18,10 @@ map: |
|
||||
|
||||
def test_falls_and_lands_on_floor(make_game):
|
||||
g = make_game(FLAT)
|
||||
place(g, 4, 1) # up in the air
|
||||
place(g, 4, 1) # up in the air
|
||||
run(g, 60)
|
||||
assert g.player.on_ground
|
||||
assert g.player.rect.bottom == 5 * 32 # floor is row 5's top (y=160)
|
||||
assert g.player.rect.bottom == 5 * 32 # floor is row 5's top (y=160)
|
||||
|
||||
|
||||
def test_terminal_velocity(make_game):
|
||||
@@ -34,13 +34,13 @@ def test_terminal_velocity(make_game):
|
||||
|
||||
def test_jump_gains_height_then_returns(make_game):
|
||||
g = make_game(FLAT)
|
||||
run(g, 30) # settle on floor
|
||||
run(g, 30) # settle on floor
|
||||
ground = g.player.rect.bottom
|
||||
peak = ground
|
||||
for i in range(60):
|
||||
step(g, hold(jump_pressed=(i == 0), jump_held=True))
|
||||
peak = min(peak, g.player.rect.bottom)
|
||||
assert peak < ground - 32 # rose at least a tile
|
||||
assert peak < ground - 32 # rose at least a tile
|
||||
|
||||
|
||||
def test_variable_jump_height(make_game):
|
||||
@@ -55,6 +55,7 @@ def test_variable_jump_height(make_game):
|
||||
step(g, hold(jump_pressed=(i == 0), jump_held=held))
|
||||
hi = min(hi, g.player.rect.bottom)
|
||||
return ground - hi
|
||||
|
||||
assert peak(60) > peak(1) + 8
|
||||
|
||||
|
||||
@@ -71,22 +72,22 @@ map: |
|
||||
#P#...#
|
||||
#######
|
||||
""")
|
||||
place(g, 1, 3) # standing on the little step at [1,3] top
|
||||
place(g, 1, 3) # standing on the little step at [1,3] top
|
||||
# walk right off the step for a couple frames, then jump
|
||||
run(g, 4, lambda i: hold(right=True))
|
||||
y_before = g.player.rect.bottom
|
||||
step(g, hold(right=True, jump_pressed=True, jump_held=True))
|
||||
step(g, hold(right=True, jump_held=True))
|
||||
assert g.player.vy < 0 # a jump actually started
|
||||
assert g.player.vy < 0 # a jump actually started
|
||||
|
||||
|
||||
def test_walls_stop_horizontal_movement(make_game):
|
||||
g = make_game(FLAT)
|
||||
place(g, 1, 4)
|
||||
run(g, 120, lambda i: hold(right=True))
|
||||
assert g.player.rect.right <= 9 * 32 # right wall inner edge (x=288)
|
||||
assert g.player.rect.right <= 9 * 32 # right wall inner edge (x=288)
|
||||
run(g, 120, lambda i: hold(left=True))
|
||||
assert g.player.rect.left >= 1 * 32 # left wall inner edge (x=32)
|
||||
assert g.player.rect.left >= 1 * 32 # left wall inner edge (x=32)
|
||||
|
||||
|
||||
def test_oneway_platform_land_from_above_pass_from_below(make_game):
|
||||
@@ -103,7 +104,7 @@ map: |
|
||||
#######
|
||||
""")
|
||||
# Fall onto the one-way from above -> lands on it.
|
||||
place(g, 1, 1) # open air above the one-way (row 3)
|
||||
place(g, 1, 1) # open air above the one-way (row 3)
|
||||
run(g, 60)
|
||||
assert g.player.on_ground and g.player.rect.bottom == 3 * 32
|
||||
|
||||
@@ -119,12 +120,12 @@ map: |
|
||||
#P...G#
|
||||
#######
|
||||
""")
|
||||
place(g2, 1, 4) # on the floor, below the one-way (row 2)
|
||||
run(g2, 5) # settle so on_ground is set before jumping
|
||||
place(g2, 1, 4) # on the floor, below the one-way (row 2)
|
||||
run(g2, 5) # settle so on_ground is set before jumping
|
||||
passed = False
|
||||
for i in range(40):
|
||||
step(g2, hold(jump_pressed=(i == 0), jump_held=(i < 12)))
|
||||
if g2.player.rect.top < 2 * 32: # rose above the one-way row
|
||||
if g2.player.rect.top < 2 * 32: # rose above the one-way row
|
||||
passed = True
|
||||
assert passed
|
||||
|
||||
@@ -142,10 +143,10 @@ map: |
|
||||
#....G#
|
||||
#######
|
||||
""")
|
||||
place(g, 1, 2) # standing on the one-way at row 3
|
||||
place(g, 1, 2) # standing on the one-way at row 3
|
||||
run(g, 20)
|
||||
assert g.player.on_ground
|
||||
# press down + jump to drop through
|
||||
for i in range(30):
|
||||
step(g, hold(down=True, jump_pressed=(i == 0)))
|
||||
assert g.player.rect.top > 3 * 32 # fell below the one-way
|
||||
assert g.player.rect.top > 3 * 32 # fell below the one-way
|
||||
|
||||
Reference in New Issue
Block a user