removing coins over canyons; formatting

This commit is contained in:
Mottributo 2023-03-23 22:33:39 +03:00
parent b2b1bf06ba
commit eff904c5db

View File

@ -78,7 +78,7 @@ function startGame(full_start, update_objects) {
],
curGroundPosYIndex: 0,
draw: function() {
draw: function () {
push();
strokeWeight(1);
stroke(1);
@ -248,10 +248,10 @@ function startGame(full_start, update_objects) {
this.y_step /= this.scale;
pop();
},
getCurGroundPosY: function() {
getCurGroundPosY: function () {
return this.possibleGroundPosY[this.curGroundPosYIndex];
},
goUp: function() {
goUp: function () {
memorizedIndex = this.curGroundPosYIndex;
this.curGroundPosYIndex = max(0, this.curGroundPosYIndex - 1);
if (memorizedIndex != this.curGroundPosYIndex) {
@ -259,7 +259,7 @@ function startGame(full_start, update_objects) {
gameChar.scale -= 0.1;
}
},
goDown: function() {
goDown: function () {
memorizedIndex = this.curGroundPosYIndex;
this.curGroundPosYIndex = min(
this.possibleGroundPosY.length - 1,
@ -347,6 +347,7 @@ function startGame(full_start, update_objects) {
if (collectables[i - 1].x + 200 > finish_position_x) {
break;
}
collectables[i] = {
x: collectables[i - 1].x + 50 + 100 * random(0.5, 1),
y: gameChar.possibleGroundPosY[
@ -355,6 +356,17 @@ function startGame(full_start, update_objects) {
size: 75,
isFound: false,
};
// Checking whether the coin is over a canyon;
// marking it as isFound (making it disabled) in case if.
for (k = 0; k < canyons.length; k++) {
if (
canyons[k].x - canyons[k].width / 2 < collectables[i].x
&&
canyons[k].x + canyons[k].width / 2 > collectables[i].x
) {
collectables[i].isFound = true;
}
}
}
}
}
@ -519,7 +531,7 @@ function drawGround() {
);
stroke(1);
translate(-cameraPosX, 0);
for (i = -width/2; i < finish_position_x + width/2; i += 20) {
for (i = -width / 2; i < finish_position_x + width / 2; i += 20) {
line(
i,
floorPos_y + (2 * (height - floorPos_y)) / 6,