@@ -51,7 +51,7 @@ var direction = [];
51
51
direction [ 0 ] = true ;
52
52
53
53
//Bullets size
54
- var bsize = 20 ;
54
+ var bsize = 12 ;
55
55
//Max number of bullets
56
56
var bmax = 10 ;
57
57
//Bullets speed
@@ -142,6 +142,7 @@ var livebar;
142
142
var bar1 ;
143
143
var bar2 ;
144
144
var heart ;
145
+ var pistol = [ ] ;
145
146
146
147
//Load Images
147
148
function preload ( ) {
@@ -151,6 +152,12 @@ function preload() {
151
152
bar1 = loadImage ( './assets/bar1.png' ) ;
152
153
bar2 = loadImage ( './assets/bar2.png' ) ;
153
154
heart = loadImage ( './assets/heart.png' ) ;
155
+ pistol [ 0 ] = loadImage ( './assets/pistol.png' ) ;
156
+ pistol [ 1 ] = loadImage ( './assets/pistol2.png' ) ;
157
+ pistol [ 2 ] = loadImage ( './assets/pistol3.png' ) ;
158
+ pistol [ 3 ] = loadImage ( './assets/pistol4.png' ) ;
159
+ pistol [ 4 ] = loadImage ( './assets/pistol5.png' ) ;
160
+ pistol [ 5 ] = loadImage ( './assets/pistol6.png' ) ;
154
161
}
155
162
156
163
function setup ( ) {
@@ -369,7 +376,22 @@ function drawObjects() {
369
376
}
370
377
371
378
function drawPlayer ( ) {
372
- if ( ! nodamage ) rect ( px , py , sx , sy ) ;
379
+ if ( ! nodamage ) {
380
+ rect ( px , py , sx , sy ) ;
381
+ if ( direction [ 0 ] && direction [ 2 ] ) {
382
+ image ( pistol [ 1 ] , px + 25 , py ) ;
383
+ } else if ( direction [ 0 ] && direction [ 3 ] ) {
384
+ image ( pistol [ 2 ] , px + 25 , py + 20 ) ;
385
+ } else if ( direction [ 1 ] && direction [ 2 ] ) {
386
+ image ( pistol [ 4 ] , px - 12 , py ) ;
387
+ } else if ( direction [ 1 ] && direction [ 3 ] ) {
388
+ image ( pistol [ 5 ] , px - 7 , py + 20 ) ;
389
+ } else if ( direction [ 0 ] ) {
390
+ image ( pistol [ 0 ] , px + 25 , py + 20 ) ;
391
+ } else if ( direction [ 1 ] ) {
392
+ image ( pistol [ 3 ] , px - 19 , py + 20 ) ;
393
+ }
394
+ }
373
395
else noDamage ( ) ;
374
396
}
375
397
@@ -611,25 +633,30 @@ function newBullet(enumber) {
611
633
if ( ! bullets [ i ] [ 5 ] ) {
612
634
if ( enumber === - 1 ) {
613
635
noshot ++ ;
614
- bullets [ i ] [ 1 ] = py ;
615
636
bullets [ i ] [ 2 ] = bsize ;
616
637
if ( direction [ 0 ] && direction [ 2 ] ) {
617
638
bullets [ i ] [ 0 ] = spos + px + sx ;
639
+ bullets [ i ] [ 1 ] = py + 10 ;
618
640
bullets [ i ] [ 3 ] = 0 ;
619
641
} else if ( direction [ 0 ] && direction [ 3 ] ) {
620
- bullets [ i ] [ 0 ] = spos + px + sx ;
642
+ bullets [ i ] [ 0 ] = spos + px + sx - 3 ;
643
+ bullets [ i ] [ 1 ] = py + 45 ;
621
644
bullets [ i ] [ 3 ] = 1 ;
622
645
} else if ( direction [ 1 ] && direction [ 2 ] ) {
623
646
bullets [ i ] [ 0 ] = spos + px ;
647
+ bullets [ i ] [ 1 ] = py + 10 ;
624
648
bullets [ i ] [ 3 ] = 2 ;
625
649
} else if ( direction [ 1 ] && direction [ 3 ] ) {
626
- bullets [ i ] [ 0 ] = spos + px ;
650
+ bullets [ i ] [ 0 ] = spos + px + 3 ;
651
+ bullets [ i ] [ 1 ] = py + 45 ;
627
652
bullets [ i ] [ 3 ] = 3 ;
628
653
} else if ( direction [ 0 ] ) {
629
- bullets [ i ] [ 0 ] = spos + px + sx ;
654
+ bullets [ i ] [ 0 ] = spos + px + sx + 10 ;
655
+ bullets [ i ] [ 1 ] = py + 25 ;
630
656
bullets [ i ] [ 3 ] = 4 ;
631
657
} else if ( direction [ 1 ] ) {
632
- bullets [ i ] [ 0 ] = spos + px ;
658
+ bullets [ i ] [ 0 ] = spos + px - 10 ;
659
+ bullets [ i ] [ 1 ] = py + 25 ;
633
660
bullets [ i ] [ 3 ] = 5 ;
634
661
}
635
662
bullets [ i ] [ 6 ] = false ;
@@ -754,7 +781,7 @@ function drawEnemies() {
754
781
function activeEnemies ( ) {
755
782
if ( enemiesCounter > - 1 ) {
756
783
for ( p = 0 ; p <= enemiesCounter ; p ++ ) {
757
- if ( ! enemies [ stageid ] [ drawingenemies [ enemiesCounter ] [ 2 ] ] [ 8 ] ) {
784
+ if ( ! enemies [ stageid ] [ drawingenemies [ p ] [ 2 ] ] [ 8 ] ) {
758
785
if ( enemiesCounter === 0 ) enemiesCounter -- ;
759
786
else {
760
787
drawingenemies [ p ] [ 0 ] = drawingenemies [ enemiesCounter ] [ 0 ] ;
@@ -852,7 +879,22 @@ function lifePoints(id, number) {
852
879
853
880
function noDamage ( ) {
854
881
ndcounter ++ ;
855
- if ( ndcounter % 10 === 0 ) rect ( px , py , sx , sy ) ;
882
+ if ( ndcounter % 10 === 0 ) {
883
+ rect ( px , py , sx , sy ) ;
884
+ if ( direction [ 0 ] && direction [ 2 ] ) {
885
+ image ( pistol [ 1 ] , px + 25 , py ) ;
886
+ } else if ( direction [ 0 ] && direction [ 3 ] ) {
887
+ image ( pistol [ 2 ] , px + 25 , py + 20 ) ;
888
+ } else if ( direction [ 1 ] && direction [ 2 ] ) {
889
+ image ( pistol [ 4 ] , px - 12 , py ) ;
890
+ } else if ( direction [ 1 ] && direction [ 3 ] ) {
891
+ image ( pistol [ 5 ] , px - 7 , py + 20 ) ;
892
+ } else if ( direction [ 0 ] ) {
893
+ image ( pistol [ 0 ] , px + 25 , py + 20 ) ;
894
+ } else if ( direction [ 1 ] ) {
895
+ image ( pistol [ 3 ] , px - 19 , py + 20 ) ;
896
+ }
897
+ }
856
898
if ( ndcounter === 60 * 1.5 ) {
857
899
nodamage = false ;
858
900
ndcounter = 0 ;
0 commit comments