fix enemy aligning, add sticks respawn
This commit is contained in:
+24
-4
@@ -108,11 +108,31 @@ func _spawn_rocks() -> void:
|
||||
for i in range(limit):
|
||||
_spawn_single_rock()
|
||||
|
||||
var sticks_on_field: int = 0
|
||||
var sticks_pending: int = 0
|
||||
const STICK_LIMIT := 2
|
||||
|
||||
func _spawn_sticks() -> void:
|
||||
for i in range(2):
|
||||
var stick := STICK_SCENE.instantiate()
|
||||
stick.position = _safe_item_position()
|
||||
add_child(stick)
|
||||
for i in range(STICK_LIMIT):
|
||||
_spawn_single_stick()
|
||||
|
||||
func _spawn_single_stick() -> void:
|
||||
var stick := STICK_SCENE.instantiate()
|
||||
stick.position = _safe_item_position()
|
||||
add_child(stick)
|
||||
stick.connect("destroyed", _on_stick_destroyed)
|
||||
sticks_on_field += 1
|
||||
|
||||
func _on_stick_destroyed() -> void:
|
||||
sticks_on_field = maxi(0, sticks_on_field - 1)
|
||||
if not game_active:
|
||||
return
|
||||
if sticks_on_field + sticks_pending < STICK_LIMIT:
|
||||
sticks_pending += 1
|
||||
await get_tree().create_timer(20.0).timeout
|
||||
sticks_pending -= 1
|
||||
if game_active:
|
||||
_spawn_single_stick()
|
||||
|
||||
func _spawn_single_rock() -> void:
|
||||
var rock := ROCK_SCENE.instantiate()
|
||||
|
||||
Reference in New Issue
Block a user