xxxxxxxxxx
1760
let song;
let play = true;
//scene0
let bgColor = (28, 3, 1);
let sceneNum = 0;
let childX0 = -130;
let childY0 = 250;
let momX0 = 920;
let momY0 = 220;
let startColor;
let tryAgainColor = (12, 5, 38);
let homeColor = (12, 5, 38);
let child0;
let mom0;
let bg0;
let title;
//scene1
let bg1;
let hat;
//scene2
let bg2;
let eye1;
let eye2;
//scene3
let bg3;
let paper;
//scene4
let bg4;
let purpleStripe;
let mom2;
//scene3
let alpha = 255;
let childX1;
let childY1;
let value; //volumn
let start; //volumn bar transparancy
let lowest; //lowest point of green area
let highest; //highest point of green area
let drawVolumn = false;
let success1 = false;
let firstTry = true;
let loud = false;
//scene5
let transparency;
let temper;
let temperColor;
let timeLimit2;
let passengers = [];
let childX2 = 20;
let childY2 = 65 + 70 - 25 / 2;
let moveD = 0; //move distance
let momX2;
let momY2;
let success2 = false;
let bg5;
let road;
let child5;
let mom5;
let ppl1;
let ppl2;
let ppl3;
let ppl4;
let ppl5;
let ppl6;
let ppl7;
let ppl8;
//scene6
let bg6;
let child2;
let child1;
//scene7
let stripes = [];
let things = [];
let objects = [];
let drawText = false;
let childX3;
let childY3;
let childW; //width
let childH; //height
let back;
let front;
let momX3;
let momY3;
let momW;
let momH;
let text1;
let text2;
let text3;
let text4; //loosing patience
let text5; //threaten to leave
let text6; //decide to leave
let randomNum;
let fetchedObject; //the color of the fetched object
let fetchedW;
let fetchedH;
let picked; //if the child has the object
let correct; //the picked object is the right one
let timeLimit3; //in frame founts
let firstThing;
let secondThing;
let thirdThing;
let textContent;
let bg7;
let belt;
let fail3;
let success3;
let cake;
let soda;
let apple;
let coffee;
let icecream;
let empty;
//scene8
let childX8 = 150;
let childY8 = 250;
let momX8 = 450;
let momY8 = 220;
let child3;
let bg8;
let cloud;
//fail scene
let failbg;
///////////////////////////////////////////
///////////////////////////////////////////
///////////////////////////////////////////
function preload() {
soundFormats("mp3", "ogg");
song = loadSound("song.mp3");
//scene0
mom0 = loadImage("assets/mom_.png");
child0 = loadImage("assets/child_.png");
bg0 = loadImage("assets/bg0.png");
title = loadImage("assets/title.png");
//scene1
bg1 = loadImage("assets/bg1.png");
hat = loadImage("assets/hat.png");
//scene2
bg2 = loadImage("assets/scene2_bg.png");
eye1 = loadImage("assets/eye1.png");
eye2 = loadImage("assets/eye2.png");
//scene3
bg3 = loadImage("assets/bg3.png");
paper = loadImage("assets/paper.png");
//scene4
bg4 = loadImage("assets/scene4_bg.png");
purpleStripe = loadImage("assets/purpleStripe.png");
mom2 = loadImage("assets/mom2.png");
//scene5
bg5 = loadImage("assets/bg5.png");
child5 = loadImage("assets/child5.png");
mom5 = loadImage("assets/mom5.png");
ppl1 = loadImage("assets/ppl1.png");
ppl2 = loadImage("assets/ppl2.png");
ppl3 = loadImage("assets/ppl3.png");
ppl4 = loadImage("assets/ppl4.png");
ppl5 = loadImage("assets/ppl5.png");
ppl6 = loadImage("assets/ppl6.png");
ppl7 = loadImage("assets/ppl7.png");
ppl8 = loadImage("assets/ppl8.png");
road = loadImage("assets/road.png");
//scene6
bg6 = loadImage("assets/bg6.png");
child2 = loadImage("assets/child2.png");
child1 = loadImage("assets/child1.png");
//scene7
bg7 = loadImage("assets/bg7.png");
belt = loadImage("assets/belt.png");
cake = loadImage("assets/cake.png");
coffee = loadImage("assets/coffee.png");
apple = loadImage("assets/apple.png");
icecream = loadImage("assets/icecream.png");
soda = loadImage("assets/soda.png");
empty = loadImage("assets/empty.png");
//scene8
bg8 = loadImage("assets/bg8.png");
child3 = loadImage("assets/child3.png");
cloud = loadImage("assets/cloud.png");
//fail scene
failbg = loadImage("assets/fail.png");
}
///////////////////////////////////////////
///////////////////////////////////////////
///////////////////////////////////////////
function setup() {
song.setVolume(0.1);
// song.play()
// song.loop()
createCanvas(600, 400);
frameRate(30);
rectMode(CENTER);
textAlign(CENTER);
imageMode(CENTER);
startColor = color(237, 234, 228);
textFont("Verdana");
//scene3
childX1 = 0;
childY1 = 260;
value = 0;
start = 0;
lowest = 150;
highest = 160;
//scene 5
transparency = true;
timeLimit2 = 1200;
momX2 = 570;
momY2 = 310;
for (i = 0; i < 8; i++) {
passengers[0] = new Passenger(
60,
120,
// color(random(255), random(255), random(255)),
ppl1,
true,
80,
120,
true,
false,
1
);
passengers[1] = new Passenger(
135,
80,
ppl2,
true,
80,
120,
false,
false,
1.5
);
passengers[2] = new Passenger(
180,
65 + 70 + 30,
ppl3,
false,
180,
220,
false,
true,
1.5
);
passengers[3] = new Passenger(
260,
220,
ppl4,
true,
220,
260,
false,
false,
1
);
passengers[4] = new Passenger(
340,
260,
ppl5,
true,
220,
260,
true,
false,
1
);
passengers[5] = new Passenger(
390,
65 + 140 + 70,
ppl6,
false,
390,
430,
false,
true,
2
);
passengers[6] = new Passenger(
235 + 210 + 5,
330,
ppl7,
true,
290,
330,
true,
false,
1
);
passengers[7] = new Passenger(
520,
65 + 140 + 70 + 15,
ppl8,
true,
290,
330,
false,
false,
2
);
}
//scene7
picked = false;
correct = false;
timeLimit3 = 1200;
childX3 = 140;
childY3 = 145;
childW = 55;
childH = 95;
back = 145;
front = 250;
fail3 = false;
success3 = false;
momX3 = 420;
momY3 = 40;
momW = 40;
momH = 120;
text1 = `Ahh why is it so hot? \nI'm about to melt.`;
text2 = `I've been eating junk \nfood the whole week.`;
text3 = `What an aweful day. I feel exhausted.`;
randomNum = floor(random(3));
text4 = `What's taking you \nso long?`;
text5 = `You coming or not?`;
text6 = `Alright.`;
text7 = `Duh.I knew you \n wouldn't get it.`;
text8 = `Would've appreciated \nif you could get it faster.`;
for (i = 0; i < 5; i++) {
objects[0] = [icecream, 48, 50];
objects[1] = [soda, 30, 65];
objects[2] = [coffee, 40, 60];
objects[3] = [apple, 40, 50];
objects[4] = [cake, 80, 70];
}
// fetch
fetchedObject = empty;
fetchedW = 10;
fetchedH = 10;
//stripes
for (i = 0; i < 29; i++) {
stripes[i] = new Stripe(i * 21, 304.5);
}
//things
for (i = 0; i < 30; i++) {
things[i] = new Thing(objects[floor(random(5))], -i * 100 + 200, 270);
}
firstThing = new Thing(objects[0], -100, 260);
secondThing = new Thing(objects[1], -150, 260);
thirdThing = new Thing(objects[2], -200, 260);
things.splice(3, 0, firstThing, secondThing, thirdThing);
}
///////////////////////////////////////////
///////////////////////////////////////////
///////////////////////////////////////////
function mousePressed() {
if (play) {
song.play();
song.loop();
play = false;
} else {
}
}
function draw() {
switch (sceneNum) {
case 0:
scene0();
break;
case 1:
scene1();
break;
case 2:
scene2();
break;
case 3:
scene3();
break;
case 4:
scene4();
break;
case 5:
scene5();
break;
case 6:
scene6();
break;
case 7:
scene7();
break;
case 8:
scene8();
break;
case 98: //bump into passengers
scene98();
break;
case 99: //too loud in scene3
scene99();
break;
case 100:
scene100();
break;
case 101:
scene101();
break;
case 102:
scene102();
break;
}
console.log(constrain(floor(random(40)), 30, 40));
}
///////////////////////////////////////////
///////////////////////////////////////////
///////////////////////////////////////////
//scene5
class Passenger {
constructor(x, y, img, vertical, point1, point2, up, right, speed) {
this.x = x;
this.y = y;
this.img = img;
this.vertical = vertical;
this.point1 = point1;
this.point2 = point2;
this.up = up;
this.right = right;
this.speed = speed;
}
body() {
image(this.img, this.x, this.y, 33, 33);
if (this.vertical) {
if (this.y < this.point1) {
this.up = false;
}
if (this.y > this.point2) {
this.up = true;
}
} else {
if (this.x < this.point1) {
this.right = true;
}
if (this.x > this.point2) {
this.right = false;
}
}
}
moveUp() {
this.y -= this.speed;
}
moveDown() {
this.y += this.speed;
}
moveRight() {
this.x += this.speed;
}
moveLeft() {
this.x -= this.speed;
}
checkCollision() {
if (dist(this.x, this.y, childX2, childY2) < 22) {
transparency = false;
}
}
}
//scene7
class Stripe {
constructor(x, y) {
this.x = x;
this.y = y;
}
body() {
stroke(12, 5, 38, 100);
line(this.x, this.y, this.x + 20, this.y - 20);
}
move() {
if (this.x > width) {
this.x = -10;
} else {
this.x++;
}
}
}
class Thing {
constructor(img, x, y) {
this.img = img;
this.x = x;
this.y = y;
}
body() {
// fill(this.z);
// rect(this.x, this.y, 30, 60);
image(this.img[0], this.x, this.y, this.img[1], this.img[2]);
}
move() {
if (this.x > 1500) {
this.x = -30;
} else {
this.x++;
}
}
clicked() {
let d = dist(mouseX, mouseY, this.x, this.y);
if (d <= 15) {
this.x = 700;
this.y = 700;
fetchedObject = this.img[0];
fetchedW = this.img[1];
fetchedH = this.img[2];
picked = true;
if (
(this.img === objects[0] && randomNum === 0) ||
(this.img === objects[3] && randomNum === 1) ||
(this.img === objects[2] && randomNum === 2)
) {
correct = true;
}
}
}
}
///////////////////////////////////////////
///////////////////////////////////////////
///////////////////////////////////////////
//scene3
function keyReleased() {
if (keyCode == 32 && childX1 > 190 && childX1 < 210) {
firstTry = false;
if (value > highest) {
setTimeout(function () {
loud = true;
}, 1500);
setTimeout(function () {
sceneNum = 99;
frameCount = 0;
value = 0;
childX1 = 0;
drawVolumn = false;
start = 0;
loud = false;
}, 4000);
} else if (value < lowest) {
setTimeout(function () {
sceneNum = 100;
frameCount = 0;
value = 0;
childX1 = 0;
drawVolumn = false;
start = 0;
loud = false;
}, 1500);
} else {
setTimeout(function () {
success1 = true;
}, 1500);
console.log("success");
setTimeout(function () {
sceneNum = 4;
frameCount = 0;
value = 0;
childX1 = 0;
drawVolumn = false;
start = 0;
}, 4000);
}
}
}
function passLevel1() {
if (success1) {
image(cloud, 470, 200, 200, 100);
textSize(16);
fill(12, 5, 38);
text("Ugh.Just leave it at the door.", 478, 194, 170);
}
}
function tooLoud() {
if (loud) {
//cloud
image(cloud, 470, 200, 200, 100);
textSize(16);
fill(12, 5, 38);
text("Who do you think are you yelling at?!", 475, 190, 170);
}
}
function volumn() {
noStroke();
fill(255, 200, 0, 100);
rect(80, 270, 30, 160, 0, 0, 20, 20); //too low
fill(0, 255, 0, 100);
rect(80, 185, 30, 10); //optimal
fill(255, 0, 0, 100);
rect(80, 135, 30, 90, 20, 20, 0, 0); //too loud
stroke(50);
strokeWeight(2);
noFill();
rect(80, 220, 30, 260, 20);
//volumn 2
stroke(239, 202, 84);
strokeWeight(2);
noFill();
rect(80, 220, 30, 260, 20);
}
//scene5
function passLevel2() {
if (success2) {
//cloud
image(cloud, 450, 330, 170, 90);
textAlign(CENTER);
textSize(16);
fill(12, 5, 38);
text(`Aren't you the fastest?`, 458, 318, 150);
}
}
//scene7
function firstText() {
if (randomNum === 0) {
textContent = text1;
} else if (randomNum === 1) {
textContent = text2;
} else if (randomNum === 2) {
textContent = text3;
}
}
//scene7
function pick() {
for (let i = 0; i < 30; i++) {
if (childY3 <= front + 2 && childY3 > front - 20) {
things[i].clicked();
console.log("yes");
}
}
}
//fail function
function fail() {
if (dist(mouseX, mouseY, 200, 300) < 25) {
sceneNum = 2;
frameCount = 0;
} else if (dist(mouseX, mouseY, 400, 300) < 25) {
sceneNum = 0;
frameCount = 0;
}
}
function mouseClicked() {
if (sceneNum === 8) {
if (dist(mouseX, mouseY, 300, 300) < 150) {
sceneNum = 2;
frameCount = 0;
}
} else if (
sceneNum === 6 ||
sceneNum === 0 ||
sceneNum === 1 ||
sceneNum === 2 ||
sceneNum === 4
) {
if (dist(mouseX, mouseY, 300, 300) < 150) {
sceneNum++;
frameCount = 0;
}
} else if (
sceneNum === 98 ||
sceneNum === 99 ||
sceneNum === 100 ||
sceneNum === 101 ||
sceneNum === 102
) {
fail();
} else if (sceneNum === 7) {
console.log("click");
pick();
}
}
///////////////////////////////////////////
//////////////////scene000000000/////////////////////////
///////////////////////////////////////////
function scene0() {
background(bgColor);
image(bg0, 300, 200, 600, 402);
if (frameCount % 30 < 15) {
image(eye1, 221, 154, 45, 25);
} else {
image(eye2, 221, 154, 45, 25);
}
//child
fill(255, 0, 0);
image(child0, childX0, childY0, 110, 190);
//mom
fill(200, 0, 100);
image(mom0, momX0, momY0, 120, 280);
if (childX0 < 100) {
childX0 += 5;
}
if (momX0 > 490) {
momX0 -= 5;
}
if (frameCount > 100) {
//title
let titleY = 120;
let titleW;
let titleH;
if (frameCount % 10 < 5) {
titleW = 252;
titleH = 147;
} else {
titleW = 248;
titleH = 143;
}
image(title, 275, titleY, titleW, titleH);
}
if (frameCount > 130) {
fill(startColor);
textSize(30);
text("start", 300, 310, 40);
if (dist(mouseX, mouseY, 300, 300) < 50) {
startColor = color(239, 202, 84);
} else {
startColor = color(237, 234, 228);
}
}
console.log(frameCount);
console.log(sceneNum);
}
function scene1() {
background(bgColor);
image(bg1, 300, 200, 600, 400);
push();
translate(480, 90);
let r = PI / 50;
if (frameCount % 30 < 15) {
r = PI / 40;
} else {
r = 0;
}
rotate(r);
image(hat, 0, 0, 80, 50);
pop();
if (frameCount > 20) {
//title
let txt;
let txtY;
txt1 =
"In this game, you're the fearful child whose mom is charming, elusive and hard to please. You need to get her attention without annoying her, understand her needs without asking a question.";
txt2 =
"There's no room for mistakes. You have to pass three stages in one go!";
fill(255);
textSize(18);
textAlign(LEFT);
if (frameCount < 230) {
txt = txt1;
txtY = 130;
} else {
txt = txt2;
txtY = 155;
}
text(txt, 335, txtY, 430);
}
if (frameCount >= 230) {
//start button
if (dist(mouseX, mouseY, 300, 300) < 50) {
startColor = color(239, 202, 84);
} else {
startColor = color(237, 234, 228);
}
fill(startColor);
textSize(30);
text("o...okay", 240, 310, 100);
}
console.log(frameCount);
console.log(sceneNum);
}
function scene2() {
background(bgColor);
image(bg2, 300, 200, 600, 400);
if (frameCount % 30 < 15) {
image(eye1, 280, 305, 45, 25);
} else {
image(eye2, 280, 305, 45, 25);
}
//reset
alpha = 255;
firstTry = true;
value = 0;
drawVolumn = false;
success1 = false;
start = 0;
childX1 = 0;
childY1 = 260;
value = 0;
start = 0;
lowest = 150;
highest = 160;
if (frameCount > 15) {
//title
fill(255);
textAlign(LEFT);
textSize(25);
text("Be gentle...", 200, 70, 300);
textSize(18);
text(
" \n\nIt’s bedtime. Your mom’s resting in her bedroom. You need her to sign a school paper for you. \n \nMake yourself heard -- but not so loud that you'll irritate her!",
200,
70,
300
);
//start button
if (dist(mouseX, mouseY, 380, 290) < 80) {
startColor = color(239, 202, 84);
} else {
startColor = color(237, 234, 228);
}
fill(startColor);
textAlign(CENTER);
textSize(30);
text("got it", 380, 290, 300);
}
console.log(frameCount);
console.log(sceneNum);
}
///////////////////////////////////////////
///////////////////////////////////////////
///////////////////////////////////////////
function scene3() {
background(237, 234, 228);
image(bg3, 300, 200, 600, 400);
//instruction
fill(237, 234, 228);
textSize(20);
if (!drawVolumn && childX1 < 50) {
text(`Walk to the spotlight \nusing arrow keys.`, 200, 100, 300);
}
if (drawVolumn && keyIsPressed === false && firstTry) {
text(
`Press spacebar to raise the volume. Release it when it reaches the green.`,
250,
85,
350
);
}
//shadow
if (
(frameCount > 0 && frameCount % 25 < 25 / 2 && childX1 <= 190) ||
(childX1 >= 210 && frameCount > 0 && frameCount % 25 < 25 / 2)
) {
fill(239, 202, 84, 100);
ellipse(200, 350, 150, 40);
}
//child
image(child0, childX1, childY1, 110, 190);
image(paper, childX1 + 35, childY1 + 20, 50, 60);
if (keyIsDown(39)) {
childX1 += 3;
} else if (keyIsDown(37)) {
childX1 -= 3;
}
if (childX1 > 190 && childX1 < 210) {
drawVolumn = true;
} else {
drawVolumn = false;
}
//raise volumn
if (drawVolumn) {
volumn();
//increase volumn
if (keyIsDown(32) && firstTry) {
start = 255;
value += 4;
let x = 80;
let y = 350;
}
let x = 80;
let y = 350;
noStroke();
fill(255, 200, 0, start);
arc(80, 335, 30, 30, 0, PI);
fill(255, 200, 0);
if (value <= lowest && value > 0) {
rect(x, y - value / 2 - 10, 30, value); //yellow
} else if (value > lowest && value < highest) {
rect(x, y - lowest / 2 - 10, 30, lowest); //yellow
fill(0, 255, 0);
rect(x, 190 - (value - lowest) / 2, 30, value - lowest); //green
} else if (value >= highest && value <= highest + 80) {
rect(x, y - lowest / 2 - 10, 30, lowest); //yellow
fill(0, 255, 0);
rect(x, 185, 30, 10); //green
fill(255, 0, 0);
rect(x, 180 - (value - highest) / 2, 30, value - highest); //red
} else if (value > highest + 80) {
rect(x, y - lowest / 2 - 10, 30, lowest); //yellow
fill(0, 255, 0);
rect(x, 185, 30, 10); //green
fill(255, 0, 0);
rect(x, 140, 30, 80); //red
arc(x, 105, 30, 30, PI, 0);
}
}
//transition
if (frameCount < 200) {
alpha -= 5;
}
noStroke();
fill(28, 3, 1, alpha);
rect(300, 200, 600, 400);
passLevel1();
tooLoud();
console.log(value);
}
function scene4() {
background(bgColor);
image(bg4, 300, 200, 600, 400);
// image(eye,100,330,40,60)
if (frameCount % 30 < 15) {
image(mom2, 446, 250, 120, 280);
} else {
image(mom0, 446, 250, 120, 280);
}
image(purpleStripe, 300, 200, 600, 400);
//reset
alpha = 255;
childX2 = 15;
childY2 = 65 + 70 - 25 / 2;
transparency = true;
momX2 = 570;
momY2 = 310;
success2 = false;
if (frameCount > 20) {
//title
textAlign(LEFT);
fill(255);
textSize(25);
text("Be quick!", 125, 100, 200);
textSize(18);
text(
"You lost sight of your mom in a crowded shopping mall. You have to catch up with her before she runs out of her patience.",
230,
165,
400
);
text("Be careful not to bump into people!", 450, 280, 400);
//start button
if (dist(mouseX, mouseY, 420, 330) < 80) {
startColor = color(48, 48, 183);
} else {
startColor = color(206, 0, 0);
}
fill(startColor);
textSize(30);
text("I'll try...", 420, 330, 200);
}
console.log(frameCount);
console.log(sceneNum);
}
///////////////////////////////////////////
///////////////////////////////////////////
///////////////////////////////////////////
function scene5() {
background(220);
image(bg5, 300, 200, 600, 400);
image(road, 300, 200, 600, 400);
//patience bar
stroke(0);
fill(0);
rect(550, 250, 80, 10, 10);
if (frameCount <= timeLimit2 / 2) {
noStroke();
fill(0, 255, 0);
rect(
550 + (80 * frameCount) / timeLimit2 / 2,
250,
80 - (80 * frameCount) / timeLimit2,
10,
5
);
} else if (
frameCount > timeLimit2 / 2 &&
frameCount <= (timeLimit2 / 6) * 5
) {
noStroke();
fill(255, 255, 0);
rect(
550 + (80 * frameCount) / timeLimit2 / 2,
250,
80 - (80 * frameCount) / timeLimit2,
10,
5
);
} else if (frameCount > (timeLimit2 / 6) * 5 && frameCount <= timeLimit2) {
noStroke();
fill(255, 0, 0);
rect(
550 + (80 * frameCount) / timeLimit2 / 2,
250,
80 - (80 * frameCount) / timeLimit2,
10,
5
);
}
//road
noStroke();
fill(240, 246, 246);
rect(235 / 2, 100, 235, 70);
rect(200, 210 / 2 + 65, 70, 210);
rect(280 / 2 + 235 - 70, 65 + 210 - 35, 280, 70);
rect(280 + 235 - 70 - 35, 140 + 70 + 65, 70, 140);
rect(width - 225 / 2, height - 90, 225, 70);
//child
push();
if (!transparency) {
tint(255, 100);
}
image(child5, childX2, childY2, 40, 27);
pop();
//move child
if (keyIsDown(39)) {
childX2 += 3;
} else if (keyIsDown(37)) {
childX2 -= 3;
}
if (keyIsDown(38)) {
childY2 -= 3;
} else if (keyIsDown(40)) {
childY2 += 3;
}
if (childX2 > momX2) {
childX2 = momX2;
}
//starting point
if (childX2 < 15) {
childX2 = 15;
}
//first section
if (childY2 < 65 + 25 / 2 && childX2 < 165 + 25 / 2) {
childY2 = 65 + 25 / 2; //a
} else if (
childX2 < 165 + 25 / 2 - 3 /*A*/ &&
childY2 > 65 + 25 / 2 + 70 - 25
) {
childY2 = 65 + 25 / 2 + 70 - 25; //b
}
//second section
if (childX2 >= 165 + 25 / 2 && childY2 < 65 + 25 / 2) {
childY2 = 65 + 25 / 2; //a
} else if (
childX2 > 235 - 25 / 2 &&
childY2 < 65 + 140 + 25 / 2 - 3 &&
childY2 >= 65 + 25 / 2
) {
childX2 = 235 - 25 / 2; //c
} else if (
childY2 > 65 + 70 + 25 / 2 &&
childY2 < 65 + 70 + 140 - 25 / 2 &&
childX2 < 165 + 25 / 2
) {
childX2 = 165 + 25 / 2; //d
} else if (
childY2 > 65 + 140 + 70 - 25 / 2 &&
childX2 <= 165 + 210 + 25 / 2 - 6 /*A*/
) {
childY2 = 65 + 140 + 70 - 25 / 2; //f
}
//third section
if (childX2 > 235 - 25 / 2 && childY2 < 65 + 140 + 25 / 2) {
childY2 = 65 + 140 + 25 / 2;
} else if (
childX2 > 235 + 210 - 25 / 2 &&
childY2 < 65 + 140 + 70 + 25 / 2 - 3
) {
childX2 = 235 + 210 - 25 / 2;
}
//fourth section
if (childY2 > 65 + 70 + 140 - 25 / 2 && childX2 < 165 + 210 + 25 / 2) {
childX2 = 165 + 210 + 25 / 2;
} else if (
childX2 >= 165 + 210 + 25 / 2 &&
childY2 > 65 + 70 + 140 + 70 - 25 / 2
) {
childY2 = 65 + 70 + 140 + 70 - 25 / 2;
} else if (
childX2 > 235 + 210 - 25 / 2 + 3 &&
childY2 < 65 + 140 + 70 + 25 / 2
) {
childY2 = 65 + 140 + 70 + 25 / 2;
}
//passengers
for (i = 0; i < 8; i++) {
passengers[i].body();
passengers[i].checkCollision();
if (i === 0 || i === 1 || i === 3 || i === 4 || i === 6 || i === 7) {
if (passengers[i].up) {
passengers[i].moveUp();
} else {
passengers[i].moveDown();
}
} else if (i === 2 || i === 5) {
if (passengers[i].right) {
passengers[i].moveRight();
} else {
passengers[i].moveLeft();
}
}
}
//mom
// fill(255, 0, 0);
// rect(momX2, momY2, 30, 30);
image(mom5, momX2, momY2, 50, 50);
if (frameCount > timeLimit2) {
momX2++;
}
//win condition
if (frameCount <= timeLimit2 && childX2 >= momX2) {
setTimeout(function () {
success2 = true;
}, 1500);
console.log("success");
setTimeout(function () {
sceneNum = 6;
frameCount = 0;
}, 5000);
} else if (frameCount > timeLimit2 && childX2 < momX2) {
console.log("fail");
setTimeout(function () {
sceneNum = 101;
frameCount = 0;
}, 1000);
} else if (transparency === false) {
console.log("fail");
setTimeout(function () {
sceneNum = 98;
frameCount = 0;
}, 1000);
}
//transition
if (frameCount < 200) {
alpha -= 5;
}
noStroke();
fill(28, 3, 1, alpha);
rect(300, 200, 600, 400);
passLevel2();
}
function scene6() {
background(28, 3, 1);
image(bg6, 300, 200, 600, 400);
if (frameCount % 30 < 15) {
image(child1, 320, 140, 90, 160);
} else {
image(child2, 321, 140, 92, 160);
}
//reset
alpha = 255;
drawText = false;
picked = false;
correct = false;
fail3 = false;
success3 = false;
fetchedObject = empty;
childX3 = 140;
childY3 = 145;
childW = 55;
childH = 95;
momX3 = 420;
momY3 = 40;
momW = 40;
momH = 120;
// fetchColor = color(0, 0, 0, 0);
if (frameCount > 0) {
//title
textAlign(LEFT);
fill(255);
textSize(25);
text("Be smart:)", 160, 100, 200);
textSize(18);
text("\n\n(The final stage!)", 150, 100, 200);
text(
"Your mom will give you an ambiguous message. You'll have to guess what she really asks for and go fetch it!",
385,
240,
360
);
//start button
if (dist(mouseX, mouseY, 280, 312) < 50) {
startColor = color(0);
} else {
startColor = color(239, 202, 84);
}
fill(startColor);
textSize(30);
text("copy!", 280, 312, 50);
}
console.log(frameCount);
console.log(sceneNum);
}
///////////////////////////////////////////
///////////////////////////////////////////
//////////////////////////////////////////
function scene7() {
background(220);
image(bg7, 300, 200, 600, 400);
//child
image(child1, childX3, childY3, childW, childH);
if (keyIsDown(37)) {
childX3 -= 3;
} else if (keyIsDown(39)) {
childX3 += 3;
} else if (keyIsDown(38) && childY3 > back && childY3 < front + 2) {
childY3 -= 2;
childW -= 5 / 4;
childH -= 9 / 4;
fetchedW -= 0.3;
fetchedH -= 0.3;
} else if (keyIsDown(40) && childY3 >= back && childY3 < front) {
childY3 += 2;
childW += 5 / 4;
childH += 9 / 4;
fetchedW += 0.3;
fetchedH += 0.3;
}
if (childX3 > momX3 - 60) {
childX3 = momX3 - 60;
}
//mom
image(mom0, momX3, momY3, 150, 310);
if (frameCount > timeLimit3) {
momX3 += 3;
}
//fetch
image(fetchedObject, childX3 + 30, childY3, fetchedW, fetchedH);
//belt
image(belt, 300, 200, 600, 400);
//stripes
for (i = 0; i < 29; i++) {
stripes[i].body();
stripes[i].move();
}
stroke(12, 5, 38, 100);
strokeWeight(2);
line(0, 285, width, 285);
line(0, 304, width, 304);
//things
for (i = 0; i < 20; i++) {
things[i].body();
things[i].move();
}
//cloud
if (drawText && frameCount <= timeLimit3) {
image(cloud, 290, 70, 230, 105);
}
//text
textAlign(CENTER);
noStroke();
textSize(14);
fill(12, 5, 38);
text(textContent, 300, 95, 200, 70);
if (drawText && frameCount < timeLimit3 / 2 - 15 && !fail3 && !success3) {
firstText();
} else if (
frameCount > timeLimit3 / 2 &&
frameCount <= (timeLimit3 * 3) / 4 - 15 &&
!fail3 &&
!success3
) {
textContent = text4;
} else if (
frameCount > (timeLimit3 * 3) / 4 &&
frameCount <= timeLimit3 - 45 &&
!fail3 &&
!success3
) {
//thirdText
textContent = text5;
} else if (
frameCount > timeLimit3 - 30 &&
frameCount <= timeLimit3 &&
!fail3 &&
!success3
) {
//fourthText
textContent = text6;
} else if (fail3 && !success3 && frameCount < timeLimit3) {
//lastword
textContent = text7;
} else if (success3 && frameCount < timeLimit3) {
textContent = text8;
}
console.log(picked, correct, dist(childX3, childY3, momX3, momY3));
setTimeout(function () {
drawText = true;
}, 1000);
//instruction
fill(237, 234, 228);
textSize(20);
if (childY3 < back + 20 && !picked) {
text(`Walk to the front using arrow keys.`, 400, 210, 400);
}
if (childY3 > front - 20 && !picked) {
text(`Click on the item of your choice.`, 400, 210, 400);
}
if (childY3 > front - 20 && picked) {
text(`Hand it to your mom.`, 400, 210, 400);
}
//win condition
if (
picked === true &&
dist(childX3, childY3, momX3, momY3) < 140 &&
correct === true &&
frameCount <= timeLimit3
) {
console.log("win");
setTimeout(function () {
success3 = true;
}, 1500);
setTimeout(function () {
sceneNum = 8;
frameCount = 0;
}, 4000);
} else if (
(picked === true &&
dist(childX3, childY3, momX3, momY3) < 140 &&
correct === false &&
frameCount <= timeLimit3) ||
frameCount > timeLimit3
) {
console.log("fail");
setTimeout(function () {
fail3 = true;
}, 1500);
setTimeout(function () {
sceneNum = 8;
frameCount = 0;
}, 4000);
}
//transition
if (frameCount < 200) {
alpha -= 5;
}
noStroke();
fill(28, 3, 1, alpha);
rect(300, 200, 600, 400);
console.log(childW, childH);
console.log(frameCount);
}
//scene8
function scene8() {
background(28, 3, 1);
image(bg8, 300, 200, 600, 400);
//child
if (frameCount % 30 < 15) {
image(child1, 110, 280, 85, 155);
} else {
image(child3, 110, 280, 85, 155);
}
//mom
image(mom0, momX8, momY8, 120, 280);
if (frameCount > 0) {
if (momX8 < 700) {
momX8 += 5;
}
}
if (frameCount > 5) {
//title
let titleY = 180;
fill(237, 234, 228);
textSize(20);
text("Oops...Your mom seems to be unsatisfied.", 340, titleY, 300);
if (frameCount > 90) {
//start button
if (dist(mouseX, mouseY, 300, 300) < 50) {
startColor = color(237, 234, 228);
} else {
startColor = color(12, 5, 38);
}
fill(startColor);
textSize(30);
text("try again", 300, 290, 200);
}
console.log(frameCount);
console.log(sceneNum);
console.log(mouseX, mouseY);
}
}
//scene99
function scene99() {
image(failbg, 300, 200, 600, 400);
noStroke();
if (frameCount > 0) {
//title
fill(206, 0, 0);
textSize(20);
text("You were too loud! \n Gotta lower your voice...", 300, 155, 400);
}
if (frameCount > 0) {
//try again button
// fill(20, 200, 20);
// rect(200, 300, 100, 50, 20);
fill(tryAgainColor);
textSize(25);
text("Restart", 215, 290, 50);
if (dist(mouseX, mouseY, 200, 300) < 25) {
tryAgainColor = 255;
} else {
tryAgainColor = (12, 5, 38);
}
//home button
// fill(20, 200, 20);
// rect(400, 300, 100, 50, 20);
fill(homeColor);
textSize(25);
text("Home", 400, 290, 50);
if (dist(mouseX, mouseY, 400, 300) < 25) {
homeColor = 255;
} else {
homeColor = (12, 5, 38);
}
}
console.log(frameCount);
console.log(sceneNum);
}
//scene100
function scene100() {
image(failbg, 300, 200, 600, 400);
noStroke();
if (frameCount > 0) {
//title
fill(206, 0, 0);
textSize(20);
text(
"You failed to get her attention. \n You should speak up!",
310,
155,
400
);
}
if (frameCount > 0) {
//try again button
// fill(20, 200, 20);
// rect(200, 300, 100, 50, 20);
fill(tryAgainColor);
textSize(25);
text("Restart", 215, 290, 50);
if (dist(mouseX, mouseY, 200, 300) < 25) {
tryAgainColor = 255;
} else {
tryAgainColor = (12, 5, 38);
}
//home button
// fill(20, 200, 20);
// rect(400, 300, 100, 50, 20);
fill(homeColor);
textSize(25);
text("Home", 400, 290, 50);
if (dist(mouseX, mouseY, 400, 300) < 25) {
homeColor = 255;
} else {
homeColor = (12, 5, 38);
}
}
console.log(frameCount);
console.log(sceneNum);
}
//scene 98
function scene98() {
image(failbg, 300, 200, 600, 400);
noStroke();
if (frameCount > 0) {
//title
textAlign(CENTER);
fill(206, 0, 0);
textSize(20);
text(
"Oops! \n\nYou bumped into someone. \nBe more careful!",
305,
120,
400
);
}
if (frameCount > 0) {
fill(tryAgainColor);
textSize(25);
text("Restart", 215, 290, 50);
if (dist(mouseX, mouseY, 200, 300) < 25) {
tryAgainColor = 255;
} else {
tryAgainColor = (12, 5, 38);
}
//home button
fill(homeColor);
textSize(25);
text("Home", 400, 290, 50);
if (dist(mouseX, mouseY, 400, 300) < 25) {
homeColor = 255;
} else {
homeColor = (12, 5, 38);
}
}
console.log(frameCount);
console.log(sceneNum);
}
//scene101
function scene101() {
image(failbg, 300, 200, 600, 400);
noStroke();
if (frameCount > 0) {
//title
fill(206, 0, 0);
textSize(20);
text("Your mom walked away...\n \n Better walk faster!", 305, 145, 400);
}
if (frameCount > 0) {
//try again button
// fill(20, 200, 20);
// rect(200, 300, 100, 50, 20);
fill(tryAgainColor);
textSize(25);
text("Restart", 215, 290, 50);
if (dist(mouseX, mouseY, 200, 300) < 25) {
tryAgainColor = 255;
} else {
tryAgainColor = (12, 5, 38);
}
//home button
// fill(20, 200, 20);
// rect(400, 300, 100, 50, 20);
fill(homeColor);
textSize(25);
text("Home", 400, 290, 50);
if (dist(mouseX, mouseY, 400, 300) < 25) {
homeColor = 255;
} else {
homeColor = (12, 5, 38);
}
}
console.log(frameCount);
console.log(sceneNum);
}