Use arrows on the keyboard to move your character to the other side of the pathway in 17 sec. Click your mouse to add more rocks to make the game harder.
xxxxxxxxxx
let timer;
let wallpaper;
let orbs = []
let orb_1;
let chest;
var boxa;
var boxb;
var box_x;
var box_y;
var orbGroup;
var character;
var coin;
let isTouching = true;
function setup() {
createCanvas(500, 900);
wallpaper = loadImage('gamewallpaper.jpg');
orb_1 = new Orb()
orbs.push(new Orb(width * 0.5, height * 0.5));
boxa = 200
boxb = 100
timer = setTimeout (win_or_lose, 17000)
//loadFont('https://fonts.cdnfonts.com/css/georgia')
}
function draw() {
background(187, 212, 252);
imageMode(CENTER)
image(wallpaper,200,400); // 300 500
for (const orb of orbs) {
orb.draw();
}
//if (orbGroup.isTouching(character)) {
// orbGroup.destroyEach();
//yellow dots
fill(250, 246, 207)
coin = rect (100,290,30,30,5)
rect (300,600,30,30,5)
rect (300,90,30,30,5)
//magic box/chest
noStroke()
fill(255)
character = rect (boxa,boxb,30,30)
fill(135, 147, 199)
rect (boxa, boxb, 20,20)
fill(235, 152, 211)
rect (boxa, boxb, 10,10)
fill(205, 139, 224)
line(20,500, 300, 500);
/*if (character.isTouching(coin)) {
coin.destroyEach();
} */
//push();
//translate (0,-400,30)
//fill(228, 168, 247)
//box(25,25,100)
//pop()
}
function mousePressed() {
orbs.push(new Orb(mouseX, mouseY));
}
class Orb {
constructor(x,y) {
this.x = random(200);
this.y = random(600);
this.size = 10;
this.deltaX = -1;
this.deltaY = 1;
this.c = (122, 90, 173);
}
draw() {
const chestX = width/2 ;
const chestY = height/2;
const distanceFromChest = dist(this.x, this.y, chestX, chestY);
this.deltaX += (chestX - this.x) / distanceFromChest;
this.deltaY += (chestY - this.y) / distanceFromChest;
this.x += this.deltaX;
this.y += this.deltaY;
fill(this.c)
circle(this.x, this.y, this.size)
circle(this.x +5, this.y, this.size + 2)
circle(this.x, this.y +5, this.size + 2)
}
if(mousePressed) {
this.xspeed = 1.2;
this.yspeed = 1.2;
}
}
//win lose function
function win_or_lose(){
if (boxb => 400)
print("You won purr")
//else
//background(0);
fill(200)
print("The Game is Over!");
textSize(32);
text('The Game is Over. You lost....', width/2, height/2)
}
function keyPressed(){
if (keyCode== LEFT_ARROW){
boxa-= 20
}
if(keyCode == RIGHT_ARROW){
boxa+= 20
}
if(keyCode== UP_ARROW){
boxb-= 20
}
if(keyCode ==DOWN_ARROW){
boxb+= 20
}
}