I’m working on my game that’s based on the chrome dino run game that plays whenever you’re offline.
However, I’m facing a problem, I can’t get my image to move the way the dino does in the game.
I’m sorry for bothering you, but help or links to a useful resourceful would be nice.
My Code:
float bunHeight = 250, bunPosX = 40;
float speed = 4;
PImage bun;
PImage bg;
boolean jump=false;
int score = 0;
int highscore = 0;
void setup() {
size(500, 500);
//protag
bun = loadImage("Bun.png");
//bg
bg = loadImage("background.png");
println(" use UP ARROW key ");
}
void draw() {
///background?
background(bg);
fill(255);
rect(250, 245, 50, 50);
//draw the bun/protag
image(bun, bunPosX, 10+bunHeight);
//High Score Text
fill(255, 0, 0);
textSize(20);
text("High Score: " + highscore, 70, 20); //display high score in
//enables jump
if (jump) {
bunHeight -= speed;
if (bunHeight < 150) speed = -speed;
if (bunHeight > height/2) {
speed = -speed;
jump = false;
}
}
}
//Enables Jump by pressing up
void keyReleased() {
if ( keyCode == UP)
jump = true;
}
Here’s bun image