-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintro.js
executable file
·174 lines (142 loc) · 4.55 KB
/
intro.js
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
import { GAME_INTRO, GAME_PRE_MENU, GAME_MENU, GAME_INGAME, EN_US, PT_BR } from "modules/global_constants.js"
import { getText } from "lang/lang.js"
import * as color_utils from "modules/color_utils.js"
import * as text_utils from "modules/text_utils.js"
import * as fonts from "modules/fonts.js"
import * as sfx from "modules/sfx.js"
import * as music from "modules/music.js"
let ram = 0
class IntroBackground
{
w = 400
h = 198
x = 120
y = 60
last_img_h = 637.2
last_img_y = -380
opacity = 128
imgAvailable = [
new Image("images/intro/1.png", RAM),
new Image("images/intro/2.png", RAM),
new Image("images/intro/3.png", RAM),
new Image("images/intro/4.png", RAM),
new Image("images/intro/black.png", RAM),
new Image("images/intro/5.png", RAM),
new Image("images/intro/6.png", RAM),
new Image("images/intro/7.png", RAM),
new Image("images/intro/8.png", RAM),
new Image("images/intro/9.png", RAM),
new Image("images/intro/10.png", RAM)
]
imgSelected = 0
draw()
{
this.imgAvailable[this.imgSelected].color = Color.new(this.opacity, this.opacity, this.opacity, this.opacity)
this.imgAvailable[this.imgSelected].width = this.w
if (this.imgSelected == 10) {
this.imgAvailable[this.imgSelected].height = 637.2
this.imgAvailable[this.imgSelected].draw(this.x, this.last_img_y)
} else {
this.imgAvailable[this.imgSelected].height = this.h
this.imgAvailable[this.imgSelected].draw(this.x, this.y)
}
Draw.rect(0, 0, 640, 60, color_utils.black)
Draw.rect(0, 258, 640, 448 - this.h, color_utils.black)
}
}
let introBackground = new IntroBackground()
function nextFrameOn(time)
{
if (timerValue > time) {
introBackground.fadeOut = 1
if (introBackground.opacity == 0) {
introBackground.imgSelected ++
introBackground.fadeIn = 1
introBackground.fadeOut = 0
text_utils.resetText()
}
}
}
let timerValue = 0
let skip = 0
export function introScene(pad, timer)
{
pad.update()
timerValue = Timer.getTime(timer)
ram = System.getMemoryStats()
Screen.clear()
if ((pad.justPressed(Pads.CROSS) || pad.justPressed(Pads.START)) && skip == 0) {
introBackground.fadeOut = 1
skip = 1
text_utils.resetText()
Timer.reset(timer)
timerValue = Timer.getTime(timer)
}
introBackground.draw()
if (skip == 1) {
Sound.setVolume(introBackground.opacity / 128 * 100)
if (introBackground.opacity == 0) {
music.pause(music.playing)
}
if (timerValue > 1500) {
text_utils.resetText()
return GAME_PRE_MENU
}
}
if (introBackground.imgSelected == 0 && skip == 0) {
text_utils.dynamicDrawText(120, 300, 40, sfx.snd_txt2, fonts.dtm_mono, getText(0, "introText"))
nextFrameOn(6500)
} else if (introBackground.imgSelected == 1 && skip == 0) {
text_utils.dynamicDrawText(120, 300, 40, sfx.snd_txt2, fonts.dtm_mono, getText(1, "introText"))
nextFrameOn(12000)
} else if (introBackground.imgSelected == 2 && skip == 0) {
text_utils.dynamicDrawText(120, 300, 40, sfx.snd_txt2, fonts.dtm_mono, getText(2, "introText"))
nextFrameOn(18000)
} else if (introBackground.imgSelected == 3 && skip == 0) {
text_utils.dynamicDrawText(120, 300, 40, sfx.snd_txt2, fonts.dtm_mono, getText(3, "introText"))
nextFrameOn(25000)
} else if (introBackground.imgSelected == 4 && skip == 0) {
text_utils.dynamicDrawText(120, 300, 40, sfx.snd_txt2, fonts.dtm_mono, getText(4, "introText"))
nextFrameOn(29000)
} else if (introBackground.imgSelected == 5 && skip == 0) {
text_utils.dynamicDrawText(225, 300, 40, sfx.snd_txt2, fonts.dtm_mono, getText(5, "introText"))
nextFrameOn(35000)
} else if (introBackground.imgSelected == 6 && skip == 0) {
text_utils.dynamicDrawText(120, 300, 40, sfx.snd_txt2, fonts.dtm_mono, getText(6, "introText"))
nextFrameOn(42000)
} else if (introBackground.imgSelected == 7 && skip == 0) {
nextFrameOn(46000)
} else if (introBackground.imgSelected == 8 && skip == 0) {
nextFrameOn(50000)
} else if (introBackground.imgSelected == 9 && skip == 0) {
nextFrameOn(54000)
} else if (introBackground.imgSelected == 10 && skip == 0) {
if (timerValue > 60000) {
if (introBackground.last_img_y <= 36) {
introBackground.last_img_y += 0.6
}
}
if (timerValue > 74750) {
introBackground.fadeOut = 1
music.pause(music.playing)
if (introBackground.opacity == 0) {
text_utils.resetText()
return GAME_PRE_MENU
}
}
}
color_utils.fadeIn(introBackground)
color_utils.fadeOut(introBackground)
fonts.dtm_mono.print(0, 0, timerValue)
Screen.flip()
}
export function intro_gc()
{
introScene = null
nextFrameOn = null
introBackground = null
timerValue = null
skip = null
ram = null
std.gc()
}