forked from FractalDiane/GGJ2019
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayButton.gd
151 lines (115 loc) · 4.18 KB
/
playButton.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
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
extends Sprite
# # class member variables go here, for example:
# # var a = 2
# # var b = "textvar"
# var speed = 5
# var moving_up = false
# func _ready():
# # Called when the node is added to the scene for the first time.
# # Initialization here
# pass
# func _process(delta):
# check_moving()
# if moving_up == false:
# translate(Vector2(0, speed*delta))
# elif moving_up == true:
# translate(Vector2(0, -speed*delta))
# func check_moving():
# if position.y >= 186 and position.y <= 187:
# moving_up = false
# elif position.y >= 195 and position.y <= 196:
# moving_up = true
var over_start = false
var over_credits = false
var credits_open = false
var fade = false
var can_click = false
var buffer = false
onready var overlay = get_tree().get_root().get_node("TitleScreen").get_node("Overlay")
onready var credits = get_tree().get_root().get_node("TitleScreen").get_node("Credits")
func _ready():
overlay.show()
$AnimationPlayer.play("idle")
func _process(delta):
if fade:
overlay.modulate.a = max(overlay.modulate.a - 0.25 * delta, 0)
else:
overlay.modulate.a = min(overlay.modulate.a + 0.75 * delta, 1)
if can_click and not credits_open:
# if over_start:
# if Input.is_action_just_pressed("ui_click"):
# start()
# if over_credits and not credits_open:
# if Input.is_action_just_pressed("ui_click") and not buffer:
# credits()
if Input.is_action_just_pressed("credits_gamepad") and not credits_open:
credits()
if Input.is_action_just_pressed("ui_gamepad_click") and not credits_open:
start()
if Input.is_action_just_pressed("ui_cancel") and not credits_open:
get_tree().quit()
if credits_open and not buffer:
if Input.is_action_just_pressed("ui_click") or Input.is_action_just_pressed("ui_gamepad_click"):
$SoundClick.play()
get_tree().get_root().get_node("TitleScreen").get_node("Credits").hide()
credits_open = false
func _input(event: InputEvent) -> void:
if event is InputEventMouseButton and event.button_index == BUTTON_LEFT and event.is_pressed():
if over_start:
start()
if over_credits and not credits_open and not buffer:
credits()
func start():
#$SoundClick.play()
$SoundClick.play()
$Music/AnimMusicFade.play("fadeout")
modulate = Color(1, 1, 1)
$SoundGust.play()
get_tree().get_root().get_node("TitleScreen").get_node("PartsWind").set_emitting(false)
#fade = false
can_click = false
get_tree().get_root().get_node("TitleScreen").get_node("TimerWind2").start()
#Controller.change_scene("res://Scenes/Level1.tscn")
get_tree().get_root().get_node("TitleScreen").get_node("TimerStartGame").start()
func credits():
$SoundClick.play()
#Controller.change_scene("res://Scenes/Credits.tscn")
credits.show()
credits_open = true
buffer = true
get_tree().get_root().get_node("TitleScreen").get_node("TimerBuffer").start()
func _on_ClickArea_mouse_entered():
if can_click:
modulate = Color(1, .75, .75)
over_start = true
func _on_ClickArea_mouse_exited():
if can_click:
modulate = Color(1, 1, 1)
over_start = false
func _on_ClickAreaCredits_mouse_entered():
if can_click:
get_tree().get_root().get_node("TitleScreen").get_node("creditsButton").modulate = Color(1, .75, .75)
over_credits = true
func _on_ClickAreaCredits_mouse_exited():
if can_click:
get_tree().get_root().get_node("TitleScreen").get_node("creditsButton").modulate = Color(1, 1, 1)
over_credits = false
func _on_TimerFade_timeout():
$SoundGust.play()
get_tree().get_root().get_node("TitleScreen").get_node("PartsWind").set_emitting(true)
get_tree().get_root().get_node("TitleScreen").get_node("TimerMusic").start()
get_tree().get_root().get_node("TitleScreen").get_node("TimerEndWind").start()
func _on_TimerMusic_timeout():
$Music.play()
fade = true
func _on_TimerEndWind_timeout():
can_click = true
#get_tree().get_root().get_node("TitleScreen").get_node("PartsWind").set_emitting(false)
#get_tree().get_root().get_node("TitleScreen").get_node("PartsWind").get_node("PartsWind2").set_emitting(true)
func _on_TimerWind2_timeout():
fade = false
func _on_TimerStartGame_timeout():
#Controller.change_scene("res://Scenes/Level1.tscn")
Controller.change_scene("res://Scenes/Cutscenes/IntroCutScene.tscn")
func _on_TimerBuffer_timeout():
buffer = false