game over if y >= nb_lines

This commit is contained in:
adrienmalin 2019-01-08 14:22:15 +01:00
parent db1c211852
commit ed5924f407
3 changed files with 11 additions and 5 deletions

View File

@ -42,7 +42,10 @@ func possible_positions(initial_positions, movement):
func lock(piece): func lock(piece):
for position in piece.positions(): for position in piece.positions():
if position.y >= NB_LINES:
return false
set_cell_item(position.x, position.y, 0, MINO) set_cell_item(position.x, position.y, 0, MINO)
return true
func clear_lines(): func clear_lines():
var line_cleared var line_cleared

View File

@ -169,9 +169,11 @@ func _on_LockDelay_timeout():
lock() lock()
func lock(): func lock():
$GridMap.lock(current_piece) if $GridMap.lock(current_piece):
emit_signal("piece_locked", $GridMap.clear_lines(), current_piece.t_spin) emit_signal("piece_locked", $GridMap.clear_lines(), current_piece.t_spin)
new_piece() new_piece()
else:
game_over()
func hold(): func hold():
if not current_piece_held: if not current_piece_held:
@ -220,8 +222,9 @@ func pause(hide=true):
$Stats/Clock.stop() $Stats/Clock.stop()
func game_over(): func game_over():
$FlashText.print("GAME\nOVER")
pause(false) pause(false)
current_piece.emit_trail(false)
$FlashText.print("GAME\nOVER")
$ReplayButton.visible = true $ReplayButton.visible = true
func _on_ReplayButton_pressed(): func _on_ReplayButton_pressed():

View File

@ -229,7 +229,7 @@ extra_spacing_bottom = 5
font_data = ExtResource( 11 ) font_data = ExtResource( 11 )
_sections_unfolded = [ "Extra Spacing", "Font", "Settings" ] _sections_unfolded = [ "Extra Spacing", "Font", "Settings" ]
[node name="Main" type="WorldEnvironment"] [node name="Main" type="WorldEnvironment" index="0"]
environment = SubResource( 2 ) environment = SubResource( 2 )
script = ExtResource( 1 ) script = ExtResource( 1 )