-
Notifications
You must be signed in to change notification settings - Fork 163
/
Copy pathindex-uncompress.html
2173 lines (1677 loc) · 61.2 KB
/
index-uncompress.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
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"/>
<title>JunoJS</title>
<script type="text/javascript">
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function () {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];
window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame']
|| window[vendors[x] + 'CancelRequestAnimationFrame'];
}
if (!window.requestAnimationFrame)
window.requestAnimationFrame = function (callback, element) {
var currTime = new Date().getTime();
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
var id = window.setTimeout(function () {
callback(currTime + timeToCall);
},
timeToCall);
lastTime = currTime + timeToCall;
return id;
};
if (!window.cancelAnimationFrame)
window.cancelAnimationFrame = function (id) {
clearTimeout(id);
};
}());
var waves = 0;
var _sw = 0;
var _sh = 0;
var _sx = 0;
var _sy = 0;
var _sz = 0;
var _ss = 1;
var canvas = false;
var context = false;
var runGameCountDefine = 4000;
var runGameCount = 0;
var gameIsRunning = false;
var inMenu = true;
// Containers
var missiles = [];
var op_missiles = [];
var opponent = [];
var particles = [];
// Prepare data
var cosA = [], sinA = [];
for (var i = 0; i <= 720; i++) {
var _a = degToRad(-360 + i);
cosA[i] = Math.cos(_a);
sinA[i] = Math.sin(_a);
}
// Functions
function degToRad(angle) {
return angle * (Math.PI / 180);
}
function radToDeg(angle) {
return angle * (180 / Math.PI);
}
function gCosA(angle) {
return angle >= 0 ? cosA[angle + 360] : cosA[360 + angle];
}
function gSinA(angle) {
return angle >= 0 ? sinA[angle + 360] : sinA[360 + angle];
}
function rnd(x) {
return Math.random() * x;
}
Array.prototype.remove = function (index) {
this.splice(index, 1);
};
// Classes
function P3(x, y, z) {
this.x = x;
this.y = y;
this.z = z;
this.rotateX = function (angle) {
var y = this.y * gCosA(angle) - this.z * gSinA(angle);
var z = this.y * gSinA(angle) + this.z * gCosA(angle);
return new P3(this.x, y, z);
};
this.rotateY = function (angle) {
var z = this.z * gCosA(angle) - this.x * gSinA(angle);
var x = this.z * gSinA(angle) + this.x * gCosA(angle);
return new P3(x, this.y, z);
};
this.rotateZ = function (angle) {
var x = this.x * gCosA(angle) - this.y * gSinA(angle);
var y = this.x * gSinA(angle) + this.y * gCosA(angle);
return new P3(x, y, this.z);
};
this.project = function (viewWidth, viewHeight, fov, viewDistance) {
var factor = fov / (viewDistance + this.z);
var x = this.x * factor + viewWidth / 2;
var y = this.y * factor + viewHeight / 2;
return new P3(x, y, this.z);
}
}
function Message() {
this.time = 0;
this.str = "";
this.update = function (time) {
if (this.time <= 0) {
this.time = 0;
}
if (this.time > 0) {
this.time -= time;
context.beginPath();
context.fillStyle = 'rgba(255,255,255,.3)';
context.font = "bold " + Math.round(48 * _ss) + "px Helvetica";
context.textAlign = 'center';
context.fillText(this.str.toString(), _sx, _sy);
context.closePath();
}
};
this.text = function (str, time) {
this.time = time;
this.str = str;
}
}
function FPS() {
this.fps = 0;
this.now = 0;
this.lastUpdate = new Date - 1;
this.fpsFilter = 50;
this.lastStep = 0;
this.now = new Date;
this.draw = function () {
document.getElementById('fps').innerHTML = 'fps: ' + this.fps.toFixed(1) + " step: " + this.lastStep.toFixed(1);
};
this.update = function () {
this.now = new Date;
var tmp = 1000 / (this.now - this.lastUpdate);
this.fps += (tmp - this.fps) / this.fpsFilter;
this.lastStep = (this.now - this.lastUpdate);
this.lastUpdate = this.now;
}
}
function Missile(position, depth, speed, color) {
this.position = position;
this.depth = depth;
this.color = color;
this.speed = speed;
this.update = function (time) {
var lg_rad = ( _sh / 2 );
var angle = this.position * 2 * Math.PI / _player.available_moves;
var ca_rad = Math.cos(angle) * lg_rad;
var sa_rad = Math.sin(angle) * lg_rad;
var sx = _sx + ca_rad * this.depth;
var sy = _sy + sa_rad * this.depth;
var ex = _sx + ca_rad * (this.depth + (0.2 * this.depth * _ss));
var ey = _sy + sa_rad * (this.depth + (0.2 * this.depth * _ss));
context.beginPath();
context.moveTo(sx, sy);
context.lineTo(ex, ey);
context.lineWidth = ( 20 * this.depth ) * _ss;
context.strokeStyle = this.color;
context.stroke();
context.closePath();
this.depth -= ((this.speed / (1000 / 60)) * time) * this.depth;
}
}
function Particle() {
this.x;
this.y;
this.size;
this.color;
this.scale;
this.velocityX;
this.velocityY;
}
function Explosion(x, y, color) {
this.items = [];
this.time = 1000;
for (var angle = 0; angle < 360; angle += 60) {
var particle = new Particle();
particle.x = x;
particle.y = y;
particle.size = 3 + rnd(12);
particle.color = color;
particle.scale = 1.0;
var speed = 20 + rnd(80);
particle.velocityX = speed * gCosA(angle);
particle.velocityY = speed * gSinA(angle);
this.items.push(particle);
}
this.update = function (time) {
this.time -= time;
for (var i = 0; i < this.items.length; i++) {
this.items[i].scale -= time / 1000;
if (this.items[i].scale <= 0) {
this.items[i].scale = 0;
}
this.items[i].x += this.items[i].velocityX * time / 1000;
this.items[i].y += this.items[i].velocityY * time / 1000;
context.beginPath();
context.rect(this.items[i].x, this.items[i].y, this.items[i].size * this.items[i].scale, this.items[i].size * this.items[i].scale);
context.fillStyle = this.items[i].color;
context.fill();
context.closePath();
}
}
}
function Stars() {
this.count = 128;
this.items = new Array(this.count);
this.ratio = 128;
this.startSpeedDefine = 12;
this.speed = 1;
this.resize = function () {
for (var i = 0; i < this.count; i++) {
this.items[i] = [];
this.items[i][0] = rnd(_sw) * 2 - _sx * 2;
this.items[i][1] = rnd(_sh) * 2 - _sy * 2;
this.items[i][2] = Math.round(rnd(_sz)) * 2;
this.items[i][3] = 0;
this.items[i][4] = 0;
this.items[i][5] = true;
this.items[i][6] = 0;
this.items[i][7] = 0;
if (Math.sqrt(Math.pow((this.items[i][0]), 2) + Math.pow((this.items[i][1]), 2)) < _sh / 2) {
i--;
}
}
};
this.draw = function () {
context.strokeStyle = 'rgba(255,255,255,.2)';
var lg_rad = ( _sh / 2 ) * 2.4;
var angle = 360 / _player.available_moves;
for (var j = 0; j < _player.available_moves; j++) {
var qx = _sx + gCosA(j * angle) * lg_rad;
var qy = _sy + gSinA(j * angle) * lg_rad;
context.beginPath();
context.moveTo(_sx, _sy);
context.lineTo(qx, qy);
context.lineWidth = 0.3;
context.stroke();
context.closePath();
}
context.strokeStyle = 'rgb(255,255,255)';
for (var i = 0; i < this.count; i++) {
if (this.items[i][5] &&
this.items[i][7] < _sh &&
this.items[i][7] > 0 &&
this.items[i][6] < _sw &&
this.items[i][6] > 0) {
context.beginPath();
context.moveTo(this.items[i][6], this.items[i][7]);
context.lineTo(this.items[i][3], this.items[i][4]);
context.lineWidth = 0.2 * _sz / this.items[i][2];
context.stroke();
context.closePath();
}
}
};
this.update = function (time) {
for (var i = 0; i < this.count; i++) {
this.items[i][5] = true;
this.items[i][6] = this.items[i][3];
this.items[i][7] = this.items[i][4];
var st_speed = (this.speed / (1000 / 60)) * time;
this.items[i][2] -= this.speed;
if (this.items[i][2] > _sz) {
this.items[i][2] -= _sz;
this.items[i][5] = false;
}
if (this.items[i][2] < 0) {
this.items[i][2] += _sz;
this.items[i][5] = false;
}
this.items[i][3] = _sx + (this.items[i][0] / this.items[i][2]) * this.ratio;
this.items[i][4] = _sy + (this.items[i][1] / this.items[i][2]) * this.ratio;
}
this.draw();
}
}
function Obj() {
this.vertices = [];
this.faces = [];
this.colors = [];
this.t = [];
this.avg_z = [];
this.x = 0;
this.y = 0;
this.z = 0;
this.rx = 0;
this.ry = 0;
this.rz = 0;
this.fov = 800;
this.distance = 6;
this.isHit = false;
this.hitTimeDefine = 1;
this.hitTime = 0;
this.hitColor = 'rgb(0,255,0)';
this.color = false;
this.offset = 0;
this.currentOffset = 0;
this.offsetLimit = 0;
this.removed = false;
this.hit = function () {
if (this.currentOffset == this.offsetLimit ||
this.currentOffset / this.offsetLimit >= 0.5) {
this.isHit = true;
this.hitTimeDefine = 100;
this.hitTime = 0;
return true;
}
return false;
};
this.read = function (_p, _v, _f, _c) {
var i;
// vertex
for (i = 0; i < _v.length; i += 3) {
this.vertices.push(new P3((parseInt(_p[_v[i]], 36) / 1000000), (parseInt(_p[_v[i + 1]], 36) / 1000000), (parseInt(_p[_v[i + 2]], 36) / 1000000)));
}
// face
for (i = 0; i < _f.length; i += 3) {
this.faces.push(new Array(parseInt(_f[i], 36), parseInt(_f[i + 1], 36), parseInt(_f[i + 2], 36)));
}
// colors
for (i = 0; i < _c.length; i++) {
this.colors.push('#' + _c[i]);
}
};
this.gen = function () {
this.t = [];
this.avg_z = [];
var i;
for (i = 0; i < this.vertices.length; i++) {
var v = this.vertices[i];
var r = v.rotateX(this.rx).rotateY(this.ry).rotateZ(this.rz);
var p = r.project(0, 0, this.fov, this.distance / _ss);
this.t.push(p)
}
for (i = 0; i < this.faces.length; i++) {
var f = this.faces[i];
this.avg_z[i] = { "index": i, "sort": (this.t[f[0]].z + this.t[f[1]].z + this.t[f[2]].z) / 3, "color": this.colors[i]};
}
this.avg_z.sort(function (a, b) {
return b.sort - a.sort;
});
};
this.move = function (x, y, z) {
this.x = x;
this.y = y;
this.z = z;
};
this.rotate = function (x, y, z) {
var gen = false;
if (this.rx != x || this.ry != y || this.rz != z) {
gen = true;
}
this.rx = x;
this.ry = y;
this.rz = z;
if (gen) {
this.gen();
}
};
this.draw = function () {
for (var i = 0; i < this.faces.length; i++) {
var f = this.faces[this.avg_z[i].index];
context.beginPath();
context.fillStyle = this.isHit ? this.hitColor : this.color ? this.color : this.avg_z[i].color;
context.moveTo(this.t[f[0]].x + this.x, this.t[f[0]].y + this.y);
context.lineTo(this.t[f[1]].x + this.x, this.t[f[1]].y + this.y);
context.lineTo(this.t[f[2]].x + this.x, this.t[f[2]].y + this.y);
context.fill();
context.closePath();
}
}
}
function Background() {
this.backgroundData = false;
this.resize = function () {
context.fillStyle = "rgb(0,0,0)";
context.fillRect(0, 0, _sw, _sh);
context.globalAlpha = 0.3;
var grd = context.createRadialGradient(_sh / 4, _sh / 4, 50, _sh / 4, _sh / 4, 300);
grd.addColorStop(0, '#900');
grd.addColorStop(1, '#000');
context.fillStyle = grd;
context.beginPath();
context.arc(_sh / 4, _sh / 4, 300, 0, 2 * Math.PI, false);
context.closePath();
context.fill();
context.globalAlpha = 0.6;
var grd2 = context.createRadialGradient(_sh / 2 + 100, _sh / 2 + 100, 10, _sh / 2 + 100, _sh / 2 + 100, 600);
grd2.addColorStop(0, '#009');
grd2.addColorStop(1, 'rgba(0,0,0,0)');
context.fillStyle = grd2;
context.beginPath();
context.arc(_sh / 2 + 100, _sh / 2 + 100, 600, 0, 2 * Math.PI, false);
context.closePath();
context.fill();
context.globalAlpha = 0.2;
var grd2 = context.createRadialGradient(_sh, _sh, 10, _sh, _sh, 600);
grd2.addColorStop(0, 'red');
grd2.addColorStop(1, 'rgba(0,0,0,0)');
context.fillStyle = grd2;
context.beginPath();
context.arc(_sh, _sh, 600, 0, 2 * Math.PI, false);
context.closePath();
context.fill();
context.globalAlpha = 1.0;
context.save();
this.backgroundData = new Image();
this.backgroundData.src = document.getElementById('c').toDataURL('image/png');
};
this.draw = function () {
if (this.backgroundData.src != 'data:,') { // hack for old android browser
context.drawImage(this.backgroundData, 0, 0);
} else {
context.fillStyle = "rgb(0,0,0)";
context.fillRect(0, 0, _sw, _sh);
}
}
}
function Logo() {
Obj.call(this);
this.load();
}
Logo.prototype = new Obj();
Logo.prototype.constructor = Logo;
Logo.prototype.load = function () {
var _p = "-27pti 9ee5 qpn -216au 56g2 qpm -22ixw a40s -25cbe 1fxn -1yrx3 -10v5 -1wobz 4pvu -1yor9 46mn -1tq1v 5ow -1qjlz 3mom -1v5j7 9kbw -1vix4 65ib -1plm8 9oe5 uohy -10ixy ut74 -uz0z cvh2 d1v3 -12846 634b -17pl5 4cbf -1ejsr n6j -17bmx -vmp -zzhj v85 -1bhnj 57ua -1dltq 7mxu -1ju3x cvbu -1ints 55us -1ea6y d05t -w0s4 5ifv -oyz8 -8ni -jkv1 l2d5 uxbh -5gka 9mye -jp8x -5c6o -2g3 4w2x ezwh an1c ewhs 919u r2x1 6olb 76th bynw 1cqn jua1 4b5r daxc 73jz jus5 -s1r rgm3 15ka wx0w 6uty qfk7 74iu ytip faho rypi l8jn t3mi fd78 x0fy nlzt rp0j tedc jy47 qdxp opc4 p1t7 jtqb vhg5 dfjs nsb3 10z22 17ikq 165xp 13ck6 19wyh 1c0jl 1a04b 1eytp 1i59k 1djcd 1d5yg 1j39c 1n6ds asao 1p614 49ru 1wheo 57u7 1tv6n 78nt 1sirl b947 1trwh glf 20uwv -rr6 24acw 50k0 20obl 4enu 26wix gjd 2b4lj 3zq4 274l6 8l0o 26gmg 6kjq 2cmax 8wh2 2b8y8 dl5v 246so bzqc 26hxs ah8y 273yo gv0h 20g0t is5d 1t5w6 fawp 1z1gk dei5 1uwwo kraa 1u2eo mouj 1py06 r4c8 1oj4t mgsd 1pp7w ibne 1vc41 p54v 1zxhe qapx 25x7m ub35 1zs0j vfha 1u0dv ucvy 24i7r p0xy 26mqo kmm3 2a4wl qwpb 2byv8 l12o".split(" ");
var _v = "0 1 2 3 4 5 6 7 2 8 9 5 10 11 5 12 13 5 14 15 5 16 17 5 18 19 5 20 21 2 22 23 5 24 25 2 24 26 2 20 26 2 27 28 2 29 30 2 29 28 2 27 31 2 32 33 5 34 35 5 36 37 5 38 39 5 40 41 5 42 43 5 44 45 5 46 47 2 48 49 5 50 51 2 50 28 2 46 28 2 52 53 5 54 55 5 56 57 2 54 58 2 56 55 5 59 60 2 61 58 2 62 55 5 63 55 5 63 58 2 59 58 2 64 65 2 66 67 2 68 69 2 70 71 5 72 73 5 74 75 5 76 77 5 78 79 5 80 81 5 82 83 5 84 85 5 86 87 2 88 89 2 90 91 2 92 93 2 94 95 2 96 97 2 98 99 2 100 101 2 102 103 2 104 1 2 105 4 5 106 7 2 107 9 5 108 11 5 109 13 5 110 15 5 111 17 5 112 19 5 113 21 2 114 23 5 115 25 2 115 26 2 113 26 2 116 117 2 118 119 5 120 121 5 122 123 5 124 125 2 126 127 5 128 129 5 130 131 5 132 133 5 134 135 5 136 137 5 138 139 2 140 141 5 142 143 2 144 145 2 146 147 2 148 149 2 150 151 2 152 153 2 154 155 2 156 157 2 158 159 2 160 161 2 162 163 2 164 165 2 166 167 2 168 169 2 170 171 2 172 173 2 174 175 2 176 177 2 178 179 2 180 181 2 182 183 2 184 185 2".split(" ");
var _f = "0 1 2 1 0 3 4 5 6 4 1 3 7 5 4 8 9 a 8 5 7 b 9 8 c 9 b d 9 c a 5 8 6 1 4 e f g h f e i f h j k l j m i n k j o p q o k n r p o s p r t p s q k o l m j m u i u f i v w x y w v w z 10 11 z w 12 z 11 13 z 12 14 z 13 10 x w 15 16 17 18 16 15 19 1a 1b 19 1b 18 1c 1a 19 1d 1a 1c 1e 1f 1d 1g 1h 1i 1g 1f 1e 1j 1h 1g 1k 1l 1m 1k 1h 1j 1n 1l 1k 17 16 1o 17 1l 1n 1o 1l 17 1m 1h 1k 1i 1f 1g 1f 1a 1d 1b 16 18 1p 1q 1r 1s 1q 1p 1t 1u 1v 1t 1q 1s 1w 1u 1t 1x 1y 1z 1x 1u 1w 20 1y 1x 21 1y 20 22 1y 21 1z 1u 1x 1v 1q 1t 24 25 26 24 27 23 28 25 24 29 2a 2b 29 25 28 2c 2a 29 2d 2e 2f 2d 2a 2c 2g 2e 2d 2h 2i 2j 2h 2e 2g 2k 2i 2h 2l 2m 2n 2l 2i 2k 2o 2m 2l 2p 2q 2r 2p 2s 2o 2t 2q 2p 2u 2v 2w 2u 2x 2t 2y 2v 2u 2z 30 2y 31 30 2z 30 2v 2y 2w 2x 2u 2x 2q 2t 2r 2s 2p 2s 2m 2o 2n 2i 2l 2j 2e 2h 2f 2a 2d 2b 25 29 26 27 24".split(" ");
var _c = "a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e a1a68e".split(" ");
this.read(_p, _v, _f, _c);
this.gen();
};
function Player() {
Obj.call(this);
this.load();
this.life = 1.0;
this.score = 0;
this.angle = 0;
this.fireCount = 1;
this.fireFrequency = 600;
this.fireTime = 0.0;
this.available_moves = 12;
this.position = -1;
this.depth = 0.8;
this.offset_angle = 0;
this.mouse_angle = 0;
this.hit = function () {
this.isHit = true;
this.hitTime = 0;
this.hitTimeDefine = _fps.lastStep * 10;
this.hitColor = 'rgb(255,0,0)';
this.life -= 0.1;
if (this.life < 0) {
opponent = [];
missiles = [];
op_missiles = [];
waves = 9;
generate_waves();
}
};
this.reset = function () {
this.life = 1.0;
this.angle = 0;
this.fireCount = 1;
this.fireFrequency = 1.0;
this.fireTime = 0.0;
this.position = -1;
this.depth = 0.7;
this.score = 0;
};
this.update = function (time) {
if (this.isHit) {
this.hitTime += time;
if (this.hitTime > this.hitTimeDefine) {
this.isHit = false;
}
}
this.fireTime += time;
if (this.fireTime > this.fireFrequency && missiles.length < this.fireCount) {
this.fireTime = 0.0;
missiles.push(new Missile(this.position, 0.9, 0.04, 'rgb(0,255,0)'));
}
var height = _sh > _sw ? _sw : _sh;
var lg_rad = ( height / 2) * 0.9;
var angle = 0;
var angle_deg = 0;
if (this.offset_angle != 0) {
if (this.offset_angle > 0) {
this.offset_angle -= this.available_moves / 2;
}
else {
this.offset_angle += this.available_moves / 2;
}
angle = (this.mouse_angle - this.offset_angle + 90);
angle_deg = this.mouse_angle - this.offset_angle;
}
else {
angle = (this.mouse_angle + 90);
angle_deg = this.mouse_angle;
}
var qx = _sx + gCosA(angle) * lg_rad;
var qy = _sy + gSinA(angle) * lg_rad;
this.move(qx, qy, 0);
this.rotate(155, 0, angle_deg);
this.draw();
context.globalCompositeOperation = this.isHit ? "source-over" : "lighter";
for (var w = 0; w < 4; w++) {
var r = 30 - (w * 4) - rnd(w * 5);
var jx = rnd(w * 5) + _sx + gCosA(angle) * (lg_rad * (1.2 + 0.06 * w));
var jy = rnd(w * 5) + _sy + gSinA(angle) * (lg_rad * (1.2 + 0.06 * w));
var gradient = context.createRadialGradient(jx, jy, 0, jx, jy, r);
gradient.addColorStop(0.0, "white");
gradient.addColorStop(0.8, "yellow");
gradient.addColorStop(1.0, "red");
context.beginPath();
context.fillStyle = this.isHit ? this.hitColor : gradient;
context.arc(jx, jy, r, 0, Math.PI * 2, false);
context.fill();
context.closePath();
}
context.globalCompositeOperation = "source-over";
}
}
Player.prototype = new Obj();
Player.prototype.constructor = Player;
Player.prototype.load = function () {
var _p = "0 -3cze vz2f byzb -373u -c3j -5kgw 6k38 -vmyv -byzb 6e7p o73 5kgw 10cxy -3jyv -s3i2 -107xi -1mc3 -zgll".split(" ");
var _v = "0 1 2 0 1 2 3 4 5 6 7 8 9 4 5 0 10 11 0 1 2 12 7 8 13 14 15 16 14 15 6 7 8 0 17 18 6 7 8 0 1 2 0 1 2 0 1 2 12 7 8 12 7 8 6 7 8 12 7 8".split(" ");
var _f = "0 1 2 5 7 a 7 2 8 8 b 7 7 5 2 5 0 2 a 7 b 3 4 5 4 6 5 4 3 9 9 b c".split(" ");
var _c = "fffbfb fffbfb ff0000 ff0000 006cff 006cff 080808 00071f 00071f 470300 470300".split(" ");
this.read(_p, _v, _f, _c);
this.gen();
};
function Cube() {
Obj.call(this);
this.load();
}
Cube.prototype = new Obj();
Cube.prototype.constructor = Cube;
Cube.prototype.load = function () {
var _p = "lfls -lfls -lflr lflr lflt".split(" ");
var _v = "0 1 1 0 1 0 1 1 0 1 1 1 0 0 2 3 0 4 1 0 0 1 0 1".split(" ");
var _f = "0 1 3 4 7 5 0 4 1 1 5 2 2 6 3 4 0 7 1 2 3 7 6 5 4 5 1 5 6 2 6 7 3 0 3 7".split(" ");
var _c = "ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff".split(" ");
this.read(_p, _v, _f, _c);
this.gen();
};
// Class without model
function staticOpponent(position, depth) {
Cube.call(this);
this.position = position;
this.depth = depth;
this.time = 0;
this.angle = 0;
this.update = function (time) {
if (this.isHit) {
this.hitTime += time;
if (this.hitTime >= this.hitTimeDefine) {
this.removed = true;
}
time = 0;
}
this.time += time;
var lg_rad = ( _sh / 2) * this.depth;
var angle = this.position * 2 * Math.PI / _player.available_moves;
var qx = _sx + Math.cos(angle) * lg_rad;
var qy = _sy + Math.sin(angle) * lg_rad;
this.angle += 1;
if (this.angle > 360) {
this.angle = 0;
}
this.distance = 126 - ( 120 * this.depth);
this.move(qx, qy, 0);
this.rotate(this.angle, 232, this.position * 360 / _player.available_moves - 90);
this.draw();
}
}
staticOpponent.prototype = new Cube();
staticOpponent.prototype.constructor = staticOpponent;
function movingOpponent(position, depth) {
Cube.call(this);
this.position = position;
this.depth = depth;
this.time = 0;
this.angle = 0;
this.update = function (time) {
if (this.isHit) {
this.hitTime += time;
if (this.hitTime >= this.hitTimeDefine) {
this.removed = true;
}
time = 0;
}
this.time += time;
if (!this.removed) {
if (this.time > 200) {
this.position++;
if (this.position >= _player.available_moves) {
this.position = 0;
}
this.offset = degToRad((360 / _player.available_moves) / 200);
this.offsetLimit = degToRad(360 / _player.available_moves);
this.currentOffset = 0;
this.time = 0;
}
}
var lg_rad = ( _sh / 2) * this.depth;
var angle = (this.position * 2 * Math.PI / _player.available_moves);
if (this.offset != this.offsetLimit) {
angle -= this.offsetLimit;
angle += (this.offset * this.time);
this.currentOffset = (this.offset * this.time);
if ((this.offset * this.time) >= this.offsetLimit) {
this.offset = this.offsetLimit;
this.currentOffset = this.offsetLimit;
}
}
var qx = _sx + Math.cos(angle) * lg_rad;
var qy = _sy + Math.sin(angle) * lg_rad;
this.angle += 1;
if (this.angle > 360) {
this.angle = 0;
}
var z = this.position * 360 / _player.available_moves - 90 + this.angle;
if (z > 360) {
z -= 360;
}
this.distance = 66 - ( 60 * this.depth);
this.move(qx, qy, 0);
this.rotate(90, 0, z);
this.draw();
}
}
movingOpponent.prototype = new Obj();
movingOpponent.prototype.constructor = movingOpponent;
movingOpponent.prototype.load = function () {
var _p = "-ik89 apsw 0 -9a45 -g2pc 9a45 ik8a g2pc lfls".split(" ");
var _v = "0 1 2 3 1 4 5 1 4 6 1 2 5 1 7 2 8 2 3 1 7".split(" ");
var _f = "0 5 1 2 5 3 4 5 6 1 5 2 3 5 4 6 5 0".split(" ");
var _c = "ffffff ffffff ffffff ff0000 ff0000 ff0000".split(" ");
this.read(_p, _v, _f, _c);
this.gen();
};
function shooterOpponent(position, depth) {
Cube.call(this);
this.position = position;
this.depth = depth;
this.time = 0;
this.fireTime = 0;
this.angle = 0;
this.update = function (time) {
if (this.isHit) {
this.hitTime += time;
if (this.hitTime >= this.hitTimeDefine) {
this.removed = true;
}
time = 0;
}
this.time += time;
this.fireTime += time;
if (!this.removed) {
if (this.time > 600) {
if (this.fireTime > 1200) {
op_missiles.push(new Missile(this.position, this.depth, -0.02, 'rgb(255,0,0)'));
this.fireTime = 0;
}
this.position++;
if (this.position >= _player.available_moves) {
this.position = 0;
}
this.offset = degToRad((360 / _player.available_moves) / 600);
this.offsetLimit = degToRad(360 / _player.available_moves);
this.currentOffset = 0;
this.time = 0;
}
}
var lg_rad = ( _sh / 2) * this.depth;
var angle = this.position * 2 * Math.PI / _player.available_moves;
if (this.offset != this.offsetLimit) {
angle -= this.offsetLimit;
angle += (this.offset * this.time);
this.currentOffset = (this.offset * this.time);
if ((this.offset * this.time) >= this.offsetLimit) {
this.offset = this.offsetLimit;
this.currentOffset = this.offsetLimit;
}
}
var qx = _sx + Math.cos(angle) * lg_rad;
var qy = _sy + Math.sin(angle) * lg_rad;
this.angle += 1;
if (this.angle >= 360) {
this.angle = 0;
}
var z = (this.position * (360 / _player.available_moves)) - 90 - (360 / _player.available_moves) + this.angle + Math.round(radToDeg(this.currentOffset));
if (z >= 360) {
z -= 360;
}
this.distance = 286 - ( 280 * this.depth);
this.move(qx, qy, 0);
this.rotate(0, 0, z);
this.draw();
}
}
shooterOpponent.prototype = new Cube();
shooterOpponent.prototype.constructor = shooterOpponent;
shooterOpponent.prototype.load = function () {
var _p = "r3b4 0 -r3b4 -ql4x -2md 23 -2c6a9 -2me 1ll7f -1lnrp -3xrfl 1liiz 24 3y9c7 2co6v r31j".split(" ");
var _v = "0 1 1 1 1 0 1 2 1 2 1 1 1 0 1 3 4 5 6 7 8 6 9 5 10 4 5 6 11 12 13 4 5 14 7 8 14 9 5 15 4 5 14 11 12".split(" ");
var _f = "3 1 4 1 0 4 0 1 2 2 1 3 6 5 9 7 6 8 5 6 7 8 6 9 a b c d b e b a e c b d".split(" ");
var _c = "ff0000 ff0000 ffffff ffffff ff0000 ff0000 ffffff ffffff ff0000 ff0000 ffffff ffffff".split(" ");
this.read(_p, _v, _f, _c);
this.gen();
};
function shieldOpponent(position, depth) {
Cube.call(this);
this.position = position;
this.depth = depth;
this.time = 0;
this.angle = 0;
this.hitCount = 3;
this.update = function (time) {
if (this.isHit) {
this.hitTime += time;
if (this.hitTime >= this.hitTimeDefine) {
this.hitCount -= 1;
if (this.hitCount == 0) {
this.removed = true;
} else {
this.isHit = false;
}
}
}
this.time += time;
var lg_rad = ( _sh / 2) * this.depth;
var angle = this.position * 2 * Math.PI / _player.available_moves;
var qx = _sx + Math.cos(angle) * lg_rad;
var qy = _sy + Math.sin(angle) * lg_rad;
this.angle += 1;
if (this.angle > 360) {
this.angle = 0;
}
// this.color = 'rgba(255,255,255,0.3)';
this.distance = 66 - ( 60 * this.depth);
this.move(qx, qy, 0);
this.rotate(this.angle, this.angle, this.position * 360 / _player.available_moves - 90);
this.draw();
}
}
shieldOpponent.prototype = new Cube();
shieldOpponent.prototype.constructor = shieldOpponent;
shieldOpponent.prototype.load = function () {
var _p = "-ik89 apsw 0 -apsw ik89 -lfls lfls".split(" ");
var _v = "0 1 2 0 3 2 2 1 0 2 3 0 4 1 2 4 3 2 2 5 2 2 1 4 2 3 4 2 6 2".split(" ");
var _f = "1 0 3 5 4 8 0 9 2 6 1 3 4 9 7 6 5 8 0 2 3 4 7 8 3 2 5 2 9 4 6 3 5 8 7 1 6 8 1 7 9 0 2 4 5 7 0 1".split(" ");
var _c = "336699 336699 336699 336699 336699 336699 336699 336699 ffffff ffffff ffffff ffffff ffffff ffffff ffffff ffffff".split(" ");
this.read(_p, _v, _f, _c);
this.gen();
};
function movingShieldOpponent(position, depth) {
Cube.call(this);
this.position = position;