-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrendering.js
264 lines (163 loc) · 6.67 KB
/
rendering.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
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
function draw_game() {
ctx = canvas.getContext("2d");
ctx.drawImage(background, Math.round(platform_x_movement*(0.5)%background.width-background.width), 0);
ctx.drawImage(background, Math.round(platform_x_movement*(0.5)%background.width), 0);
ctx.drawImage(background, Math.round(platform_x_movement*(0.5)%background.width+background.width), 0);
ctx.drawImage(background2, Math.round(platform_x_movement*(0.8)%background.width-background.width), 0);
ctx.drawImage(background2, Math.round(platform_x_movement*(0.8)%background.width), 0);
ctx.drawImage(background2, Math.round(platform_x_movement*(0.8)%background.width+background.width), 0);
////////////////////////////////////////////////////////////////////////////////////////// DRAW EACH INDIVIDUAL TILE WHERE IT GOES
for(var i = 0; i<map.length; i++){
for(var k = 0; k<map[i].length; k++){
if(imageMap[i][k] != null) ctx.drawImage(imageMap[i][k], k*blocksize+Math.floor(platform_x_movement), Math.floor(i*blocksize), blocksize, blocksize);
}
}
////////////////////////////////////////////////////////////////////////////////////////// DRAW EACH COLLECTABLE
for(var i = 0; i<collectable.length; i++){
// handle booze collectables
if(!collectable[i].hidden){
ctx.drawImage(Cell.image, collectable[i].x+Math.floor(platform_x_movement), Math.floor(collectable[i].y));
}
}
////////////////////////////////////////////////////////////////////////////////////////// DRAW DAT BUCKY
drawObject(CurrPlayer, ctx);
////////////////////////////////////////////////////////////////////////////////////////// DRAW UI
drawUI(ctx);
////////////////////////////////////////////////////////////////////////////////////////// DRAW BUTTON
//Button_Gameplay_Reset.draw();
//Button_Gameplay_Options.draw();
//**************************************************************************************************** Buttons
if(Button_Gameplay_Reset.update()){
PlayerGame.resetGame();
}
if(Button_Gameplay_Options.update()){
PlayerGame.state = GAMESTATE_OPTIONS;
}
////////////////////////////////////////////////////////////////////////////////////////// DRAW SEXY GRID
if(grid){
blocksWidth = map[0].length;
blocksHeight = map.length;
for(var i = 0; i*blocksize<=blocksWidth*blocksize; i++){
ctx.stokeStyle = "rgb(0,0,0)";
ctx.beginPath();
ctx.moveTo(0,i*blocksize);
ctx.lineTo(blocksWidth*blocksize,i*blocksize);
ctx.stroke();
ctx.stokeStyle = "rgb(0,0,0)";
ctx.beginPath();
ctx.moveTo(i*blocksize+platform_x_movement%blocksize,0);
ctx.lineTo(i*blocksize+platform_x_movement%blocksize,blocksHeight*blocksize);
ctx.stroke();
ctx.stokeStyle = "rgb(0,0,0)";
}
}
}
////////////////////////////////////////////////////////////////////////////////////////// DRAW EVERYTHING
function draw_world() {
var canvas = document.getElementById("draw_canvas");
if (PlayerGame.state == GAMESTATE_GAMEPLAY) {
draw_game();
////////////////////////////////////////////////////////////////////////////////////////// SPLASH SCREEN IF-BLOCK
} else if(PlayerGame.state == GAMESTATE_OPTIONS){
ctx.drawImage(optionsScreen, 0, 0);
Button_Options_Start.update();
if(Button_Options_Start.update()){
PlayerGame.resetGame(); //reset the game so that you don't start a game at your previous progress/death
PlayerGame.state = GAMESTATE_START;
}
}
else if(PlayerGame.state == GAMESTATE_START){
ctx.drawImage(startScreen, 0, 0);
if(Button_Start_Play.update()){
PlayerGame.state = GAMESTATE_GAMEPLAY;
}
if(Button_Start_Credits.update()){
PlayerGame.state = GAMESTATE_CREDITS;
}
if(Button_Start_Options.update()){
PlayerGame.state = GAMESTATE_OPTIONS;
}
}else if(PlayerGame.state == GAMESTATE_CREDITS){
ctx.drawImage(creditScreen1, 0, 0);
//left side
ctx.drawImage(creditNameMitchell, 50, 50, 200, 100);
ctx.drawImage(creditNameAlex, 50, 150, 200, 100);
ctx.drawImage(creditNameNick, 50, 250, 200, 100);
//right side
ctx.drawImage(creditNameJason, 350, 125, 200, 100);
ctx.drawImage(creditNameJesse, 350, 300, 200, 100);
MatrixEffect();
IntToAscii(750, 200);
ctx.font = 'bold 40px Calibri';
ctx.fillStyle = "rgb(255, 255, 255)";
ctx.strokeStyle = 'white';
ctx.lineWidth = 10;
ctx.fillText(aMitchellM, 50, 50);
Button_Credits_MainMenu.draw();
if(Button_Credits_MainMenu.update()){
PlayerGame.state = GAMESTATE_START;
}
}
//end function draw_world()
}
function MatrixEffect(){
ctx.drawImage(alphabetSoup[iArrayPosition], 750, 530);
//iArrayPosition++;
//if(iArrayPosition >= 3){
// iArrayPosition = 0;
//}
//ctx.fillStyle = "rgb(0, 0, 0)";
//ctx.fillText("sdf", 370, 130);
}
function IntToAscii(iXStartPosition, iYStartPosition){
//var iXTextPosition = 0;
//var iYTextPosition = 0;
var x = String.fromCharCode(iCounter);
ctx.font = 'bold 40px Calibri';
ctx.fillStyle = "rgb(255, 255, 255)";
ctx.strokeStyle = 'white';
ctx.lineWidth = 10;
ctx.fillText(x, iXStartPosition, iYStartPosition);
//ctx.drawImage(creditNameMitchell, 50, 50, 200, 100);
//ctx.drawImage(creditNameAlex, 50, 150, 200, 100);
//ctx.drawImage(creditNameNick, 50, 250, 200, 100);
if(bMitchellM == 0){
//iStringPosition = sMitchellM.length;
//change to a while
if(iStringPosition < sMitchellM.length){
if(x == sMitchellM.charAt(iStringPosition)){
ctx.font = 'bold 40px Calibri';
ctx.fillStyle = "rgb(255, 255, 255)";
ctx.strokeStyle = 'white';
ctx.lineWidth = 10;
ctx.fillText(x, iXTextPosition, iYTextPosition);
aMitchellM[iStringPosition] = x;
iXTextPosition += 40;
iCounter = 32;
iStringPosition++;
ctx.font = 'bold 40px Calibri';
ctx.fillStyle = "rgb(255, 255, 255)";
ctx.strokeStyle = 'white';
ctx.lineWidth = 10;
ctx.fillText(aMitchellM, 50, 50);
}
else if(iCounter != sMitchellM.charAt(iStringPosition)){
iCounter++;
}
}
}
if(bJasonA == 0){
}
if(bAlexS == 0){
}
if(bNickH == 0){
}
if(bJesseK == 0)
{
iCounter++;
}
//if(iCounter <= iCounterMax)
//{
// iCounter = iCounterMin;
//}
}