- #1
lionely
- 576
- 2
Alright I'm trying to make a game using Java-Script, it is a 2-D side scroller
if ( xPositions>this.x && xPositions<this.x+50 && yPositions>y && yPositions<y+50) {
y-= 5;
fill(255, 255, 255, 127);
stroke(0, 0, 0, 127);
rect(80, 110, 280, 150, 15);
noStroke();
fill(0, 0, 0);
textFont(loadFont("Times", 36), 36);
text("Game Over\n Try again!", 100, 150);
text("Final Score: " + points, 85, 250);
noLoop();
}
Also it might be different from usual Java-Script because I am using Khan academy's compiler.
The problem is that my character just moves through the objects and nothing happens, when the object touches my character the game should end. I have no idea what to change.
So could someone please help me?
if ( xPositions>this.x && xPositions<this.x+50 && yPositions>y && yPositions<y+50) {
y-= 5;
fill(255, 255, 255, 127);
stroke(0, 0, 0, 127);
rect(80, 110, 280, 150, 15);
noStroke();
fill(0, 0, 0);
textFont(loadFont("Times", 36), 36);
text("Game Over\n Try again!", 100, 150);
text("Final Score: " + points, 85, 250);
noLoop();
}
Also it might be different from usual Java-Script because I am using Khan academy's compiler.
The problem is that my character just moves through the objects and nothing happens, when the object touches my character the game should end. I have no idea what to change.
So could someone please help me?