removing coins over canyons; formatting
This commit is contained in:
parent
b2b1bf06ba
commit
eff904c5db
24
sketch.js
24
sketch.js
@ -78,7 +78,7 @@ function startGame(full_start, update_objects) {
|
|||||||
],
|
],
|
||||||
curGroundPosYIndex: 0,
|
curGroundPosYIndex: 0,
|
||||||
|
|
||||||
draw: function() {
|
draw: function () {
|
||||||
push();
|
push();
|
||||||
strokeWeight(1);
|
strokeWeight(1);
|
||||||
stroke(1);
|
stroke(1);
|
||||||
@ -248,10 +248,10 @@ function startGame(full_start, update_objects) {
|
|||||||
this.y_step /= this.scale;
|
this.y_step /= this.scale;
|
||||||
pop();
|
pop();
|
||||||
},
|
},
|
||||||
getCurGroundPosY: function() {
|
getCurGroundPosY: function () {
|
||||||
return this.possibleGroundPosY[this.curGroundPosYIndex];
|
return this.possibleGroundPosY[this.curGroundPosYIndex];
|
||||||
},
|
},
|
||||||
goUp: function() {
|
goUp: function () {
|
||||||
memorizedIndex = this.curGroundPosYIndex;
|
memorizedIndex = this.curGroundPosYIndex;
|
||||||
this.curGroundPosYIndex = max(0, this.curGroundPosYIndex - 1);
|
this.curGroundPosYIndex = max(0, this.curGroundPosYIndex - 1);
|
||||||
if (memorizedIndex != this.curGroundPosYIndex) {
|
if (memorizedIndex != this.curGroundPosYIndex) {
|
||||||
@ -259,7 +259,7 @@ function startGame(full_start, update_objects) {
|
|||||||
gameChar.scale -= 0.1;
|
gameChar.scale -= 0.1;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
goDown: function() {
|
goDown: function () {
|
||||||
memorizedIndex = this.curGroundPosYIndex;
|
memorizedIndex = this.curGroundPosYIndex;
|
||||||
this.curGroundPosYIndex = min(
|
this.curGroundPosYIndex = min(
|
||||||
this.possibleGroundPosY.length - 1,
|
this.possibleGroundPosY.length - 1,
|
||||||
@ -347,6 +347,7 @@ function startGame(full_start, update_objects) {
|
|||||||
if (collectables[i - 1].x + 200 > finish_position_x) {
|
if (collectables[i - 1].x + 200 > finish_position_x) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
collectables[i] = {
|
collectables[i] = {
|
||||||
x: collectables[i - 1].x + 50 + 100 * random(0.5, 1),
|
x: collectables[i - 1].x + 50 + 100 * random(0.5, 1),
|
||||||
y: gameChar.possibleGroundPosY[
|
y: gameChar.possibleGroundPosY[
|
||||||
@ -355,6 +356,17 @@ function startGame(full_start, update_objects) {
|
|||||||
size: 75,
|
size: 75,
|
||||||
isFound: false,
|
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);
|
stroke(1);
|
||||||
translate(-cameraPosX, 0);
|
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(
|
line(
|
||||||
i,
|
i,
|
||||||
floorPos_y + (2 * (height - floorPos_y)) / 6,
|
floorPos_y + (2 * (height - floorPos_y)) / 6,
|
||||||
@ -834,4 +846,4 @@ function keyReleased() {
|
|||||||
console.log(frameCount + " released " + key + " " + keyCode);
|
console.log(frameCount + " released " + key + " " + keyCode);
|
||||||
if (keyCode == 65 /*A*/) gameChar.isLeft = false;
|
if (keyCode == 65 /*A*/) gameChar.isLeft = false;
|
||||||
if (keyCode == 68 /*D*/) gameChar.isRight = false;
|
if (keyCode == 68 /*D*/) gameChar.isRight = false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user