-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbase.gd
41 lines (30 loc) · 907 Bytes
/
base.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
38
39
40
41
extends Node2D
@onready var camera = $"Camera2D"
@onready var player = $"Snail"
@onready var spawner = $"Spawner"
@onready var ui = $CanvasLayer/InGameUI
@onready var pause_menu = $CanvasLayer/Pause
@onready var death_menu = $CanvasLayer/Death
@export var shift = 300
func _ready():
SignalBus.restart.connect(restart)
SignalBus.death.connect(on_death)
restart()
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta):
camera.position.x = player.position.x + shift
func restart():
death_menu.hide()
get_tree().paused = false
get_tree().call_group("pipe","queue_free")
player.position = Vector2(0,640)
player.reset()
camera.position = Vector2(shift,640)
spawner.position = Vector2(720,640)
spawner.spawn_pipes()
ui.reset()
func start_area_exited(_body):
SignalBus.dead = false
func on_death():
death_menu.show()
get_tree().paused = true