forked from foumart/JS.13kGames.2019_SuperBunny
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
1466 lines (1322 loc) · 59.2 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
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>
<html>
<head>
<meta content="charset=utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=0" />
<meta name="mobile-web-app-capable" content="yes">
<link rel="manifest" href="manifest.json">
<link rel="icon" type="image/png" sizes="any" href="ico.png">
<title>Super Bunny Strikes Back!</title>
<meta name="description" content="Developed by Noncho Savov, FoumartGames © 2019. Submission in JS13K games. Inspired by Super Bunny by Vic Leone, DataMost Inc. 1983" />
<meta name="keywords" content="game, javascript, js, html5, js13k, canvas" />
<meta name="author" content="Noncho Savov" />
<meta name="copyright" content="Copyright © 2019 by Noncho Savov. All Rights Reserved." />
<meta name="application-name" content="Super Bunny Strikes Back!" />
<meta property="og:title" content="Super Bunny Strikes Back!" />
<meta property="og:type" content="game" />
<meta property="og:image" content="https://www.foumartgames.com/games/SuperBunny/icon.png" />
<meta property="og:url" content="https://www.foumartgames.com/games/SuperBunny/" />
<meta property="og:description" content="Super Bunny Strikes Back! JavaScript Web App by Noncho Savov. Submission in JS13K Games competition 2019. Inspired by Super Bunny - a game by Vic Leone, DataMost Inc. 1983" />
<meta property="fb:app_id" content="2460958557508879">
<meta name="twitter:card" content="summary" />
<meta name="twitter:title" content="Super Bunny Strikes Back!" />
<meta name="twitter:description" content="Super Bunny Strikes Back! JavaScript Web App by Noncho Savov. Submission in JS13K Games competition 2019. Inspired by Super Bunny - a game by Vic Leone, DataMost Inc. 1983" />
<meta name="twitter:image" content="https://www.foumartgames.com/games/SuperBunny/icon.png"/>
<!-- Coil -->
<meta name="monetization" content="$twitter.xrptipbot.com/FoumartGames">
<style>
div,canvas{position:absolute;box-sizing:border-box;cursor:pointer;}
.m{transform:scaleY(-1); opacity:.2}
.v{animation:move 1s;-webkit-animation:move 1s}
@keyframes move{from{opacity:0}}
@-webkit-keyframes move{from{opacity:0}}
#hero{top:352px;text-align:center;font:bold 14px arial;width:960px;}
.z{width:960px;height:540px;background-image:linear-gradient(#535,#323,#211,#312,#933,#111,#233,#346,#a57)}
.c{
image-rendering:-webkit-crisp-edges;
image-rendering:-moz-crisp-edges;
image-rendering:-o-crisp-edges;
image-rendering:pixelated;
}
.d{filter:drop-shadow(0 4px 0 #000);}
.e{width:100px;height:100px}
.f{width:80px;height:34px;left:875px;top:8px}
.s{background-color:#306bff;border:solid 6px;border-color:#59f #048 #036 #f6b}
.t{background-color:#d24;border:solid 5px;border-color:#d69 #a12 #702 #e8a}
.u{user-select:none;-moz-user-select:none;-webkit-user-select:none;-webkit-tap-highlight-color:transparent}
.g{-webkit-filter:grayscale(.9);filter:grayscale(.9);opacity:.3;}
</style>
</head>
<body class=u style=margin:0;overflow:hidden;background-color:#000>
<div id=game class=z>
<canvas class=c id=gridCanvas width=960 height=540></canvas>
<canvas class="c e" id=bunnyCanvas width=24 height=25></canvas>
<div class=f onclick=resetGame() style=left:920px;width:34px;></div>
<div class=f onclick=toggleFullscreen() style=left:835px></div>
<div class=f onclick=mute() style=top:50px;left:835px;width:120px;></div>
<div class=f onclick=pause() style=top:92px></div>
<div class=f onclick=nextStage() style=left:3px;width:36px;></div>
<div class=f onclick=prevStage() style=left:3px;width:36px;top:40px;></div>
<div id=leftbtn style=left:0;top:30%;width:40%;height:70%></div>
<div id=rightbtn style=left:60%;top:30%;width:40%;height:70%></div>
</div>
<div id=menu class=z></div>
<script>
"use strict";
// register SW
if("serviceWorker" in navigator) {
navigator.serviceWorker
.register("serviceworker.js")
.then(function() {
console.log("[Event] Service Worker registered successfully");
})
.catch(function() {
console.log("[Warning] Service worker registration failed")
});
} else {
console.log("[Warning] ServiceWorker not found in navigator");
}
// requestAnimationFrame polyfill
/*if (!window.requestAnimationFrame) {
window.requestAnimationFrame = ( function() {
return window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function(callback, element) {
window.setTimeout(callback, 1000/60);
};
})();
}*/
// SoundFX, sound effects
var FX = (function(){
var audioContext;
var oscTypes = ["sawtooth", "square", "triangle", "sine"];
var initialized;
// start frequency HZ
// frequency change in time + / -
// length (number of frames taking to play the sound)
// oscillator type 0 - 3
// starting delay (frames of silence delay before the sound starts)
// volume 0.0 - 1.0
function playSound(_freq, _incr, _length, _type, _delay, _vol){
if(!audioContext) return;// doh, are we on IE??
var oscillator = audioContext.createOscillator(); // instantiate a new oscillator
oscillator.type = oscTypes[_type];
var modulationGain = audioContext.createGain(); // instantiate modulation for sound volume control
modulationGain.gain.value = 0; // set the initial volume to 0 to prevent an ugly tick noise at the beginning
var i = 0;// frame counter
if(_delay) setTimeout(playTune, _delay); else playTune();
function playTune(){
if(!_vol) return
if(!i){
oscillator.connect(modulationGain).connect(audioContext.destination);
oscillator.start();
// make sure to stop the sound from playing in the background (when the tab is inactive)
oscillator.stop(audioContext.currentTime+(_length-i)/60);
} else modulationGain.gain.value = (i<4?.05*i*i:1-i/_length) * _vol * d.volume;
oscillator.frequency.value = _freq + _incr * i;
if(i++ < _length) requestAnimationFrame(playTune);
}
}
var d = {volume:1, initialized:initialized, start:function(){
try {
audioContext = new (
window.AudioContext ||
window.webkitAudioContext ||
window.mozAudioContext ||
window.msAudioContext ||
window.oAudioContext
)();
this.initialized = 1;
console.log("[Event] AudioContext initialized");
} catch(e){
console.log("[Warning] AudioContext not found",e);
}
}}
// stage starting sound, w:length
d.d=function(w,d){playSound(90, 9, 10+w*10, 1, d||0, 0.05); playSound(30, 3, 20+w*10, 1, d||0, 0.1); playSound(90, 5, 20+w*10, 2, d||0, 0.2)}
// 0:bunny die, 1-4:bunny jump
d.b=function(w){
playSound(220, -9 * (w*w||1), 40/w|0||1, 2, w*60, .2 - (w?.14+w/80:0));
playSound(90*(w||1), -9, 9, 1, w*60, .2 - (w?.14+w/80:0));
}
// level complete or super bunny jump
d.c=function(w,l,d){playSound(300-90*w*w, 9*w, (l||8)*w, 2-(w/2|0), (d||0)+(w-1)*(l/2||8), .1-w*.02);}
// custom //_type, _freq, _incr, _length, _delay, _vol
d.p=function(w,f,i,l,d,v){playSound(f||120, i||10, l||50, w||0, d, v||0.1);}
return d;
})();
var Tile = (function(){
return {
getTile:function(x, y, W, H, w, h, scale, speed, connecting, connected){
return {
X:x,
Y:y,
W:W,
H:H,
w:w,
h:h,
x:x * w * scale,
y:y * h * scale,
scale:scale,
size:h*scale,
speed:speed || 0,
connecting:connecting,
connected:connected,
count:0,
addUnit:function(frame, type, color, dir, sprite1, sprite2){
this.frame = frame;
this.type = type;
this.color = color;
this.dir = dir || 0;
this.sprite1 = sprite1;
this.sprite2 = sprite2;
if(sprite2) this.count = 1;
if(type>37) {this.W*=2;this.w*=2;}//double width unit (lion)
else this.connected = false;
if(type==32 || type==28) this.collectible = 1;//the fox got collectible
},
draw:function(ctx){
//22:boar, 24:fox>, 26:fox<>, 28:fox<+>, 30:beaver, 32:fox+>, 34:snake->, 36:empty, 38:lion
ctx.save();
ctx.translate(this.x+(this.type==17?12:32), this.y+2);
if(this.X && this.X <= L) {
// define base line color ["ffaa00","ff4455","33ff44","cccccc"]
ctx.fillStyle="#"+((this.sprite1)?(this.count)?this.collectible&&(this.type==28||this.type==32)||(yum&&this.type!=30&&this.type!=34&&this.type!=38&&!(this.type==28&&!this.collectible))?gridColors[0]:gridColors[1]:gridColors[2]:gridColors[3]);
// draw base line arrow
if(this.type>27 && this.type!=36 && this.sprite1 && ((!this.collectible&&this.type==28&&yum) || !yum || this.type==30 || this.type==34 || this.type==38)) {
// draw arrow tip
ctx.fillRect((this.dir?this.w*this.scale-this.scale*5:this.scale*2), this.h*this.scale-this.scale*3, this.scale, this.scale*2);
ctx.fillRect((this.dir?this.w*this.scale-this.scale*6:this.scale*3), this.h*this.scale-this.scale*4, this.scale, this.scale*3);
// draw flames and collectible
if(this.collectible || (!this.collectible && this.type==28 && yum) || (!yum||this.type==30 || this.type==34 || this.type==38)) {
if(!this.dir){
ctx.save();
ctx.scale(-1, 1);
ctx.translate(this.W>24?-191:-64, 0);
}
ctx.drawImage(bunnySprites[this.collectible?18:17], 2, 0, 14, 4, -4, this.h*this.scale-20, 56*(this.dir?1:-1), 12);
if(!this.dir) ctx.restore(); else {
ctx.save();
ctx.scale(-1, 1);
ctx.translate(-130, 0);
}
if(this.collectible) ctx.drawImage(bunnySprites[20+mode], 0, 0, 24, 6, this.dir?mode?0:36:mode?-8:28, this.h*this.scale-26, 72, 18);
if(this.dir) ctx.restore();
}
}
// draw base line
addShadow(ctx, 3);
if((!this.connected || !this.sprite1) && this.color!=12) ctx.fillRect(this.scale, this.h*this.scale-this.scale*2, this.w*this.scale-(this.connecting&&!this.frame?0:this.scale*4), this.scale);
addShadow(ctx);
// draw an enemy
if(this.sprite1) this.drawImg(ctx, this.count>=this.frame?this.sprite1:this.sprite2, this.dir, this.w, this.h, this.W, this.H, this.scale, 1, this.type==17? 1.25 : 1);
} else if(this.sprite1){
// draw ambient, as well as the bonus item, but only if it's still not taken (yum || sprite2 == arrow)
this.drawImg(ctx, this.sprite2?yum||this.sprite2==bunnySprites[19]?this.sprite2:this.sprite1:this.sprite1, this.X, this.w, this.h+1, this.W, this.H, this.scale, 1.5, 1);
}
ctx.restore();
if(this.count) {
this.count ++;
if(this.count > this.frame*2) {
this.count = 1;
if(this.type < 32 && this.type!=26) this.dir = !this.dir?1:0;// flip unit animation
}
}
},
drawImg:function(c, r, d, w, h, W, H, s, i, j){
c.scale(d?-j:j,j*j);
c.drawImage(r, (w-W)*s/2-(d?this.Y==2&&this.X==L+1?w*5.5:w:i>1?w*i:0), (h-H-2)*s/2, W*s*(this.Y==2&&this.X==L+1?1.2:d?-i:i), H*s);
c.scale(1,1);
}
}
}
};
})();
var hardWidth = 960;
var hardHeight = 540;
var width;
var height;
var gridColors = ["ffab00","ff4555","34ff44","cdcccc"]
var playerColors = [
"33333333bb33bbbbbbcc8866ddddddee9999ffffff",//bunny and kitty
"1a38a5305dff33bb33b1a2a2f5b8b8ff8235ffffff",//super bunny
"992255cc4477ffaa22aa9988f5b8b8ff7799ffffff",//super kitty
"f64000f66200f68200ff9610ffbf10ffda10ffe65d",//boom
"102313333333f64000f66200f68200ff9610ffd71e"//yum, level complete arrow
];
var px = [];
var P = "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@E@@@@@@@H}@Ho@@@@@@@@~Gxo@@@@@@@@vOxo@@@@@@@@pOx_@@@@@@@@p~xM@@@@@IIA@~hC@@@@IddL@p??@@@H[ke]IygyG@@Ykm|do}?BG@@Ym??d?l?o?HIk}|????}?uaLkm???o?C?Fg\\mdm?o}?@@@?_m|O}myo@@@hX}??iC?O[@@@X}}?Y@x?h]@@@k?_@@@}Gn@@@@?m}G@pF@@@@@}??~@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@HE@hE@@@@@@@p?@?E@@@@@@@p~A?E@@@@HII@~GoA@@@@addAvO_@@@@I[m?LpG]@@@H[kgglp~C@HAYk}?g|k??@aL[mg???mgyGg\\km????o?BG?_md|???o?o?xX?|o}}?E}?w@X???]}o@@?F@@{??C?G@@@@@y??oh?X@@@@@h?E@H?h@@@@@@}?G@}GG@@@@@x?~@x~p@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@hEiE@@@@@@@@}?Oi@@@@@@@@pv?MC@@@@@@@@pvo}G@@@@@@@A@~??@@@@@IIdDx?}@@HAH[dmm|oLG@aLYkm|dm?WGHglk?|?do}oGx?]m?????xoF@?h}d????@w@@@he?}m}?@@@@@m??iK?G@@@@x???Xy?E@@@@x??o@?G@@@@@xo?E@?@@@@@@xG@@p?@@@@@@xG@@xG@@@@@@~G@@@@@@@@@@?@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@xG@@@@@@@@@@u?@@@@HI@@@@hvG@@@ydA@@@@u~@@@?gDII@@@vE@@x?O[cI@@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vf@yjb}AR@HblmBH@@@@vvv^s@@HgelO@@@jdUUB@@@@sF@@@@@BPdmUA@@RelUB@@@@@@@@@@UQAUmjB@@@PedUU@@@@@@@@kJH@jeU@@@@@jemjB@@@@@@pKSA@jlU@@@@@@mRUE@@@@@@@@YDjmlB@@@@PjUBjJ@@@@@@@clllMU@@@@PjmUQQ@@@@@@@@CHQ{@YB@@XZTIm@@@@";
P.replace(/./g, function(a){
let q=a.charCodeAt()
px.push(q&7)
px.push((q>>3)&7)
});
var i,j,k,l,m,n,o,p = 0;
var sprites = [];
var bunnySprites;
// initialize sprites data
j = px.length/576
for(i = 0; i < j-4; i++){
sprites.push(px.splice(0,576))
}
sprites.push(px.splice(0,1152))
sprites.push(px.splice(0,1152))
var scale = 4; //scale multiplier
var H = 24; // sprite width
var W = 24; // sprite height
var board;
var level;
var L = 5; // collumns
var R = 5; // rows
var running = 1;
var end;
var win;
var fff;
var monet; // monetization : subscribed
var master; // game has been cleared, 1:super bunny, 2:super kitten
var mode = 1;
var lives = -1;
var collects;
var time;
var globaltime;
var besttime;
var score = 0;
var tscore = 0;
var hiscore = 0;
var bonus;
var multi = 10;
var oldmulti;
var dir = 1; // bunny facing direction 0:left, 1:right
var posX = 0; // bunny position, linked to the board collumn position, integer 0-R
var bunnyY; // bunny position real y
var jump; // jump frames, 0:idle
var jumpfps = 2; // jump frame skipping
var bunnyDieY;
var dieY;
var callback;// function called after bunny die animation
var yum;
var boom;
var enemyColors = [,
"1cac006dd200886644c3f409de4e00fa651dff8421",//1 - carrot
"11ddff2244662255cc4488ccdd7d16f5a83bfac34d",//2 - fish
"803e0ccc5800e7b2b2ee9653f57a1dfafafaff1900",//3 - orange
"813e0cc75600d8b7a9ef9653f67a1dfcfbfafb4936",//4 - orange 2
"972900cc3c00ddb3acff793cf85e17efefeffa0313",//5 - dark orange/red
"5b4146b25b76f0e1efe5a3a3cb8c8ce4b3e0936f6f",//6 - pink, old snake
"625329a98d40d9c7bfd6ba90d69e66f9f9f9bf6428",//7 - ocher
"7b1d38cf665bf7dae4e9c2bce29d94fefefee42e59",//8 - pink
"6544668f4e90e1dae6be7dc0b361b2fdfdfdc33f9c",//9 - violet
"444440777770e8b2b2ccccc0aaaaa0eeeee0cf3838",//10 - grey with red hilight, snake
"006c0a00a00faded8554fc6510dd21f1fef02cc400",//11 - green snake
"0b4d830483d505edf44cd5f21bb1f0f5f5f551fffb"//12 - blue snake
];
var levels;
var speeds;
var offsets;
var spaces;
var gridContext = gridCanvas.getContext("2d");
var bunnyContext = bunnyCanvas.getContext("2d");
gridContext.imageSmoothingEnabled = bunnyContext.imageSmoothingEnabled = false;
window.onload = initGame();
function initGame(e){
console.log("[Event] Game initialized");// in "+screen.orientation.type+" mode");
window.focus();
//screen.orientation.lock("landscape-primary").catch(function(error){console.log("[Warning] Screen orientation locking is not supported")});
//screen.orientation.addEventListener("change", resize, false);
window.addEventListener("resize", resize, false);
resize();
e = /Android|iPhone|iPad|iPod/i.test(navigator.userAgent)?"touchstart":"mousedown";
game.style.backgroundImage="linear-gradient(#535,#323,#181618,#346,#a57)";
game.addEventListener("click", gameClick);
leftbtn.addEventListener(e, leftClick, {passive:false});
rightbtn.addEventListener(e, rightClick, {passive:false});
document.addEventListener("keydown", keyDownHandler);
document.addEventListener("fullscreenchange", fullscreenCheck);
if(document.monetization){
console.log("[Event] Web Monetization",document.monetization.state);
if(document.monetization.state=="started") monet = 1;
else document.monetization.addEventListener("monetizationstart",
function(){
monet = 1;
if(lives<0) level = -1;
}
);
} else console.log("[Warning] Web Monetization not found");
// generate player sprites (bunny/kitty colors depending on mode)
bunnySprites = [];
for(i = 0; i < 22; i++){
bunnySprites.push(getUnit(i, i>16 ? (i>19?1:3)+i%2 : i>11 ? 1+mode : 0, i>19 ? enemyColors : playerColors));
}
createMenu();
}
function resize(e){
width = document.documentElement.clientWidth;
height = document.documentElement.clientHeight;
if(e) console.log("[Event] Resized, new dimensions:",width,height);
e = width/hardWidth;
e = height/width > hardHeight/hardWidth ? e : height/hardHeight < e ? height/hardHeight : e;
updatePosition(menu, (width-hardWidth)/2, (height-hardHeight)/2, e, 1);
updatePosition(game, (width-hardWidth)/2, (height-hardHeight)/2, e, 1);
}
function updatePosition(c,x,y,s,z){
c.style.transform = "translateX("+x+"px) translateY("+y+"px)"+(s?" scale"+(z?"":"X")+"("+s+")":"");
return c;
}
function tweet(){
createWindow(width/2, height/2, "https://twitter.com/intent/tweet?text="+encodeURIComponent("I achieved a"+(master==2?" Super":master?" Master":"")+" Hi-Score of "+hiscore+" points in Super Bunny Strikes Back! Can you beat it? Game by @FoumartGames for @js13kGames #js13k "+window.location.href), "html", "resizable=yes,scrollbars=no");
}
//window open
function createWindow(...r){
var a,j,w,h,i=0
a = []
for(;i < r.length; i++) a.push(r[i])
w = a.shift()
h = a.shift()
a[2] = ('width=' + w + ',height=' + h + ',' +a[2])
try{
j = window.open.apply(this, a)
j.addEventListener("load", j.focus, false)
} catch(e) {
console.log("[Warning] Could not open a new window for Tweet")
}
}
// draw Title Screen
function createMenu(){
menu.innerHTML="<div id=logo class=d onclick=startNewGame()></div><div id=hero><div style=top:154px>"+(hiscore?"<a href=javascript:tweet()>Tweet</a> your"+(master==2?" Super":master?" Master":"")+" Hi-Score: "+hiscore+", won in "+(besttime/3600|0)+"."+(besttime/60%60|0)+" mins. ":"")+(monet?"Coil Subscription detected":"Subscribe in <a href=https://coil.com/ target=_blank>Coil.com</a> to unlock "+(master?"cheats":"Super Bunny"))+"!<br/> Developed by Noncho Savov, <a href=https://www.foumartgames.com/ target=_blank>FoumartGames</a> 2019. Submission in JS13K games. Inspired by Super Bunny by Vic Leone, DataMost Inc. 1983</div></div>";
var titleArr = [
[[4,5,,-2,,3,,3]],[[4,5,-.5,-1,,3,,3]],
[[12,4,,,3,,3,1],[12,4,,6.5,1,3,1,3],[14,4,-2,14,3,1,3],[3.5,3.5,.5,3.5,1,1,1,1,1,,1],[4,4.5,7.5,10,1,1,1,1,1,,1]],
[[10,4,,14,1,1,3,3],[4.5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1],[3.5,5,3.5,17.5,1,1,,2.5,1]],
[[4,5,-1,-1,3,,3]],[[4,5,-.5,-2,3,,3]]
];
drawTitle(titleArr, -13, 25, 7.5, "s");
titleArr = [
[[7,8,4,1,,3]],
[[4,5,,4,,3]],
[[8,6,,3,3,3]],
[[4,4,,5,3,3]],
[[4,9,,,3]],
[[4,9,-.2,,,3]],
[[22,3,9,2,3,3,,,,,1],[36,4,,5,3,3]],
[[27,4,,5,3,3]],
[[5,4,,5,3,3]],
[[3,8,,1,2]],
[[4,10,-.5,-1,3,3]],
[[5,6,,3,3]]
];
drawTitle(titleArr, -37, 272, 8, "t m");
drawTitle(titleArr, -37, 240, 8, "t");
var txt = getUnit();// using getUnit here only to generate a canvas for the title text
logo.appendChild(txt);
var txtCtx = txt.getContext("2d");
updatePosition(txt, 990, 150, 3.6, 1).style.letterSpacing = "1.5px";
m = 0;
animateMenu();
var bunnyhead, bunnyhead2, bunnybody, kittyhead, kittyhead2, kittybody;
function animateMenu(){
if(!level) {
m++;
if(m==20) {
txt.className = "c v";
drawTitleTxt();
}
if(m==40) {
kittyhead = hero.appendChild(getUnit(15,2,playerColors,0,12));
updatePosition(kittyhead, -190, -26, 1.6, 1).className = "c e v";
kittyhead2 = hero.appendChild(getUnit(15,2,playerColors,0,12));
kittyhead2.getContext("2d").clearRect(0,0,24,24);
kittyhead2.getContext("2d").drawImage(bunnySprites[15], 0, H/2, W, H/2, 0, 12 -H/2, W, H/2);
kittyhead2.style.visibility = "hidden";
updatePosition(kittyhead2, -190, -26, 1.6, 1).className = "c e v";
kittybody = hero.appendChild(getUnit(12,2,playerColors))
updatePosition(kittybody, -190, -26, 1.6, 1).className = "c e v";
kittybody.onclick = function(){startNewGame(1)};
}
if(m==50){
bunnyhead = hero.appendChild(getUnit(14,1,playerColors,0,12))
updatePosition(bunnyhead, -395, -14, 2, 1).className = "c e v"+(!monet&&!master ? " g d" : "");
bunnyhead2 = hero.appendChild(getUnit(14,1,playerColors,0,12));
bunnyhead2.getContext("2d").clearRect(0,0,24,24);
bunnyhead2.getContext("2d").drawImage(bunnySprites[14], 0, H/2, W, H/2, 0, 12 -H/2, W, H/2);
bunnyhead2.style.visibility = "hidden";
updatePosition(bunnyhead2, -395, -14, 2, 1).className = "c e v"+(!monet&&!master ? " g d" : "");
bunnybody = hero.appendChild(getUnit(12,1,playerColors))
updatePosition(bunnybody, -395, -14, 2, 1).className = "c e v"+(!monet&&!master ? " g d" : "");
if(monet || master) bunnybody.onclick = startNewGame;
}
if(m==60){
updatePosition(hero.appendChild(getUnit(34,8,enemyColors)), 320, 0, 1.8, 1).className = "c e v";
updatePosition(hero.appendChild(getUnit(35,8,enemyColors)), 320, 0, 1.8, 1).className = "c e v";
hero.lastChild.style.visibility = "hidden";
}
if(m==120){
hero.lastChild.style.visibility = "visible";
hero.lastChild.previousSibling.style.visibility = "hidden";
}
if(kittyhead && bunnyhead){
if((m/8|0) % 2 == 0){
kittyhead.style.visibility = "visible";
kittyhead2.style.visibility = "hidden";
} else {
kittyhead.style.visibility = "hidden";
kittyhead2.style.visibility = "visible";
}
if((m/12|0) % 2 == 0){
bunnyhead.style.visibility = "visible";
bunnyhead2.style.visibility = "hidden";
} else {
bunnyhead.style.visibility = "hidden";
bunnyhead2.style.visibility = "visible";
}
}
if(m>140) {
m = 60;
hero.lastChild.style.visibility = "hidden";
hero.lastChild.previousSibling.style.visibility = "visible";
txtCtx.clearRect(0, 0, txt.width, txt.height);
drawTitleTxt();
} else if(m>85){
txtCtx.globalAlpha = .05;
txtCtx.fillText("play", 150, 125);
txtCtx.globalAlpha = 1;
}
requestAnimationFrame(animateMenu);
} else if(level == -1) {
level = 0;
createMenu();
}
}
function drawTitleTxt(){
addShadow(txtCtx, 1, 1, "#935")
txtCtx.fillStyle = "#fab";
txtCtx.font = "bold 16px Lucida Console";
txtCtx.fillText("STRIKES BACK", 90, 70);
addShadow(txtCtx)
}
}
function drawTitle(titleArr, baseLeft, baseTop, scale, className){
var piece;
var segment;
var pieceWidth;
for(var i = 0; i < titleArr.length; i++){
pieceWidth = 0;
for(var j = 0; j < titleArr[i].length; j++){
segment = titleArr[i][j];
if(pieceWidth < (segment[0]||0)+(segment[2]||0)) pieceWidth = (segment[0]||0)+(segment[2]||0);
piece = document.createElement("div");
logo.appendChild(piece).className = className;
piece.style.width = ((segment[0]*scale)||0)+"px";
piece.style.height = ((segment[1]*scale)||0)+"px";
piece.style.left = (baseLeft+((segment[2]*scale)||0))+"px";
piece.style.top = (baseTop+((segment[3]*scale)||0))+"px";
piece.style.borderRadius = ((segment[4]*scale)||0)+"px "+((segment[5]*scale)||0)+"px "+((segment[6]*scale)||0)+"px "+((segment[7]*scale)||0)+"px";
if(segment[8]) piece.style.borderTop = "none";
if(segment[9]) piece.style.borderRight = "none";
if(segment[10]) piece.style.borderBottom = "none";
if(segment[11]) piece.style.borderLeft = "none";
}
baseLeft += (pieceWidth*scale) + scale;
}
}
function startNewGame(e){
if(!FX.initialized) FX.start();// start soundFX
menu.style.display = "none";
if(e==1) mode = 1;
else if(e) mode = 0;
lives = mode?9:6;
level = 13;
score = 0;
yum = 0;
boom = 0;
jump = 0;
collects = 9;
globaltime = 0;
// 03 orange red eyes
// 04 light orange
// 05 dark orange
// 06 soft pink (less contrast than 08)
// 07 light ocher
// 08 light brown (contrast)
// 09 violet
// 10 grey
// 11 green
levels = [,
//22:boar, 24:fox<>, 26:fox>, 28:<-fox->, 30:<beaver>, 32:fox->, 34:snake>, 36:empty, 38:lion
//[posX, posY, animation speed, color type, direction facing]
[[1,2,40,32,4,1],[2,3,15,22,6],[3,0,72,24,10],[4,1,45,32,5,1],[5,2,12,22,8]],
[[1,1,22,22,4,1],[3,0,72,24,10],[2,2,18,22,8],[3,3,35,32,3,1],[4,0,58,28,9],[5,4,64,24,7]],
[[1,3,45,28,9],[3,0,12,22,3],[3,2,14,22,4],[3,4,13,22,5],[4,2,30,34,10],[5,0,50,24,8],[5,3,50,22,6]],
[[1,3,40,32,4],[2,0,12,22,8],[3,1,30,34,5],[3,3,36,28,9],[4,2,20,34,11,1],[4,0,30,24,7,1],[5,0,50,24,10],[5,3,50,22,6]],
[[1,3,55,24,6,1],[2,0,60,26,8],[3,4,60,34,10],[3,1,35,32,3,1],[4,3,20,22,7],[4,1,50,28,9],[5,3,100,30,5]],
[[1,0,40,26,7],[2,3,40,34,10],[2,1,30,28,9],[3,0,30,38,8],[4,0,0,36],[4,2,30,30,11],[5,1,10,22,6],[5,4,50,34,4,1]],
[[1,2,28,34,10],[2,4,36,30,11],[3,3,28,30,9],[3,0,26,30,8], [4,0,5,17,12],[4,1,4,17,12],[4,2,6,17,12],[4,3,3,17,12],[4,4,7,17,12], [5,1,28,34,7,1],[5,3,40,30,5,1]],
[[1,0,40,30,5],[2,3,40,34,10,1],[2,1,40,28,9],[3,3,30,38,8],[4,3,0,36],[5,1,10,22,6],[5,4,50,34,4,1]],
[[1,3,60,34,5,1],[2,1,20,38,6],[3,1,0,36],[2,3,30,38,10,1],[3,3,0,36],[1,1,50,34,4],[4,0,24,28,9],[4,1,16,22,7,1],[5,1,50,34,11,1]],
[[1,1,35,34,6,1],[1,3,42,34,10,1],[2,3,31,30,5,1],[3,3,70,28,9],[4,3,29,30,8,1],[5,0,25,26,3,1],[5,2,50,26,4]],
[[1,0,10,22,3],[1,3,17,22,8],[2,1,12,22,6],[2,4,11,22,10],[3,2,15,22,9],[3,4,13,22,4],[4,3,16,22,11],[4,0,15,22,5],[5,4,13,22,7]],
[[1,3,30,38,8],[2,3,0,36],[1,0,30,38,5],[2,0,0,36],[4,2,30,38,6],[5,2,0,36],[4,4,30,38,9],[5,4,0,36],[3,1,28,34,10],[3,4,25,34,7,1]],
[[1,3,25,30,8,1],[2,0,20,30,7],[3,3,50,28,9],[4,2,40,34,6],[4,4,50,34,10],[5,1,50,38,5],[5,0,50,30,3],[5,2,62,30,4],[3,0,0,20+mode,1+mode]]
]
speeds = [,
[-1, 1, -1, 1, -1],
[-1.5, 1, -1, 1, -1],
[2, -1, -1, 1.5, -1.5],
[1.5, -1.5, 1, 1, -1.5],
[-1, 1, -1.5, 1, -1],
[2, -1.5, 1, 1, -2],
[2, -1.5, 2, 30, -2],
[1, -1.5, 1, 1, 2],
[1.5, -1.5, -1.5, 2, -1],
[2, -2, 1, 2, -2.5],
[2.5, -2.5, 3, -3, 3.5],
[1.5, 1.5, 2.5, -1.5, -1.5],
[1.75, -1.75, 2, -2, 0]
]
offsets = [,
[50, -20, -75, -60, -50],
[40, -20, -75, -50, -75],
[0, -50, -50, 50, 0],
[0, 0, -50, -50, 0],
[-25, -50, 0, 0, 0],
[0, -50, 0, 0, 50],
[-25, -50, 0, 0, 0],
[0, -50, 0, 0, 50],
[0, 0, 0, -50, 50],
[-90, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, -50, -25, 0, -3]
]
spaces = [,
[14, 14, 14, 14, 14],
[12, 12, 14, 14, 14],
[14, 12, 12, 13, 12],
[14, 14, 12, 12, 10],
[13, 12, 11, 13, 13],
[10, 10, 10, 10, 10],
[13, 12, 11, 9, 13],
[10, 12, 10, 10, 11],
[10, 8, 8, 12, 12],
[9, 10, 12, 10, 10],
[10, 10, 10, 10, 10],
[9, 9, 12, 9, 9],
[10, 8, 12, 10, 16]
]
startGame();
}
function startGame(){
console.log("[Event] Start stage "+level);
if(time) globaltime += time;
time = 0;
multi = 10;
createLevel();
resetBunnyPosition(2,90);
bunnyY = board[0][2].y;
updateBunny(mode*6);
requestAnimationFrame(draw);
}
function getUnit(id,clr,colors,ctx,h){
var unit;
var WW = W*(id>37?2:1);//double
var HH = H;
if(!id && lives<0){// zero id is used here to get a canvas for the title text
WW = 775;
HH = 135;
}
if(!ctx){
unit = document.createElement("canvas");
unit.width = WW;
unit.height = HH+1;
ctx = unit.getContext("2d");
addShadow(ctx, 1)
}
if(!id && lives<0) return unit;//returning the canvas for the title text
if(id<0){
for(var y = 0; y < H/2; y++){
var w = id==-4&&y<4 ? 15-y*4 : id==-2&&y>H/2-4 ? 24-(H-y) : id==-3 ? 11+Math.random()*3 : Math.random()*(level==11?2:5);
for(var x = 0; x < W/2 - w; x++){
// random ambient color generation, with regards to the current level, kind of repressenting the four seasons
var red = (16+level*16+(Math.random()*128|0));
var green = ((level<8?128-level*8+Math.random()*(128+level*16)|0:162)-level*(level-1))
var blue = (Math.random()*(42-level*2)|0)
if(blue<16&&level<9) blue = 16
if(level == 8 || level == 9) green = 16+Math.random()*64|0
if(level == 11) green = 212
if(level == 12) {green = 128+(Math.random()*128|0); blue = 128+(Math.random()*128|0);}
if(red>255 || level == 10) {red = level==11? 0 : 255; green = level<9||level==11? 0 : 255; blue = level>10? 0 : 255}
ctx.fillStyle="#"+red.toString(16)+green.toString(16)+blue.toString(16)
ctx.fillRect(x*2, y*2, 1+Math.random()*2, 1+Math.random()*2);
}
}
if(!clr || level == 13) return unit;
// generate a carrot/fish item
id = 20+mode;
clr = 1+mode;
}
// draw the unit
for(k=0; k<(h||H); k++){
for(l=0; l<WW; l++){
if(sprites[id][k*WW+l]){
ctx.fillStyle="#"+(colors||enemyColors)[clr].substr(6*(sprites[id][k*WW+l]-1),6)
ctx.fillRect(l,k,1,1)
}
}
}
addShadow(ctx)
return unit;
}
// buffer the level
function createLevel(){
board = [];
while (board.length < L+2) board.push([]);
var tile;
var speed, width, height, offset;
for(i = 0; i < board.length; i++){
speed = speeds[level][i-1];
offset = offsets[level][i-1];
width = W+8;
height = H + (i&&i<board.length-1 ? spaces[level][i-1] : 0);
for(j = 0; j < R; j++){
tile = Tile.getTile(i, j, W, H, width, height, scale, speed, speed==speeds[level][i], speed==speeds[level][i-2]);
if(!i || i > L){
tile.addUnit(-1, 0, 0, 0, getUnit(-j-1,(i&&j==2)?2:0), (i&&j==2) ? getUnit(-j-1) : 0);// ambient with/without an item
} else
for(m = 0; m < levels[level].length; m++){
if(levels[level][m][0] == i && levels[level][m][1] == j)
tile.addUnit(// add an enemy animal
levels[level][m][2],//frame
levels[level][m][3],//type
levels[level][m][4],//color
levels[level][m][5],//dir
getUnit(levels[level][m][3],levels[level][m][4]),//sprite1
levels[level][m][3] == 20 || levels[level][m][3] == 21 ? 0 : getUnit(levels[level][m][3]+1,levels[level][m][4])//sprite2
);
}
tile.draw(gridContext);
board[i].push(tile);
if(offset) tile.y += offset;
}
}
drawLevel();
drawUserInterface();
}
// draws the entire level + the ambient rear parts
function drawLevel(){
gridContext.clearRect(0, 0, gridCanvas.width, gridCanvas.height);
for(i = 0; i < board.length; i++){
for(j = 0; j < R; j++){
board[i][j].draw(gridContext);
}
}
}
// main game loop
function draw(){
if(lives<0) return;
time ++;
oldmulti = multi;
multi = 1 + ((60 - (time/60))/6|0)
if(multi<1) multi = 1;
gridContext.clearRect(156, 0, gridCanvas.width-320, gridCanvas.height);
for(i = 1; i < board.length-1; i++){
for(j = 0; j < R; j++){
board[i][j].y += board[i][j].speed;
if(board[i][j].y > hardHeight) board[i][j].y -= board[i][j].size*R;
else if(board[i][j].y < 0 - board[i][j].size) board[i][j].y += board[i][j].size*R;
}
}
for(i = 1; i < board.length-1; i++){
for(j = 0; j < R; j++){
board[i][j].draw(gridContext);
}
}
if(board[posX][0].speed && !jump && !p) bunnyY += board[posX][0].speed;//move bunny vertically when not in a jump
if(bunnyY<-40 || bunnyY > 500) killBunny();
updatePosition(
bunnyCanvas,
board[posX][0].x+scale*10+((jump+1)/jumpfps|0)*scale*(dir||-1)*6.4,
bunnyY,
dir||boom>1||tscore?1:-1
)
if(jump) {// bunny is flying
if(jump < 5) {
FX.b(jump)
if(yum) FX.c(jump)
}
if(jump < 7*jumpfps) jump ++;
if(!p) updateBunny(yum?13:mode*6+(jump/jumpfps|0));
} else if(p){
p+=2;
if(p>2) p=0;
updateBunny(yum?12:mode*6+p);
}
if(boom > 1){// bunny is zapping an enemy
boom --;
if(boom==1 && bonus) {
score += bonus;
bonus = 0;
tscore = 0;
drawUserInterface(1);
}
updateBunny(boom==1?yum?12:mode*6:18, boom>1?bonus:0, 1);
} else
if(yum > 1){// bunny is eating powerup
yum --;
if(yum==1 && bonus) {
score += bonus;
bonus = 0;
tscore = 0;
drawUserInterface(1);
}
updateBunny(yum==1?12:18, yum>1?bonus:0, 2);
} else
if(jump > 5*jumpfps) {// bunny is landing after a jump
jump = 0;
p = 0;
// check where the bunny is jumping to
// examine a vertical line of pixels and
// compare the colors found with all available color pallets
// to determine where the bunny is landing
var oldX = posX;
posX += (dir||-1);
if(posX == L+2){// transition to next stage - next level function
FX.d(6,90)
level++;
posX = 0;
startGame();
return;
}
j = new Uint32Array(gridContext.getImageData((board[posX][0].x+scale*30), bunnyY, 1, 100).data.buffer);
n = 0;
m = 0;
for(i = 0; i < j.length; i += 3){
if(j[i]){
o = j[i].toString(16);//construct color hex for comparision
o = o.substr(6,2)+o.substr(4,2)+o.substr(2,2);
if(i>15+mode*10&&i<90-mode*15) {// check safe zone pixels (center of a platform)
for(k = 1; k < enemyColors.length; k++){
if(enemyColors[k].indexOf(o)>-1 && o && !n && !m) n = k;// enemy hittest detected - jumped on an enemy
}
}
if(gridColors.indexOf(o)>-1){// platform hittest detected
n = 0;
m = board[posX][0].speed;
// check pixels in the top and bottom zones to adjust bunny position
if(i>=90-mode*15) {p = 1; bunnyY -= 100 - i - (m*(m>0?1:6))|0;}// legs hit
else if(i<=15+mode*10) {p = 1; bunnyY += i + (m*(m>0?6:-1))|0;}// head hit
else n = -1;// body hit is deadly, no adjustment
if(p && !m) n = -1;
jump = 5*jumpfps-1;
m = 1;
if(p || n==-1) {posX = oldX; break;}
}
}
}
if(!m){
if(posX==L+1) {
bunnyY = board[L+1][2].y;
if(!yum){
p = 0;
if(board[L+1][2].sprite2 == bunnySprites[19]) jump = 1;//arrow hittest detected - jump to next stage
else n = 1;//powerup hittest detected
}
} else if(!posX) bunnyY = board[0][2].y;
}