game over if y >= nb_lines
This commit is contained in:
parent
db1c211852
commit
ed5924f407
@ -42,7 +42,10 @@ func possible_positions(initial_positions, movement):
|
||||
|
||||
func lock(piece):
|
||||
for position in piece.positions():
|
||||
if position.y >= NB_LINES:
|
||||
return false
|
||||
set_cell_item(position.x, position.y, 0, MINO)
|
||||
return true
|
||||
|
||||
func clear_lines():
|
||||
var line_cleared
|
||||
|
@ -169,9 +169,11 @@ func _on_LockDelay_timeout():
|
||||
lock()
|
||||
|
||||
func lock():
|
||||
$GridMap.lock(current_piece)
|
||||
emit_signal("piece_locked", $GridMap.clear_lines(), current_piece.t_spin)
|
||||
new_piece()
|
||||
if $GridMap.lock(current_piece):
|
||||
emit_signal("piece_locked", $GridMap.clear_lines(), current_piece.t_spin)
|
||||
new_piece()
|
||||
else:
|
||||
game_over()
|
||||
|
||||
func hold():
|
||||
if not current_piece_held:
|
||||
@ -220,8 +222,9 @@ func pause(hide=true):
|
||||
$Stats/Clock.stop()
|
||||
|
||||
func game_over():
|
||||
$FlashText.print("GAME\nOVER")
|
||||
pause(false)
|
||||
current_piece.emit_trail(false)
|
||||
$FlashText.print("GAME\nOVER")
|
||||
$ReplayButton.visible = true
|
||||
|
||||
func _on_ReplayButton_pressed():
|
||||
|
@ -229,7 +229,7 @@ extra_spacing_bottom = 5
|
||||
font_data = ExtResource( 11 )
|
||||
_sections_unfolded = [ "Extra Spacing", "Font", "Settings" ]
|
||||
|
||||
[node name="Main" type="WorldEnvironment"]
|
||||
[node name="Main" type="WorldEnvironment" index="0"]
|
||||
|
||||
environment = SubResource( 2 )
|
||||
script = ExtResource( 1 )
|
||||
|
Loading…
x
Reference in New Issue
Block a user