-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSorting.gd
More file actions
74 lines (63 loc) · 1.79 KB
/
Copy pathSorting.gd
File metadata and controls
74 lines (63 loc) · 1.79 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
extends Control
var correct_sorting = {
"StyrofoamCup" : "Trash",
"Pizzabox" : "Trash",
"Fork" : "Trash",
"BananaPeel" : "Compost",
"WaterBottle" : "Recycle",
"CrumpledPaper" : "Recycle"
}
var item_order = [ "Pizzabox","BananaPeel", "WaterBottle", "StyrofoamCup", "CrumpledPaper", "Fork"]
var item_num = 0
func _ready():
get_node("StyrofoamCup").visible = false
get_node("Pizzabox").visible = false
get_node("Fork").visible = false
get_node("BananaPeel").visible = false
get_node("WaterBottle").visible = false
get_node("CrumpledPaper").visible = false
get_node("TryAgain").visible = false
func reset_items():
get_node("StyrofoamCup").visible = false
get_node("Pizzabox").visible = false
get_node("Fork").visible = false
get_node("BananaPeel").visible = false
get_node("WaterBottle").visible = false
get_node("CrumpledPaper").visible = false
get_node("TryAgain").visible = false
get_node("Correct").visible = false
func show_try_again():
get_node("TryAgain").visible = true
func show_correct():
get_node("Correct").visible = true
func off_correct():
get_node("Correct").visible = false
func _process(delta):
if item_num >= 6:
get_tree().change_scene("res://Credit.tscn")
else:
get_node(item_order[item_num]).visible = true
func _on_Recycle_pressed():
if correct_sorting[item_order[item_num]] == get_node("Recycle").name:
item_num += 1
reset_items()
show_correct()
else:
off_correct()
show_try_again()
func _on_Trash_pressed():
if correct_sorting[item_order[item_num]] == get_node("Trash").name:
item_num += 1
reset_items()
show_correct()
else:
off_correct()
show_try_again()
func _on_Compost_pressed():
if correct_sorting[item_order[item_num]] == get_node("Compost").name:
item_num += 1
reset_items()
show_correct()
else:
off_correct()
show_try_again()