-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSmallQuest.sb
589 lines (545 loc) · 16.4 KB
/
SmallQuest.sb
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
'Small Quest
'Version 0.8.02a
'Copyright © 2015 Filipe Cardoso Martins and Nonki Takahashi. The MIT License.
'Program ID HDL692-8
'Last update 2015-08-12
'Inicialize constantes. / Initialize constants.
Not = "False=True;True=False;"
CRLF = Text.GetCharacter(13) + Text.GetCharacter(10)
'Definições de idioma. / Language settings.
scene = ""
lang = "en-US"
Language_GetTextFromDAT()
'Configurações da janela do jogo. / The game window settings.
GraphicsWindow.Hide()
GraphicsWindow.Show()
gwTitle = "Small Quest 0.8.02a"
GraphicsWindow.Title = gwTitle
GraphicsWindow.Height = "550"
GraphicsWindow.Width = "800"
GraphicsWindow.FontName = "Trebuchet MS"
GameMenu_Form()
GraphicsWindow.MouseMove = OnMouseMove
GraphicsWindow.MouseDown = OnMouseDown
GameMenu_Select()
Program.End()
Sub Game_New
GraphicsWindow.Clear()
Loading_Form()
GraphicsWindow.Clear()
Game_Frame()
Game_Characters()
Game_Actions()
Game_LoadNextScene()
Game_Loop()
EndSub
Sub Loading_Form
'Configurações da janela do jogo. / The game window settings.
larguraBarraCarregamento = 700 'loading bar width
'Designer da janala do jogo. / Designer of the game window.
GraphicsWindow.BackgroundColor= "DodgerBlue"
GraphicsWindow.BrushColor= GraphicsWindow.GetColorFromRGB (255, 255, 255)
GraphicsWindow.FillRectangle (10, 10, 780, 530)
GraphicsWindow.BrushColor= GraphicsWindow.GetColorFromRGB (0, 0, 0)
GraphicsWindow.FillRectangle (15, 15, 770, 520)
'Foto de Fundo. / Photo Fund.
imagem = ImageList.LoadImage(Program.Directory + "/image/FundoTelaCarregamento.png")
GraphicsWindow.DrawImage(imagem, 15, 15)
'Textos exibidos na janela de carregamento do jogo. / Texts displayed in game loading window.
GraphicsWindow.BrushColor = "DarkOrange"
GraphicsWindow.FontSize = "40"
Logo = Shapes.AddText("Small Quest")
Shapes.Move(Logo, 280, 50)
GraphicsWindow.BrushColor = "DeepSkyBlue"
GraphicsWindow.FontSize = "20"
Direitos = Shapes.AddText(dat["independent"])
Shapes.Move(Direitos, dat["independentX"], 110)
GraphicsWindow.FontSize = "15"
ProgressoFundo = Shapes.AddText(dat["loading"])
Shapes.Move(ProgressoFundo, 357, 480)
'Sistema de carregamento. / Charging system.
GraphicsWindow.BrushColor = "White"
GraphicsWindow.FillRectangle(50, 450, larguraBarraCarregamento, 30)
For porcento = 1 to 100
larguraAtual = porcento / 100 * larguraBarraCarregamento
tempo1()
GraphicsWindow.BrushColor = "Chartreuse"
GraphicsWindow.FillRectangle(50, 450, larguraAtual, 30)
GraphicsWindow.BrushColor = "Black"
GraphicsWindow.FontSize = "15"
Shapes.Remove(Progresso)
Progresso = Shapes.AddText(porcento + "%")
Shapes.Move(Progresso, 387, 455)
EndFor
Shapes.Remove(ProgressoFundo)
GraphicsWindow.BrushColor = "DeepSkyBlue"
GraphicsWindow.FontSize = "15"
ProgressoFundo = Shapes.AddText(dat["ready"])
Shapes.Move(ProgressoFundo, 380, 480)
Program.Delay(1000)
EndSub
'Tempo de carregamento. / Charging time.
Sub tempo1
Program.Delay(50)
EndSub
Sub GameMenu_Form
'Designer da janela do jogo. / Designer of the game window.
GraphicsWindow.BackgroundColor= "DodgerBlue"
GraphicsWindow.BrushColor= GraphicsWindow.GetColorFromRGB (255, 255, 255)
GraphicsWindow.FillRectangle (10, 10, 780, 530)
GraphicsWindow.BrushColor= GraphicsWindow.GetColorFromRGB (0, 0, 0)
GraphicsWindow.FillRectangle (15, 15, 770, 520)
'Foto de Fundo. / Photo Fund.
imagem = ImageList.LoadImage(Program.Directory + "/image/FundoTelaCarregamento.png")
GraphicsWindow.DrawImage(imagem, 15, 15)
GraphicsWindow.BrushColor = "#CC000000"
GraphicsWindow.FillRectangle(300, 160, 200, 260)
'Título do jogo / Game title.
GraphicsWindow.BrushColor = "DarkOrange"
GraphicsWindow.FontSize = "40"
nameGame = Shapes.AddText("Small Quest")
Shapes.Move(nameGame, 280, 50)
'Configurações do game menu. / Game settings menu.
GameMenu_Add()
EndSub
Sub GameMenu_Add
GraphicsWindow.BrushColor = "DeepSkyBlue"
GraphicsWindow.FontSize = "20"
menuName = Shapes.AddText(dat["gameMenu"])
Shapes.Move(menuName, dat["gameMenuX"], 110)
GraphicsWindow.BrushColor = "White"
dark = 30
y0 = 180
dy = 35
For i = 1 To nMenu
y = y0 + (i - 1) * dy
menu[i] = Shapes.AddText(dat["menu" + i])
Shapes.Move(menu[i], dat["menuX" + i], y)
Shapes.SetOpacity(menu[i], dark)
EndFor
EndSub
Sub GameMenu_Select
inGame = "True"
While inGame
If mouseMove Then
my = GraphicsWindow.MouseY
selected = ""
For i = 1 To nMenu
y1 = y0 + (i - 1) * dy
y2 = y1 + dy
If y1 <= my And my < y2 Then
Shapes.SetOpacity(menu[i], 100)
selected = i
Else
Shapes.SetOpacity(menu[i], dark)
EndIf
EndFor
mouseMove = "False"
EndIf
If mouseDown Then
If selected = 1 Then 'CONTINUAR / CONTINUE
title = dat["warning"]
txt = dat["warning1"]
GraphicsWindow.ShowMessage(txt, title)
ElseIf selected = 2 Then 'NOVO JOGO / NEW GAME
Game_New()
GraphicsWindow.Clear()
GameMenu_Form()
ElseIf selected = 3 Then 'LINGUAGEM / LANGUAGE
GameMenu_Remove()
Language_Add()
mouseDown = "False"
Language_Select()
Language_Remove()
GameMenu_Add()
ElseIf selected = 4 Then 'AJUDA / HELP
title = dat["warning"]
txt = dat["warning1"]
GraphicsWindow.ShowMessage(txt, title)
ElseIf selected = 5 Then 'SAIR / EXIT
inGame = "False"
EndIf
mouseDown = "False"
EndIf
EndWhile
EndSub
Sub GameMenu_Remove
Shapes.Remove(menuName)
For i = 1 To nMenu
Shapes.Remove(menu[i])
EndFor
EndSub
Sub Game_Frame
'Designer da janela do jogo. / Designer of the game window.
GraphicsWindow.BackgroundColor= "DodgerBlue"
GraphicsWindow.BrushColor= GraphicsWindow.GetColorFromRGB (255, 255, 255)
GraphicsWindow.FillRectangle (10, 10, 780, 470)
GraphicsWindow.BrushColor= GraphicsWindow.GetColorFromRGB (255, 255, 255)
GraphicsWindow.FillRectangle (10, 490, 780, 50)
GraphicsWindow.BrushColor= GraphicsWindow.GetColorFromRGB (0, 0, 0)
GraphicsWindow.FillRectangle (13, 493, 774, 44)
GraphicsWindow.BrushColor= GraphicsWindow.GetColorFromRGB (0, 0, 0)
GraphicsWindow.FillRectangle (15, 15, 185, 460)
GraphicsWindow.BrushColor= GraphicsWindow.GetColorFromRGB (0, 0, 0)
GraphicsWindow.FillRectangle (210, 15, 185, 460)
GraphicsWindow.BrushColor= GraphicsWindow.GetColorFromRGB (0, 0, 0)
GraphicsWindow.FillRectangle (405, 15, 185, 460)
GraphicsWindow.BrushColor= GraphicsWindow.GetColorFromRGB (0, 0, 0)
GraphicsWindow.FillRectangle (600, 15, 185, 460)
EndSub
Sub Game_Characters
'Mostrar caracteres. / Show characters.
GraphicsWindow.FontSize = 30
dark = 30
y1 = 15
y2 = y1 + 460
For i = 1 To 4
x1[i] = 30 + (i - 1) * 195
x2[i] = x1[i] + 185
GraphicsWindow.BrushColor = "White"
name[i] = Shapes.AddText(dat["name" + i])
Shapes.Move(name[i], 30 + (i - 1) * 195, 496)
GraphicsWindow.BrushColor = "Gray"
path = Program.Directory + "\image\" + fname[i] + ".png"
face[i] = Shapes.AddImage(path)
Shapes.Move(face[i], 30 + (i - 1) * 195, 150)
If i = 1 Then
hover[i] = "True"
Else
hover[i] = "False"
Shapes.SetOpacity(name[i], dark)
Shapes.SetOpacity(face[i], dark)
EndIf
EndFor
EndSub
Sub Game_Actions
'Mostrar os menus de ação. / Show action menus.
y = 360
height = 100
width = 155
dark = 30
GraphicsWindow.FontSize = 16
nAction = 0
While dat["action" + (nAction + 1)] <> ""
nAction = nAction + 1
EndWhile
For i = 1 To 4
x = 30 + (i - 1) * 195
GraphicsWindow.BrushColor = "#333333"
action[i] = Shapes.AddRectangle(width, height)
Shapes.Move(action[i], x, y)
Shapes.SetOpacity(action[i], dark)
GraphicsWindow.BrushColor = "#FFFFFF"
xa = x + 10
ya = y + 4
For j = 1 To nAction
item[fname[i] + j] = Shapes.AddText(dat["action" + j])
Shapes.Move(item[fname[i] + j], xa, ya)
Shapes.SetOpacity(item[fname[i] + j], dark)
ya = ya + 20
EndFor
EndFor
EndSub
Sub Game_LoadNextScene
If scene = "" Then
scene = "s1-1"
EndIf
Language_GetTextFromDAT()
line = 1
EndSub
Sub Game_Loop
'Começar o jogo. / Start game.
mouseMove = "False"
GraphicsWindow.MouseMove = OnMouseMove
mouseDown = "False"
GraphicsWindow.MouseDown = OnMouseDown
playing = "True"
While playing
If Text.StartsWith(dat[line], "caption:") Then
caption = Text.GetSubTextToEnd(dat[line], 9)
Game_ShowCaption()
line = line + 1
ElseIf Text.StartsWith(dat[line], "next:") Then
scene = Text.GetSubTextToEnd(dat[line], 6)
Game_LoadNextScene()
ElseIf Text.StartsWith(dat[line], "end") Then
title = dat["end"]
txt = dat["end1"]
GraphicsWindow.ShowMessage(txt, title)
playing = "False"
ElseIf dat[line] = "" Then
title = dat["error"]
txt = dat["error1"]
GraphicsWindow.ShowMessage(txt, title)
playing = "False"
EndIf
If mouseMove Then
mx = GraphicsWindow.MouseX
my = GraphicsWindow.MouseY
selected = ""
For i = 1 To 4
If x1[i] <= mx And mx <= x2[i] And y1 <= my And my <= y2 Then
If hover[i] Then
For j = 1 To nAction
ya1 = 364 + (j - 1) * 20
ya2 = ya1 + 20
If ya1 <= my And my < ya2 Then
Shapes.SetOpacity(item[fname[i] + j], 100)
selected = fname[i] + j
Else
Shapes.SetOpacity(item[fname[i] + j], dark)
EndIf
EndFor
Else
hover[i] = "True"
Shapes.SetOpacity(name[i], 100)
Shapes.SetOpacity(face[i], 100)
Shapes.SetOpacity(action[i], 100)
EndIf
Else
If hover[i] Then
hover[i] = "False"
Shapes.SetOpacity(name[i], dark)
Shapes.SetOpacity(face[i], dark)
Shapes.SetOpacity(action[i], dark)
For j = 1 To nAction
Shapes.SetOpacity(item[fname[i] + j], dark)
EndFor
EndIf
EndIf
EndFor
mouseMove = "False"
Else
Program.Delay(200)
EndIf
If mouseDown Then
Game_HideBalloon()
If Text.EndsWith(selected, 1) Then 'Converse / Talk
character = 0
For i = 1 To 4
If Text.StartsWith(selected, fname[i]) Then
character = i
i = 4
EndIf
EndFor
i = character
If 1 <= i And i <= 4 Then
txt = "..."
big = "False"
For i = 1 To 4
If Text.StartsWith(dat[line], fname[i] + ":") Then
start = Text.GetLength(fname[i]) + 2
txt = Text.GetSubTextToEnd(dat[line], start)
big = "True"
line = line + 1
character = i
i = 4
EndIf
EndFor
i = character
Game_ShowBalloon()
EndIf
mouseDown = "False"
ElseIf Text.EndsWith(selected, 2) Then 'Dorme / Sleep
playing = "False"
EndIf
mouseDown = "False"
EndIf
EndWhile
EndSub
Sub Game_ShowCaption
'param caption - caption to be shown
width = 740
height = 110
xc = 30
yc = y1 + 10
GraphicsWindow.PenWidth = 2
GraphicsWindow.PenColor = "Gray"
GraphicsWindow.BrushColor = "#333333"
rect = Shapes.AddRectangle(width, height)
Shapes.Move(rect, xc, yc)
GraphicsWindow.BrushColor = "White"
GraphicsWindow.FontSize = 20
txt = Shapes.AddText(caption)
Shapes.Move(txt, xc + 10, yc + 10)
mouseDown = "False"
While Not[mouseDown]
Program.Delay(500)
EndWhile
Shapes.Remove(txt)
Shapes.Remove(rect)
EndSub
Sub Game_ShowBalloon
'Desenhe balão. / Draw balloon.
'param i - index 1..4 for each character
'param big - "True" for big balloon, "False" for small balloon
'param txt - balloon text
r = 20
height = 110
yb = y1 + 10
dx = (i - 1) * 195
GraphicsWindow.PenWidth = 0
GraphicsWindow.BrushColor = "#FFFFFF"
If big Then
width = 740
xb = 30
Else
width = 155
xb = 30 + dx
EndIf
balloon[1] = Shapes.AddRectangle(width, height - 2 * r)
Shapes.Move(balloon[1], xb, yb + r)
balloon[2] = Shapes.AddRectangle(width - 2 * r, height)
Shapes.Move(balloon[2], xb + r, yb)
For i = 3 To 6
balloon[i] = Shapes.AddEllipse(2 * r, 2 * r)
EndFor
Shapes.Move(balloon[3], xb, yb)
Shapes.Move(balloon[4], xb + width - 2 * r, yb)
Shapes.Move(balloon[5], xb, yb + height - 2 * r)
Shapes.Move(balloon[6], xb + width - 2 * r, yb + height - 2 * r)
root = Shapes.AddTriangle(50 + dx, yb + height, 65 + dx, yb + height, 65 + dx, yb + height + 20)
GraphicsWindow.BrushColor = "#000000"
GraphicsWindow.FontSize = 20
talk = Shapes.AddText(txt)
Shapes.Move(talk, xb + 10, yb + 10)
EndSub
Sub Game_HideBalloon
If root <> "" Then
Shapes.Remove(root)
root = ""
EndIf
If talk <> "" Then
Shapes.Remove(talk)
talk = ""
EndIf
For i = 1 To 6
If balloon[i] <> "" Then
Shapes.Remove(balloon[i])
balloon[i] = ""
EndIf
EndFor
EndSub
Sub OnMouseMove
mouseMove = "True"
EndSub
Sub OnMouseDown
mouseDown = "True"
EndSub
Sub Language_GetTextFromDAT
'Inicializar Idioma do Texto - Estes textos serão lidos do arquivo .dat.
'Initialize Language Text - These text will be read from .dat file.
' param scene - scene number
If scene = "" Then
fname[1] = "Diggory"
fname[2] = "Johnny"
fname[3] = "Lya"
fname[4] = "Hana"
prefix = Program.Directory + "/" + lang
Else
prefix = Program.Directory + "/scenario/" + scene + "_" + lang
EndIf
Stack.PushValue("local", i)
ln = 1
datLine = File.ReadLine(prefix + ".dat", ln)
max = 0
While datLine <> ""
nItem = Array.GetItemCount(datLine)
index = Array.GetAllIndices(datLine)
For i = 1 To nItem
dat[index[i]] = datLine[index[i]]
If max < index[i] Then
max = index[i]
EndIf
While Text.IsSubText(dat[index[i]], "<br>")
Language_ReplaceBreak()
EndWhile
EndFor
ln = ln + 1
datLine = File.ReadLine(prefix + ".dat", ln)
EndWhile
While dat[max + 1] <> ""
max = max + 1
dat[max] = ""
EndWhile
nMenu = 0
While Array.ContainsIndex(dat, "menu" + (nMenu + 1))
nMenu = nMenu + 1
EndWhile
i = Stack.PopValue("local")
EndSub
Sub Language_ReplaceBreak
' param dat[index[i]]
' return dat[indes[i]]
p = Text.GetIndexOf(dat[index[i]], "<br>")
If 0 < p Then
dat[index[i]] = Text.GetSubText(dat[index[i]], 1, p - 1) + CRLF + Text.GetSubTextToEnd(dat[index[i]], p + 4)
EndIf
EndSub
Sub Language_Add
GraphicsWindow.BrushColor = "DeepSkyBlue"
GraphicsWindow.FontSize = "20"
menuName = Shapes.AddText("LANGUAGE SELECTION")
Shapes.Move(menuName, 284, 110)
'Texto Básico para teste / Basic text for testing.
GraphicsWindow.BrushColor = "White"
menu[1] = Shapes.AddText("ENGLISH")
Shapes.Move(menu[1], 360, 180)
flag[1] = Shapes.AddImage(Program.Directory + "/image/EstadosUnidos.png")
Shapes.Move(flag[1], 320, 180 + 4)
menu[2] = Shapes.AddText("PORTUGÊS")
Shapes.Move(menu[2], 360, 215)
flag[2] = Shapes.AddImage(Program.Directory + "/image/Brasil.png")
Shapes.Move(flag[2], 320, 215 + 4)
menu[3] = Shapes.AddText("日本語")
Shapes.Move(menu[3], 360, 250)
flag[3] = Shapes.AddImage(Program.Directory + "/image/Japam.png")
Shapes.Move(flag[3], 320, 250 + 4)
nLang = 3
For i = 1 To nLang
Shapes.SetOpacity(menu[i], dark)
Shapes.SetOpacity(flag[i], dark)
EndFor
EndSub
Sub Language_Select
inSelection = "True"
While inSelection
If mouseMove Then
my = GraphicsWindow.MouseY
selected = ""
For i = 1 To nLang
y1 = y0 + (i - 1) * dy
y2 = y1 + dy
If y1 <= my And my < y2 Then
Shapes.SetOpacity(menu[i], 100)
Shapes.SetOpacity(flag[i], 100)
selected = i
If selected = 1 Then
lang = "en-US"
ElseIf selected = 2 Then
lang = "pt-BR"
ElseIf selected = 3 Then
lang = "ja-JP"
EndIf
scene = ""
Language_GetTextFromDAT()
Else
Shapes.SetOpacity(menu[i], dark)
Shapes.SetOpacity(flag[i], dark)
EndIf
EndFor
mouseMove = "False"
EndIf
If mouseDown Then
inSelection = "False"
mouseDown = "False"
EndIf
EndWhile
EndSub
Sub Language_Remove
Shapes.Remove(menuName)
For i = 1 To nLang
Shapes.Remove(menu[i])
Shapes.Remove(flag[i])
EndFor
EndSub