]> Untitled Git - mushroom-game.git/blob - world.gd
Squashed commit of the following:
[mushroom-game.git] / world.gd
1 extends Node3D
2
3 signal victory
4 signal quit
5
6
7 # Called when the node enters the scene tree for the first time.
8 func _ready() -> void:
9         pass # Replace with function body.
10
11
12 # Called every frame. 'delta' is the elapsed time since the previous frame.
13 func _process(_delta: float) -> void:
14         pass
15
16
17 # Quit the game on user action
18 func _unhandled_input(event: InputEvent) -> void:
19         if event.is_action_pressed("quit-game"):
20                 quit.emit()
21
22
23 # if all mushrooms have been picked,
24 # then game is over
25 func _on_mushroom_picked() -> void:
26         print("Player picked a mushroom!")
27         
28         for mushroom in $mushrooms.get_children():
29                 if mushroom.is_picked == false:
30                         return
31                         
32         print("Player picked all mushrooms, game over")
33         victory.emit()
34
35
36 func _on_victory() -> void:
37         get_tree().change_scene_to_file("res://victory-screen.tscn")
38
39
40 func _on_quit() -> void:
41         get_tree().quit()