Skip to content

Commit 9033696

Browse files
committed
Przebudowanie liczenia punktow, dodanie wyswietlania punktow do HUD'a
1 parent b3cf162 commit 9033696

File tree

1 file changed

+27
-16
lines changed

1 file changed

+27
-16
lines changed

js/app_p5.js

+27-16
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,12 @@ var tcounter = 0;
163163
var maxtime = minutes * 60 + seconds;
164164

165165
//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;
168172

169173
var drawingenemies = [];
170174
for (l = 0; l < 4; l++) drawingenemies[l] = [];
@@ -370,8 +374,8 @@ function stageCompleted() {
370374
textSize(50);
371375
fill('#000000');
372376
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);
375379
text("Level " + (stageid + 1) + " Completed", 500, 400);
376380
text("Press SPACE to Continue", 500, 700);
377381
fill('#FFFFFF');
@@ -589,7 +593,7 @@ function gravity(maxy, maxid) {
589593
} else {
590594
if (maxid === maxp[stageid] - 1) {
591595
completed = true;
592-
countPoints();
596+
countPoints(1);
593597
}
594598
}
595599
}
@@ -818,8 +822,8 @@ function restartGame() {
818822
bulletsCounter = -1;
819823
seconds = 0;
820824
minutes = 3;
821-
score[stageid] = 0;
822-
noshot = 0;
825+
score = 0;
826+
noshot = 1;
823827
lastp = getLastPlatform();
824828
sstart = 0;
825829
for (p = 0; p <= enemiesCounter; p++) {
@@ -1056,6 +1060,7 @@ function drawHUD() {
10561060
fill('black');
10571061
text(plifep, 82, 65);
10581062
drawTimer();
1063+
text(countPoints(0), 1245, 65);
10591064
fill('#FFFFFF');
10601065
}
10611066

@@ -1104,8 +1109,9 @@ function damage() {
11041109
bullets[j][5] = false;
11051110
lifePoints(drawingenemies[l][2], -1);
11061111
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;
11091115
}
11101116
}
11111117
}
@@ -1211,13 +1217,18 @@ function spikesCollision() {
12111217
}
12121218
}
12131219

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+
}
12211232
}
12221233

12231234

0 commit comments

Comments
 (0)