Browse Source

Prevent buggy rotations

main
karl 2 years ago
parent
commit
2dacf54608
  1. 11
      GameBoard.gd

11
GameBoard.gd

@ -67,7 +67,9 @@ func get_random_shape():
func update_board():
if player_lost():
# The player lost if the active shape is within another shape, since that means that they're
# piling up on top
if is_shape_stuck():
game_over()
if can_active_move_down():
@ -100,8 +102,7 @@ func can_active_move_right():
return _can_active_move_towards(Vector2(RASTER_SIZE, 0.0))
func player_lost():
# The player lost if the active shape is within another shape, so it "cannot move towards itself"
func is_shape_stuck():
return not _can_active_move_towards(Vector2.ZERO)
@ -188,6 +189,10 @@ func move_right():
func rotate_shape():
active_shape.rotation_degrees += 90
# Revert the rotation if that would cause it to be stuck inside another
if is_shape_stuck():
active_shape.rotation_degrees -= 90
func drop():

Loading…
Cancel
Save