xxxxxxxxxx
370
let img;
let img2;
let floof;
let treatImg;
let img4;
let img5;
let img6;
let angle = 0;
let scene = 0;
let button1;
let button2;
var score = 0;
var score2 = 0;
var y = -20;
var x = 200;
var speed = 2;
var diameter = 550;
let floofyay;
let score1 = 0;
let mytreats = [];
let goodTreats = ["JornTreat.png"];
let treatImages = [];
let treatData = [
{
x: 100,
y: 30,
speed: 4,
},
{
x: 120,
y: 80,
speed: 3.2,
},
{
x: 140,
y: 130,
speed: 3.5,
},
{
x: 160,
y: 180,
speed: 3.6,
},
{
x: 320,
y: 300,
speed: 3.8,
},
{
x: 340,
y: 350,
speed: 3.3,
},
{
x: 160,
y: 400,
speed: 3.1,
},
{
x: 180,
y: 450,
speed: 2.9,
},
];
function preload(){
for ( let i = 0; i < goodTreats.length; i++) {
treatImages[i] = loadImage(goodTreats[i]);
}
}
function setup() {
createCanvas(600, 400);
img = loadImage("Juno2.png");
img2 = loadImage("Junosleep.png");
floof = loadImage("Junowalk1.png");
img4 = loadImage("Leaf.png");
img5 = loadImage("Junoreal.jpeg");
img6 = loadImage("LeafTitle.png");
treatImg = loadImage("JornTreat.png");
angleMode(DEGREES);
button1 = createButton("♥ let's go ♥");
button1.position(210, 330);
button1.size(170, 40);
button1.mousePressed(sceneChangeA);
button1.hide();
button2 = createButton("♥ restart ♥");
button2.position(220, 55);
button2.size(160, 40);
button2.mousePressed(sceneChangeD);
button2.hide();
floofyay = new player(70, 278);
for (let i = 0; i < 8; i++) {
mytreats[i] = new treats(
treatData[i].x,
treatData[i].y,
treatData[i].speed);
}
}
function draw() {
// background(171, 154, 177);
switch (scene) {
case 0:
scene0(); //title screen
break;
case 1:
scene1(); // game1
break;
case 2:
scene2(); // game2
break;
case 3:
scene3(); // game3
break;
case 4:
scene4(); // endscreen
break;
}
}
let go = false;
function ready() {
go = true;
}
//title screen
function scene0() {
background(171, 154, 177);
textStyle(BOLD);
fill(50);
textFont("monospace", 20);
text("♥ Juno loves to catch leaves ♥", 300, 280);
text("♥ Use the mouse to help her catch them ♥", 300, 315);
textAlign(CENTER);
image(img2, 175, 35, 250, 220);
push();
translate(100, 160);
rotate(angle);
imageMode(CENTER);
image(img6, 0, 0, 90, 80);
pop();
push();
translate(500, 160);
rotate(-angle);
imageMode(CENTER);
image(img6, 0, 0, 90, 80);
pop();
angle += 1;
//border
push();
rectMode(CORNER);
fill(50);
noStroke();
rect(0, 0, 600, 20);
rect(0, 380, 600, 20);
rect(0, 0, 20, 600);
rect(580, 0, 20, 600);
pop();
push();
stroke(30);
strokeWeight(5);
line(20, 20, 20, 380);
line(580, 20, 580, 380);
line(20, 20, 580, 20);
line(20, 380, 580, 380);
pop();
button1.show();
button2.hide();
reset();
}
function scene1() {
background(171, 154, 177);
push();
textStyle(BOLD);
fill(50);
textFont("monospace", 40);
text("leaves caught = " + score2, 30, 60);
pop();
textAlign(LEFT);
image(img4, x, y, 60, 60);
rectMode(CENTER);
image(floof, mouseX, height - 122, 140, 100);
y += speed;
if (y > height) {
scene = 2;
}
if (y > height - 122 && x > mouseX - 60 && x < mouseX + 60) {
y = -20;
speed += 0.5;
score2 += 1;
}
if (y == -20) {
pickRandom();
}
push();
rectMode(CORNER);
fill(50);
noStroke();
rect(0, 0, 600, 20);
rect(0, 380, 600, 20);
rect(0, 0, 20, 600);
rect(580, 0, 20, 600);
pop();
push();
stroke(30);
strokeWeight(5);
line(20, 20, 20, 380);
line(580, 20, 580, 380);
line(20, 20, 580, 20);
line(20, 380, 580, 380);
pop();
button1.hide();
button2.hide();
}
function pickRandom() {
x = random(20, width - 20);
}
function scene2() {
background(171, 154, 177);
cursor("grab");
//bellypatstext
textStyle(BOLD);
fill(50);
textFont("monospace", 50);
text("pets " + score, 40, 70);
textAlign(LEFT);
push();
textStyle(BOLD);
fill(50);
textFont("monospace", 20);
text("oh no! Juno dropped a leaf", 40, 100);
text("console her with belly pets", 40, 120);
text("leaves caught = " + score2, 330, 350);
textAlign(LEFT);
pop();
//border
push();
rectMode(CORNER);
fill(50);
noStroke();
rect(0, 0, 600, 20);
rect(0, 380, 600, 20);
rect(0, 0, 20, 600);
rect(580, 0, 20, 600);
pop();
push();
stroke(30);
strokeWeight(5);
line(20, 20, 20, 380);
line(580, 20, 580, 380);
line(20, 20, 580, 20);
line(20, 380, 580, 380);
pop();
//Juno
diameter = lerp(diameter, 550, 0.1);
image(img, 60, 10, diameter, diameter);
button1.hide();
button2.hide();
if (score === 20) {
scene = 3;
}
}
function scene3() {
background(171, 154, 177);
floofyay.x = 20;
// bgcolor = doggo;
for (let i = 0; i < mytreats.length; i++) {
mytreats[i].draw();
mytreats[i].move();
mytreats[i].checkCollision();
}
textSize(40);
text("treats eaten: " + score1, 40,60);
floofyay.draw();
floofyay.move();
push();
textStyle(BOLD);
fill(50);
textFont("monospace", 20);
text("now console her with treats!", 43, 90);
text("use arrow keys to give Juno snacks", 43, 120);
textAlign(LEFT);
pop();
//border
push();
rectMode(CORNER);
fill(50);
noStroke();
rect(0, 0, 600, 20);
rect(0, 380, 600, 20);
rect(0, 0, 20, 600);
rect(580, 0, 20, 600);
pop();
push();
stroke(30);
strokeWeight(5);
line(20, 20, 20, 380);
line(580, 20, 580, 380);
line(20, 20, 580, 20);
line(20, 380, 580, 380);
pop();
if (score1 === 10) {
scene = 4;
}
}
function scene4() {
background(171, 154, 177);
push();
textStyle(BOLD);
fill(50);
textFont("monospace", 27);
textAlign(CENTER);
text("♥ Thanks for the love ♥", 300, 40);
image(img5, 0, 100, 300, 350);
image(img5, 300, 100, 300, 350);
pop();
button1.hide();
button2.show();
}
//bellypats
function mousePressed() {
var distance = dist(50, 50, mouseX - 270, mouseY - 220);
if (distance <= 50) {
score++;
diameter = 540;
}
}
function sceneChangeA() {
scene = 1;
}
function sceneChangeD() {
scene = 0;
}
function reset() {
score = 0;
score2 = 0;
speed = 2;
y = -20;
}