@@ -163,8 +163,12 @@ var tcounter = 0;
163
163
var maxtime = minutes * 60 + seconds ;
164
164
165
165
//Number of shot
166
- var noshot = 0 ;
167
- var score = [ ] ;
166
+ var noshot = 1 ;
167
+ var score = 0 ;
168
+ var points = 0 ;
169
+ var points2 = 0 ;
170
+ var currentscore = 0 ;
171
+ var generalscore = 0 ;
168
172
169
173
var drawingenemies = [ ] ;
170
174
for ( l = 0 ; l < 4 ; l ++ ) drawingenemies [ l ] = [ ] ;
@@ -370,8 +374,8 @@ function stageCompleted() {
370
374
textSize ( 50 ) ;
371
375
fill ( '#000000' ) ;
372
376
text ( "Congratulations!!!" , 500 , 100 ) ;
373
- text ( "Your score:" , 575 , 175 ) ;
374
- text ( score , 640 , 250 ) ;
377
+ text ( "Your current score:" , 490 , 175 ) ;
378
+ text ( generalscore , 640 , 250 ) ;
375
379
text ( "Level " + ( stageid + 1 ) + " Completed" , 500 , 400 ) ;
376
380
text ( "Press SPACE to Continue" , 500 , 700 ) ;
377
381
fill ( '#FFFFFF' ) ;
@@ -589,7 +593,7 @@ function gravity(maxy, maxid) {
589
593
} else {
590
594
if ( maxid === maxp [ stageid ] - 1 ) {
591
595
completed = true ;
592
- countPoints ( ) ;
596
+ countPoints ( 1 ) ;
593
597
}
594
598
}
595
599
}
@@ -818,8 +822,8 @@ function restartGame() {
818
822
bulletsCounter = - 1 ;
819
823
seconds = 0 ;
820
824
minutes = 3 ;
821
- score [ stageid ] = 0 ;
822
- noshot = 0 ;
825
+ score = 0 ;
826
+ noshot = 1 ;
823
827
lastp = getLastPlatform ( ) ;
824
828
sstart = 0 ;
825
829
for ( p = 0 ; p <= enemiesCounter ; p ++ ) {
@@ -1056,6 +1060,7 @@ function drawHUD() {
1056
1060
fill ( 'black' ) ;
1057
1061
text ( plifep , 82 , 65 ) ;
1058
1062
drawTimer ( ) ;
1063
+ text ( countPoints ( 0 ) , 1245 , 65 ) ;
1059
1064
fill ( '#FFFFFF' ) ;
1060
1065
}
1061
1066
@@ -1104,8 +1109,9 @@ function damage() {
1104
1109
bullets [ j ] [ 5 ] = false ;
1105
1110
lifePoints ( drawingenemies [ l ] [ 2 ] , - 1 ) ;
1106
1111
if ( enemies [ stageid ] [ drawingenemies [ l ] [ 2 ] ] [ 7 ] === 0 ) {
1107
- if ( enemies [ stageid ] [ drawingenemies [ l ] [ 2 ] ] [ 5 ] === 0 ) score [ stageid ] += 150 ;
1108
- else score [ stageid ] += 250 ;
1112
+ if ( enemies [ stageid ] [ drawingenemies [ l ] [ 2 ] ] [ 5 ] === 0 ) score += 150 ;
1113
+ else if ( enemies [ stageid ] [ drawingenemies [ l ] [ 2 ] ] [ 5 ] === 1 ) score += 250 ;
1114
+ else score += 400 ;
1109
1115
}
1110
1116
}
1111
1117
}
@@ -1211,13 +1217,18 @@ function spikesCollision() {
1211
1217
}
1212
1218
}
1213
1219
1214
- function countPoints ( ) {
1215
- for ( var k = 1 ; k <= plifep ; k ++ ) score [ stageid ] += 75 ;
1216
- var points = ( 60 * minutes + seconds ) * 300 / maxtime ;
1217
- if ( noshot === 0 ) noshot ++ ;
1218
- var points2 = 350 / noshot ;
1219
- score [ stageid ] = score [ stageid ] + points + points2 ;
1220
- score [ stageid ] = Math . round ( score [ stageid ] ) ;
1220
+ function countPoints ( type ) {
1221
+ switch ( type ) {
1222
+ case 0 :
1223
+ points = ( 60 * minutes + seconds ) * 600 / maxtime ;
1224
+ points2 = 500 / noshot ;
1225
+ currentscore = Math . round ( points + points2 + score ) ;
1226
+ return currentscore + generalscore ;
1227
+ break ;
1228
+ case 1 :
1229
+ generalscore = generalscore + currentscore ;
1230
+ break ;
1231
+ }
1221
1232
}
1222
1233
1223
1234
0 commit comments