-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScriptSource.js
More file actions
191 lines (154 loc) · 4.93 KB
/
ScriptSource.js
File metadata and controls
191 lines (154 loc) · 4.93 KB
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
//Classe que será aberta quando a janela do navegador iniciar
window.onload = function(){
//Variaveis de Canvas
var cnv = document.querySelector("canvas");
//Variaveis de sprite do personagem
var spriteSheet = new Image();
spriteSheet.src = "img/player/chrono_sprite.png";
var player = new Sprite();
player.setSprite("img/player/chrono_sprite.png");
player.setBattleAnimationDetails("img/player/chrono_battle_sprites.png", 350, 350, 50, 50, [6,5,4,3,2], ["intro","attack","hability","death","damage"]); //(sprite, posX, posY, width, height, rangeVector, actionsVector)
//Estado do Jogo
var MENU = 1, CREDITOS = 2, VILA_INICIAL = 3, LOJA = 4, MAPA_MUNDI = 5, ARENA = 6, GAME_OVER = 7, SISTEMA_LOJA = 8,FLORESTA = 9, SISTEMA_INVENTARIO = 10;
var CASAFERREIRO = 11,CASANPC = 12, CASASERVICOS = 13, CASAMISSOES = 14, INTRODUCAO = 15, FINAL_JOGO = 16, INSTRUCAO = 17;
var gameState = MENU;
//Instanciação das Classes de Telas
var menu = new MenuInicial(cnv,player);
var creditos = new Creditos(cnv);
var vila = new VilaInicial(cnv,player);
var loja = new Loja(cnv,player);
var arena = new ArenaCombate(cnv,player);
var mapaMundi = new MapaMundi(cnv,arena,player);
var gameOver = new GameOver(cnv);
var sisLoja = new SistemaLoja(cnv, player);
var introFloresta = new Floresta(cnv,player);
var inventario = new SistemaInventario(cnv, player);
var casaFerreiro = new CasaFerreiro(cnv,player);
var casaNpc = new CasaNpc(cnv,player);
var casaServicos = new CasaServicos(cnv,player);
var casaMissoes = new CasaMissoes(cnv,player);
var introducao = new Introducao(cnv);
var fimJogo = new FimJogo(cnv);
var instrucao = new Instrucao(cnv);
//Ao carregar a pagina, começa o jogo
spriteSheet.onload = function(){
menu.updateGameState(gameState);
menu.start();
creditos.start();
vila.start();
loja.start();
mapaMundi.start();
arena.start();
gameOver.start();
sisLoja.start();
introFloresta.start();
inventario.start();
casaFerreiro.start();
casaNpc.start();
casaServicos.start();
casaMissoes.start();
introducao.start();
fimJogo.start();
instrucao.start();
loop();
}
function loop(){
window.requestAnimationFrame(loop,cnv);
switch(gameState){
case MENU:
menu.loop();
gameState = menu.returnState();
//console.log("Menu ReturnState: " + gameState);
break;
case CREDITOS:
creditos.loop();
gameState = creditos.returnState();
//console.log("Creditos ReturnState: " + gameState);
break;
case VILA_INICIAL:
vila.loop();
gameState = vila.returnState();
//console.log("Vila ReturnState: " + gameState);
break;
case LOJA:
loja.loop();
gameState = loja.returnState();
//console.log("Loja ReturnState: " + gameState);
break;
case MAPA_MUNDI:
mapaMundi.loop();
gameState = mapaMundi.returnState();
//console.log("Mapa Mundi ReturnState: " + gameState);
break;
case ARENA:
arena.loop();
gameState = arena.returnState();
//console.log("Arena ReturnState: " + gameState);
break;
case GAME_OVER:
gameOver.loop();
gameState = gameOver.returnState();
//console.log("Arena ReturnState: " + gameState);
break;
case SISTEMA_LOJA:
sisLoja.loop();
gameState = sisLoja.returnState();
//console.log("Sistema Loja ReturnState: " + gameState);
break;
case FLORESTA:
introFloresta.loop();
gameState = introFloresta.returnState();
break;
case CASAFERREIRO:
casaFerreiro.loop();
gameState = casaFerreiro.returnState();
break;
case CASANPC:
casaNpc.loop();
gameState = casaNpc.returnState();
break;
case CASASERVICOS:
casaServicos.loop();
gameState = casaServicos.returnState();
break;
case SISTEMA_INVENTARIO:
inventario.loop();
gameState = inventario.returnState();
break;
case CASAMISSOES:
casaMissoes.loop();
gameState = casaMissoes.returnState();
break;
case INTRODUCAO:
introducao.loop();
gameState = introducao.returnState();
break;
case FINAL_JOGO:
fimJogo.loop();
gameState = fimJogo.returnState();
break;
case INSTRUCAO:
instrucao.loop();
gameState = instrucao.returnState();
break;
}
//Atualização do gameState nas telas
menu.updateGameState(gameState);
creditos.updateGameState(gameState);
vila.updateGameState(gameState);
loja.updateGameState(gameState);
mapaMundi.updateGameState(gameState);
arena.updateGameState(gameState);
gameOver.updateGameState(gameState);
sisLoja.updateGameState(gameState);
introFloresta.updateGameState(gameState);
casaFerreiro.updateGameState(gameState);
casaNpc.updateGameState(gameState);
casaServicos.updateGameState(gameState);
inventario.updateGameState(gameState);
casaMissoes.updateGameState(gameState);
introducao.updateGameState(gameState);
fimJogo.updateGameState(gameState);
instrucao.updateGameState(gameState);
}
}