-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.gd
148 lines (124 loc) · 3.3 KB
/
Main.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
extends Node2D
export var gravityAcc := 30.0
onready var textLeft = 'res://textLeft.txt'
onready var textRight = 'res://textRight.txt'
var Word_scene = preload("res://Word.tscn")
var WallLetter_scene = preload("res://LetterWall.tscn")
var Player1 = preload("res://Player1.tscn")
var Player2 = preload("res://Player2.tscn")
var words = []
var linesLeft = []
var linesRight = []
var totalTime = 0
var started = false
func _ready():
linesLeft = load_lines(textLeft)
linesRight = load_lines(textRight)
randomize()
func start():
$HUD/Title2.hide()
$StartTimer.start()
$DramaTimer.start()
var p1 = Player1.instance()
var p2 = Player2.instance()
p1.hide()
p2.hide()
add_child(p1)
add_child(p2)
$Player1.ugh()
#$Player2.ugh()
func load_words(file):
var f = File.new()
var toReturn = []
f.open(file, File.READ)
while not f.eof_reached(): # iterate through all lines until the end of file is reached
var line = f.get_line()
toReturn.append_array(line.split(" "))
f.close()
return toReturn
func load_lines(file):
var f = File.new()
var toReturn = []
f.open(file, File.READ)
while not f.eof_reached(): # iterate through all lines until the end of file is reached
var line = f.get_line()
toReturn.append(line)
f.close()
return toReturn
#func _process(delta):
# pass
func _on_LetterScrollTimer_timeout():
# add new line of text
var xmargin = 100
var textL = linesLeft.pop_front()
if textL == null:
$LetterScrollTimer.stop()
return 0
for i in range(len(textL)):
var letter = textL[i]
if letter == " ": continue
var l = WallLetter_scene.instance()
l.theLetter = letter
l.position = Vector2(i*l.fontWidth + xmargin, get_viewport().size.y)
get_parent().add_child(l)
var textR = linesRight.pop_front()
if textR == null:
$LetterScrollTimer.stop()
return 0
for i in range(len(textR)):
var letter = textR[len(textR)-1-i]
if letter == " ": continue
var r = WallLetter_scene.instance()
r.theLetter = letter
r.position = Vector2(get_viewport().size.x - i*r.fontWidth-xmargin, get_viewport().size.y)
get_parent().add_child(r)
func _process(delta):
print(get_parent().get_child_count())
if Input.is_action_just_pressed("esc"):
if $HUD/VideoPlayer.is_playing():
$HUD/VideoPlayer.stop()
$HUD/VideoPlayer.hide()
$HUD/VideoPlayer.emit_signal("finished")
else:
get_tree().quit()
totalTime += delta/50
if levelOfDrama == 3:
$HUD/ProgressBar1.value += delta*100
$HUD/ProgressBar2.value += delta*100
func _on_StartTimer_timeout():
if not started:
$HUD/Title1.hide()
$HUD/Title2.show()
$StartTimer.start()
started = true
else:
$HUD/Title2.hide()
$LetterScrollTimer.start()
var levelOfDrama = 0
func _on_DramaTimer_timeout():
if levelOfDrama == 0:
$HUD/BottomRect.show()
else: if levelOfDrama == 1:
$HUD/ReadyLetter1.show()
$Player1.show()
$HUD/ReadyLetter2.show()
$Player2.show()
$HUD/Controls1.show()
$HUD/Controls2.show()
else: if levelOfDrama == 2:
$DramaTimer.stop()
$DramaTimer.wait_time = 1.3
$DramaTimer.start()
$HUD/ProgressBar1.show()
$HUD/ProgressBar2.show()
else: if levelOfDrama == 3:
$HUD/LivesCounter1.show()
$HUD/LivesCounter2.show()
$HUD/Controls1.hide()
$HUD/Controls2.hide()
$DramaTimer.stop()
levelOfDrama += 1
func _on_VideoPlayer_finished():
$HUD/VideoPlayer.hide()
$HUD/AudioStreamPlayer.play(39.626)
start()