-
Notifications
You must be signed in to change notification settings - Fork 14
/
GodotCredits.gd
122 lines (103 loc) · 2.42 KB
/
GodotCredits.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
extends Node2D
const section_time := 2.0
const line_time := 0.3
const base_speed := 100
const speed_up_multiplier := 10.0
const title_color := Color.blueviolet
var scroll_speed := base_speed
var speed_up := false
onready var line := $CreditsContainer/Line
var started := false
var finished := false
var section
var section_next := true
var section_timer := 0.0
var line_timer := 0.0
var curr_line := 0
var lines := []
var credits = [
[
"A game by Awesome Game Company"
],[
"Programming",
"Programmer Name",
"Programmer Name 2"
],[
"Art",
"Artist Name"
],[
"Music",
"Musician Name"
],[
"Sound Effects",
"SFX Name"
],[
"Testers",
"Name 1",
"Name 2",
"Name 3"
],[
"Tools used",
"Developed with Godot Engine",
"https://godotengine.org/license",
"",
"Art created with My Favourite Art Program",
"https://myfavouriteartprogram.com"
],[
"Special thanks",
"My parents",
"My friends",
"My pet rabbit"
]
]
func _process(delta):
var scroll_speed = base_speed * delta
if section_next:
section_timer += delta * speed_up_multiplier if speed_up else delta
if section_timer >= section_time:
section_timer -= section_time
if credits.size() > 0:
started = true
section = credits.pop_front()
curr_line = 0
add_line()
else:
line_timer += delta * speed_up_multiplier if speed_up else delta
if line_timer >= line_time:
line_timer -= line_time
add_line()
if speed_up:
scroll_speed *= speed_up_multiplier
if lines.size() > 0:
for l in lines:
l.rect_position.y -= scroll_speed
if l.rect_position.y < -l.get_line_height():
lines.erase(l)
l.queue_free()
elif started:
finish()
func finish():
if not finished:
finished = true
# NOTE: This is called when the credits finish
# - Hook up your code to return to the relevant scene here, eg...
#get_tree().change_scene("res://scenes/MainMenu.tscn")
func add_line():
var new_line = line.duplicate()
new_line.text = section.pop_front()
lines.append(new_line)
if curr_line == 0:
new_line.add_color_override("font_color", title_color)
$CreditsContainer.add_child(new_line)
if section.size() > 0:
curr_line += 1
section_next = false
else:
section_next = true
func _unhandled_input(event):
if event.is_action_pressed("ui_cancel"):
finish()
if event.is_action_pressed("ui_down") and !event.is_echo():
speed_up = true
if event.is_action_released("ui_down") and !event.is_echo():
speed_up = false