-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
567 lines (491 loc) · 19.8 KB
/
index.html
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
<html>
<head>
<title>Perkele IV</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="./style/webgl.css" type="text/css">
<script type="text/javascript" src="./scripts/glMatrix-0.9.5.min.js"></script>
<script src="./scripts/entity.js" type="text/javascript"></script>
<script src="./scripts/hero.js" type="text/javascript"></script>
<script src="./scripts/world.js" type="text/javascript"></script>
<script src="./scripts/utility.js" type="text/javascript"></script>
<script src="./scripts/webgl.js" type="text/javascript"></script>
<script src="./scripts/input.js" type="text/javascript"></script>
<script src="./scripts/camera.js" type="text/javascript"></script>
<script src="./scripts/game.js" type="text/javascript"></script>
<script src="./scripts/globals.js" type="text/javascript"></script>
<script src="./scripts/ui.js" type="text/javascript"></script>
<script src="./scripts/combat.js" type="text/javascript"></script>
<script src="./scripts/ability.js" type="text/javascript"></script>
<script src="./scripts/item.js" type="text/javascript"></script>
<script src="./scripts/parse_objects.js" type="text/javascript"></script>
<script src="./scripts/terrain.js" type="text/javascript"></script>
<!--
NO NEED TO HAVE THIS - IT IS JUST FOR REFERENCE
<script src="./scripts/old.js" type="text/javascript"></script>
-->
<!-- Fragment shader program -->
<script id="shader-fs" type="x-shader/x-fragment">
/*// set medium percision
precision mediump float;
uniform vec4 tempColor;
// uniform attribute for setting the color
//varying vec4 vColor;
void main(void) {
// Setting color of fragments to input color
gl_FragColor = tempColor;//vec4(1.0,1.0,1.0,1.0);//vColor;
}*/
precision mediump float;
// atributes for setting vertex position, normals and texture coordinates
//varying vec2 vTextureCoord;
varying vec3 vTransformedNormal;
varying vec4 vPosition;
varying vec2 vTextureCoord;
uniform bool uUseLighting; // lighting switch
uniform bool uUseTextures; // textre switch
uniform vec3 uAmbientColor; // ambient color uniform
uniform vec3 uPointLightingLocation; // light direction uniform
uniform vec3 uPointLightingColor; // light color
uniform vec3 uDirectionalLightingLocation;
uniform vec3 uDirectionalLightingColor;
// uniform attribute for setting 2D sampler
uniform sampler2D uSampler;
uniform vec4 tempColor;
uniform float attenuationFactor;
void main(void) {
vec3 lightWeighting;
if (!uUseLighting) {
lightWeighting = vec3(1.0, 1.0, 1.0);
} else {
// transform normals
vec3 lightDirection = normalize(uPointLightingLocation - vPosition.xyz);
// calculate weight for directional light
float directionalLightWeighting = max(dot(normalize(vTransformedNormal), lightDirection), 0.0);
// calculate point lighting
lightWeighting = uAmbientColor + uPointLightingColor * directionalLightWeighting;
// calculate directional lighting
directionalLightWeighting = max(dot(normalize(vTransformedNormal), uDirectionalLightingLocation), 0.0);
lightWeighting = lightWeighting + uDirectionalLightingColor * directionalLightWeighting;
//float attenuationFactor = 0.01; // manjsi k je, bol bo svetil okol playerja FYI
lightWeighting = lightWeighting * (1.0 / (1.0+attenuationFactor*pow(distance(vPosition.xyz, uPointLightingLocation), 2.0)));
}
vec4 fragmentColor;
if (uUseTextures) {
fragmentColor = texture2D(uSampler, vec2(vTextureCoord.s, vTextureCoord.t));
} else {
fragmentColor = tempColor;//vec4(1.0, 1.0, 1.0, 1.0);
}
gl_FragColor = vec4(fragmentColor.rgb * lightWeighting, fragmentColor.a);
}
</script>
<!-- Vertex shader program -->
<script id="shader-vs" type="x-shader/x-vertex">
// atributes for setting vertex position and color
/*attribute vec3 aVertexPosition;
attribute vec4 aVertexColor;
uniform mat4 uMVMatrix; // model-view matrix
uniform mat4 uPMatrix; // projection matrix
// variable for passing color from vertex shader to fragment shader
//varying vec4 vColor;
void main(void) {
// calculate the vertex position
gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);
//vColor = aVertexColor;
}*/
// atributes for setting vertex position, normals and texture coordinates
attribute vec3 aVertexPosition;
attribute vec3 aVertexNormal;
attribute vec2 aTextureCoord;
uniform mat4 uMVMatrix; // model-view matrix
uniform mat4 uPMatrix; // projection matrix
uniform mat3 uNMatrix; // normal matrix
// variable for passing texture coordinates and lighting weights
// from vertex shader to fragment shader
varying vec2 vTextureCoord;
varying vec3 vTransformedNormal;
varying vec4 vPosition;
void main(void) {
// calculate the vertex position
vPosition = uMVMatrix * vec4(aVertexPosition, 1.0);
gl_Position = uPMatrix * vPosition;
vTextureCoord = aTextureCoord;
vTransformedNormal = uNMatrix * aVertexNormal;
}
</script>
</head>
<body onload="start()">
<div id="content">
<canvas id="glcanvas" width="1850px" height="900px">
No <code><canvas></code> suppport in your browser.
</canvas>
<!-- UI ELEMENTS -->
<!-- Top of game screen; used for showing selected enemy health -->
<div id="UIWrapper">
<div id="mainMenuScreen">
<div class="popupBox">
<div class="popupBoxWrapper">
<h1 style="font-size:100px;text-align:center; margin-top:100px;">PERKELE<br/>IV</h1>
<h3 style="color:white">Diablo has returned yet again! Join the fight against him and his countless hordes of demon monsters!<br/>But beware, none have returned from their journey.</h3>
<div onClick="ui.closeMainMenu()" class="uiButton" style="margin:0px auto;">START GAME</div>
<div id="howToPlayBtn" class="uiButton" style="margin:0px auto;">HOW TO PLAY</div>
<div id="howToPlayDiv">
<p>You control one character. The camera always follows him (no free camera).</p>
<p>Click with your mouse to move your character.<br/>If you click on a pickup-able item, your character will move to it and pick it up.<br/>If you click on a monster, your character will move to it and start attacking.<br/>Keep clicking to keep attacking!</p>
<p>With each hit, you gain Fury, which can be used to trigger your abilities. You can read more about it in-game (HELP menu option).
</div>
</div>
</div>
</div>
<div id="gameOverScreen">
<div class="popupBox">
<div class="popupBoxWrapper">
<h1 style="font-size:100px;color:red;text-align:center; margin-top:200px;">GAME OVER</h1>
<h3 style="color:white">"Stay a while and listen."<br/>- Deckard Cain</h3>
<div onClick="ui.gameOverToMainMenu()" id="gameOverToMainMenuBtn" class="uiButton" style="display:none;margin:0px auto;">TO MAIN MENU</div>
</div>
</div>
</div>
<div id="topBar">
<div id="enemyHealthBar">
<span id="enemyHealthBarName">EVIL PUMPKIN</span>
<div id="enemyHealthBarPercentage">
</div>
</div>
</div>
<div id="inventoryBar">
<div class="popupBox">
<div id="itemList">
<h3>INVENTORY</h3>
Choose a weapon to equip
<!--<div class="inventoryItem">
<img class="itemImg" src="assets/ui/swordIcon.jpg" />
<span class="itemName">BANISHER OF DEMONS</span>
</div>-->
</div>
<div id="itemDescriptionWrapper">
<div id="itemDescription">
<p id="selectedWeaponName" class="inventoryHeading">BANISHER OF DEMONS</p>
<p id="weaponAttack">Attack: +20</p>
<p id="weaponcriticalChance">Critical Chance: +10%</p>
<p id="weaponRarity">Rarity: LEGENDARY</p>
</div>
<hr />
<div id="playerStats">
<p class="inventoryHeading">YOUR STATS</p>
<p id="statsHP">HP: 55 / 100</p>
<p id="statsHPRegen">HP regeneration: 1 / sec</p>
<p id="statsAttack">Attack: 33</p>
<p id="statsCriticalChance">Critical Chance: 10%</p>
<p id="statsFury">Fury: 0 / 100</p>
</div>
</div>
</div>
</div>
<div id="characterBar">
<div class="popupBox">
<div class="popupBoxWrapper">
<h3>CHARACTER STATS</h3>
<hr/>
<p>HP: <span id="characterStatsHP">0 / 0</span></p>
<p>HP regen: <span id="characterStatsHPRegen">0 / sec</span></p>
<p>Fury: <span id="characterStatsFury">0 / 0</span></p>
<p>Fury decay: <span id="characterStatsFuryDecay">0 / sec</span></p>
<hr/>
<p>Base attack: <span id="characterStatsBaseAttack">0</span></p>
<p>Base critical chance: <span id="characterStatsBaseCritical">0 %</span></p>
<p>Weapon attack: <span id="characterStatsWeaponAttack">0</span></p>
<p>Weapon critical chance: <span id="characterStatsWeaponCritical">0 %</span></p>
<p>Total attack: <span id="characterStatsTotalAttack">0</span></p>
<p>Total critical chance: <span id="characterStatsTotalCritical">0 %</span></p>
<hr/>
<p>Discovery: <span id="characterStatsDiscovery">0 %</span></p>
</div>
</div>
</div>
<div id="menuBar">
<div class="popupBox">
<div class="popupBoxWrapper">
<h3>MENU</h3>
<hr/>
<div onclick="ui.gameOverToMainMenu()" class="uiButton" style="margin:0px auto;">EXIT</div>
<a href="https://www.youtube.com/watch?v=dQw4w9WgXcQ"><div class="uiButton" style="margin:0px auto;">BUY VALOR POINTS</div></a>
</div>
</div>
</div>
<div id="helpBar">
<div class="popupBox">
<div class="popupBoxWrapper">
<h3>HELP</h3>
<hr/>
<h4>Fury</h4>
<p>Fury is used to activate your various abilities. You gain Fury by attacking enemies, but it slowly diminishes/decays, so use those abilities before you run out!</p>
<hr/>
<h4>Abilities</h4>
<p>In addition to basic attack, which generates Fury, your Hero has 2 abilites:<br/>
<ul>
<li>360 slash (use '1' to activate) damages all enemies around you</li>
<li>Heal (use '2' to activate) heals your Hero for 50% of maximum HP</li>
</ul>
<hr/>
<h4>Critical chance</h4>
<p>Each basic attack has a chance do deal 'critical damage', which is double your basic damage.</p>
<hr/>
<h4>Discovery and loot</h4>
<p>Your 'Discovery' stat determines the chance of monsters dropping weapons upon death.</p>
<p>Weapons drop in different rarities (by order of rarity): COMMON, RARE, LEGENDARY, EPIC</p>
<p>Rarer weapons drop less often, but usually have much better stats! Use your inventory to switch between collected weapons.</p>
</div>
</div>
</div>
<div id="loadingBar">
<div class="popupBox">
<div class="popupBoxWrapper">
<h1>LOADING</h1>
<h3>The game is never late, <br/>it arrives precisely when it's meant to!<br/>---Long gone wizard</h3>
</div>
</div>
</div>
<div id="victoryBar">
<div class="popupBox">
<div class="popupBoxWrapper">
<h1>Thanks for playing!</h1>
<h3>We hope you had as much fun playing, <br/>as we had making this game!</h3>
<h4>- Perkele Team </h4>
<div onClick="ui.gameOverToMainMenu()" id="victoryToMainMenuBtn" class="uiButton" style="display:none;margin:0px auto;">TO MAIN MENU</div>
</div>
</div>
</div>
<div id="victoryText">
<div class="popupBox">
<div class="popupBoxWrapper">
<h3>Diablo has perished, light returns to this world as a result of your actions!</h3>
</div>
</div>
</div>
<div id="bottomBar">
<div id="healthBox">
<span id="currentHP" class="boxText">HP<br/>0/0</span>
<div id="healthPercentage"></div>
</div>
<div id="abilityBar">
<div id="characterButtons">
<div onclick="ui.toggleCharacterStats()" class="uiButton">CHARACTER</div>
<div onclick="ui.toggleInventory()" class="uiButton">INVENTORY</div>
</div>
<div id="abilityWrapper">
<div class="abilityBox">
<span class="abilityName">LMOUSE<br/>Basic Attack<br/>+10 Fury</span>
<div id="abilityBasicAttackCooldownBar" class="abilityCooldown">
</div>
</div>
<div class="abilityBox">
<span class="abilityName">1<br/>360 Slash<br/>-50 Fury</span>
<div id="ability360SlashCooldownBar" class="abilityCooldown">
</div>
</div>
<div class="abilityBox">
<span class="abilityName">2<br/>Heal<br/>-25 Fury</span>
<div id="abilityHealCooldownBar" class="abilityCooldown">
</div>
</div>
</div>
<div id="systemButtons">
<div onclick="ui.toggleHelp()" class="uiButton">HELP</div>
<div onclick="ui.toggleMenu()" class="uiButton">MENU</div>
</div>
</div>
<div id="furyBox">
<span id="currentFury" class="boxText">Fury<br/>0/0</span>
<div id="furyPercentage"></div>
</div>
</div>
</div>
</div>
<div>
<audio id="audioAmbient" style="display:none;" controls>
<source src="assets/audio/ambient.mp3" type="audio/mpeg">
</audio>
<audio class="audioBasicAttack">
<source src="assets/audio/basicattack1.mp3" type="audio/mpeg">
</audio>
<audio class="audioBasicAttack">
<source src="assets/audio/basicattack2.mp3" type="audio/mpeg">
</audio>
<audio class="audioBasicAttack">
<source src="assets/audio/basicattack3.mp3" type="audio/mpeg">
</audio>
<audio class="audioBasicAttack">
<source src="assets/audio/basicattack4.mp3" type="audio/mpeg">
</audio>
<audio class="audioBasicAttack">
<source src="assets/audio/basicattack5.mp3" type="audio/mpeg">
</audio>
<audio class="audioBasicAttack">
<source src="assets/audio/basicattack6.mp3" type="audio/mpeg">
</audio>
<audio id="audioWhirlwind">
<source src="assets/audio/whirlwind.mp3" type="audio/mpeg">
</audio>
<audio id="audioHeal">
<source src="assets/audio/heal.mp3" type="audio/mpeg">
</audio>
<audio class="audioGetHit">
<source src="assets/audio/gethit1.mp3" type="audio/mpeg">
</audio>
<audio class="audioGetHit">
<source src="assets/audio/gethit2.mp3" type="audio/mpeg">
</audio>
<audio class="audioGetHit">
<source src="assets/audio/gethit3.mp3" type="audio/mpeg">
</audio>
<audio class="audioGetHit">
<source src="assets/audio/gethit4.mp3" type="audio/mpeg">
</audio>
<audio class="audioGetHit">
<source src="assets/audio/gethit5.mp3" type="audio/mpeg">
</audio>
<audio class="audioGetHit">
<source src="assets/audio/gethit6.mp3" type="audio/mpeg">
</audio>
<audio class="audioGetHit">
<source src="assets/audio/gethit7.mp3" type="audio/mpeg">
</audio>
<audio class="audioGetHit">
<source src="assets/audio/gethit8.mp3" type="audio/mpeg">
</audio>
<audio class="audioGetHit">
<source src="assets/audio/gethit9.mp3" type="audio/mpeg">
</audio>
<audio class="audioGetHit">
<source src="assets/audio/gethit10.mp3" type="audio/mpeg">
</audio>
<audio id="audioDeath1">
<source src="assets/audio/death1.mp3" type="audio/mpeg">
</audio>
<audio id="audioDeath2">
<source src="assets/audio/death2.mp3" type="audio/mpeg">
</audio>
<audio id="audioYouDied">
<source src="assets/audio/youdied.mp3" type="audio/mpeg">
</audio>
<audio id="audioDropNormal">
<source src="assets/audio/drop.mp3" type="audio/mpeg">
</audio>
<audio id="audioDropLegendary">
<source src="assets/audio/legendaryDrop.mp3" type="audio/mpeg">
</audio>
<audio id="audioButton">
<source src="assets/audio/button.wav" type="audio/wav">
</audio>
<audio id="audioPickup">
<source src="assets/audio/pickup.wav" type="audio/wav">
</audio>
<audio id="audioSelectWeapon">
<source src="assets/audio/selectWeapon.wav" type="audio/wav">
</audio>
<audio class="audioDiabloBoast">
<source src="assets/audio/diabloBoast1.mp3" type="audio/mpeg">
</audio>
<audio class="audioDiabloBoast">
<source src="assets/audio/diabloBoast2.mp3" type="audio/mpeg">
</audio>
<audio class="audioDiabloBoast">
<source src="assets/audio/diabloBoast3.mp3" type="audio/mpeg">
</audio>
<audio class="audioDiabloHalfHealth">
<source src="assets/audio/diabloHalfHealth1.mp3" type="audio/mpeg">
</audio>
<audio class="audioDiabloHalfHealth">
<source src="assets/audio/diabloHalfHealth2.mp3" type="audio/mpeg">
</audio>
<audio class="audioDiabloQuarterHealth">
<source src="assets/audio/diabloQuarterHealth1.mp3" type="audio/mpeg">
</audio>
<audio class="audioDiabloKillsHero">
<source src="assets/audio/diabloKillsHero1.mp3" type="audio/mpeg">
</audio>
<audio class="audioDiabloKillsHero">
<source src="assets/audio/diabloKillsHero2.mp3" type="audio/mpeg">
</audio>
<audio class="audioDiabloDies">
<source src="assets/audio/diabloDies.mp3" type="audio/mpeg">
</audio>
<audio class="audioPlayerKillsDiablo">
<source src="assets/audio/playerKillsDiablo1.mp3" type="audio/mpeg">
</audio>
<audio id="audioDiabloFightAmbient">
<source src="assets/audio/diabloFightAmbient.mp3" type="audio/mpeg">
</audio>
<audio id="audioPlayerWonAmbient">
<source src="assets/audio/playerWonAmbient.mp3" type="audio/mpeg">
</audio>
<audio id="audioPlayerDiabloTaunt">
<source src="assets/audio/playerDiabloTaunt.mp3" type="audio/mpeg">
</audio>
<audio class="audioEnemyAttack">
<source src="assets/audio/enemyAttack1.mp3" type="audio/mpeg">
</audio>
<audio class="audioEnemyAttack">
<source src="assets/audio/enemyAttack2.mp3" type="audio/mpeg">
</audio>
<audio class="audioEnemyAttack">
<source src="assets/audio/enemyAttack3.mp3" type="audio/mpeg">
</audio>
<audio class="audioEnemyAttack">
<source src="assets/audio/enemyAttack4.mp3" type="audio/mpeg">
</audio>
<audio class="audioEnemyAttack">
<source src="assets/audio/enemyAttack5.mp3" type="audio/mpeg">
</audio>
<audio class="audioEnemyAttack">
<source src="assets/audio/enemyAttack6.mp3" type="audio/mpeg">
</audio>
<audio class="audioEnemyAttack">
<source src="assets/audio/enemyAttack7.mp3" type="audio/mpeg">
</audio>
<audio class="audioDiabloImmortalLaugh">
<source src="assets/audio/diabloImmortalLaugh1.mp3" type="audio/mpeg">
</audio>
<audio class="audioDiabloImmortalLaugh">
<source src="assets/audio/diabloImmortalLaugh2.mp3" type="audio/mpeg">
</audio>
<audio class="audioDiabloImmortalLaugh">
<source src="assets/audio/diabloImmortalLaugh3.mp3" type="audio/mpeg">
</audio>
<!--
<h4>FIX ASAP:</h4>
fix that lightning <br />
</div>
<div>
<h4>TODO:</h4>
if objects comes under mouse the hud should update <br />
implement meta data for classes <br/>
add walls and stairs <br/>
</div>
<div>
<h4>Postponed:</h4>
add animations<br />
add effects<br />
collision box for terrain - no need<br />
fix ray tracing starting too high - no need<br />
</div>
<div>
<h4>Finished:</h4>
HP regen <br />
implement items <br/>
implement area abilities <br />
enemy health bar hide on death <br />
implement enemy attacking via range <br/>
fix movement on y axis - also the reason for rotation to 0,0,0 angle at first move <br />
implement collision bypassing - we should move towards our destination at other angles <br />
implement dead enemy deliting/collision ignoring <br/>
implement enemy attack <br />
enemy evil pumpkin <br />
entity name<br />
change terrain to world object <br />
implement enemy class - merged to hero<br/>
add entity type <br />
implement entity class for all <br/>
implement inheritance <br/>
</div>-->
</body>
</html>