-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.gd
37 lines (27 loc) · 1.04 KB
/
main.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
extends Node
@export var mob_scene: PackedScene
# Called when the node enters the scene tree for the first time.
func _ready():
$UserInterface/Retry.hide()
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass
func _on_mob_timer_timeout():
# Create a new instance of the Mob scene.
var mob = mob_scene.instantiate()
# Choose a random location on the SpawnPath
# We store a reference to the SpawnLocation node
var mob_spawn_location = get_node("SpawnPath/SpawnLocation")
# And give it a random offset
mob_spawn_location.progress_ratio = randf()
var player_position = $Player.position
mob.initialize(mob_spawn_location.position, player_position)
mob.squashed.connect($UserInterface/ScoreLabel._on_mob_squashed.bind())
add_child(mob)
func _on_player_hit():
$MobTimer.stop()
$UserInterface/Retry.show()
func _unhandled_input(event):
if event.is_action_pressed("ui_accept") and $UserInterface/Retry.visible:
# This restarts the current scene
get_tree().reload_current_scene()