xxxxxxxxxx
function setup() {
createCanvas(600, 400)
noStroke()
rectMode(CENTER)
// sound
song.loop()
// maze sets
for (var i = 0; i < 350; i++) {
// day 1
ppl1[i] = new ppl(random(270), random(300))
ppl2[i] = new ppl(random(350, width), random(120, height))
ppl3[i] = new ppl(random(350), random(380, height))
ppl4[i] = new ppl(random(270, width), random(40))
// day 2
ppl5[i] = new ppl(random(0, 100), random(0, 180))
ppl6[i] = new ppl(random(200, width), random(0, 30))
ppl7[i] = new ppl(random(100, 500), random(100, 170))
ppl8[i] = new ppl(random(580, 600), random(0, 400))
ppl9[i] = new ppl(random(350, 500), random(170, 310))
ppl10[i] = new ppl(random(100, 270), random(250, 320))
ppl11[i] = new ppl(random(0, 10), random(180, 400))
ppl12[i] = new ppl(random(250, 600), random(390, 400))
ppl13[i] = new ppl(random(200, 270), random(300, 400))
ppl14[i] = new ppl(random(10, 100), random(395, 400))
//day 3
ppl15[i] = new ppl(random(0, 600), random(0, 40))
ppl16[i] = new ppl(random(0, 600), random(360, 400))
ppl17[i] = new ppl(random(0, 40), random(0, 280))
ppl18[i] = new ppl(random(560, 600), random(0, 280))
ppl19[i] = new ppl(random(350, 450), random(120, 400))
ppl20[i] = new ppl(random(-20, 20), random(-110, 110))
//day 4
ppl22[i] = new ppl(random(80, 150), random(0, 320))
ppl23[i] = new ppl(random(260, 330), random(80, 400))
ppl24[i] = new ppl(random(450, 510), random(0, 320))
//day 5
ppl25[i] = new ppl(random(500), random(height))
}
// start
me[0] = new mainCharacter(dayX[0], dayY[0])
for (var i = 0; i < 100; i++) {
ppl21[i] = new ppl(random(width), random(-400, 0))
}
// game - day1
me[1] = new mainCharacter(dayX[1], dayY[1])
vicBut[0] = new button(width / 2 + 5, height - 55, 0)
hovers[1] = new hover(width / 2 + 5, height - 55, "#AECACE")
clicks[1] = new click(width / 2 + 5, height - 55, "#AECACE")
// game - day 2
me[2] = new mainCharacter(dayX[2], dayY[2])
hovers[2] = new hover(width / 2 + 5, height - 55, "#D3A08F")
clicks[2] = new click(width / 2 + 5, height - 55, "#D3A08F")
// game - day 3
me[3] = new mainCharacter(dayX[3], dayY[3])
hovers[3] = new hover(width / 2 + 5, height - 55, "#A0BAAF")
clicks[3] = new click(width / 2 + 5, height - 55, "#A0BAAF")
// game - day 4
me[4] = new mainCharacter(dayX[4], dayY[4])
hovers[4] = new hover(width / 2 + 5, height - 55, "#DE6E40")
clicks[4] = new click(width / 2 + 5, height - 55, "#DE6E40")
// game - day 5
me[5] = new mainCharacter(dayX[5], dayY[5])
me[6] = new mainCharacter(dayX[6], dayY[6])
}
function draw() {
background(150)
// texture
// push()
// blendMode(MULTIPLY)
// image(texture, 0, 0, 600, 400)
// pop()
//switch scenes
switch (sceneNum) {
case 0: // start
cursor(ARROW)
for (var i = 0; i < 100; i++) {
ppl21[i].show(me[0].x, me[0].y)
ppl21[i].move()
ppl21[i].y += 2
if (ppl21[i].y > 0) {
me[0].show()
me[0].move()
}
}
// Game title & instructions
let y = -500
let ydelta = y + frameCount * 1.5
if (ydelta > 0) {
ydelta = 0
// instructions come out later when game title sets at the right place
image(start, 0, 200, 600, 200, 0, 400, 1200, 400)
// start button
rect(500, 350, 100, 50, 20)
push()
textSize(20)
fill(255)
text("START", 468, 356)
pop()
if (450 < mouseX && mouseX < 550 && 328 < mouseY && mouseY < 378) {
push()
noFill()
stroke("#C0C3CA")
strokeWeight(5)
rect(500, 350, 100, 50, 20)
pop()
cursor(HAND)
if (mouseIsPressed) {
sceneNum = 1
}
}
}
// game title fly down
image(start, 0, ydelta, 600, 200, 0, 0, 1200, 400)
//texture
push()
blendMode(MULTIPLY)
image(texture, 0, 0, 600, 400)
pop()
break
case 1:
cursor(ARROW)
// day 1 maze set
for (var i = 0; i < 300; i++) {
ppl1[i].show(me[1].x, me[1].y)
ppl1[i].move()
if (ppl1[i].check(me[1].x, me[1].y)) {
me[1].x = dayX[1]
me[1].y = dayY[1]
}
ppl2[i].show(me[1].x, me[1].y)
ppl2[i].move()
if (ppl2[i].check(me[1].x, me[1].y)) {
me[1].x = dayX[1]
me[1].y = dayY[1]
}
}
for (var i = 0; i < 50; i++) {
ppl3[i].show(me[1].x, me[1].y)
ppl3[i].move()
if (ppl3[i].check(me[1].x, me[1].y)) {
me[1].x = dayX[1]
me[1].y = dayY[1]
}
}
for (var i = 0; i < 100; i++) {
ppl4[i].show(me[1].x, me[1].y)
ppl4[i].move()
if (ppl4[i].check(me[1].x, me[1].y)) {
me[1].x = dayX[1]
me[1].y = dayY[1]
}
}
// maincharacter
me[1].show()
me[1].move()
// dialog
if (me[1].x > 120 && me[1].x < 350) {
image(scene1, 0, 0, 300, 400, 0, 0, 600, 800)
}
if (me[1].x > 350) {
image(scene1, 300, 70, 300, 400, 600, 0, 600, 800)
}
//texture
push()
blendMode(MULTIPLY)
image(texture, 0, 0, 600, 400)
pop()
break
case 10: // victory - day 1
image(victory10, 0, 0, 600, 400)
vicBut[0].show()
//button words
textSize(20)
fill(255)
text("The Next Day...", 237, 352)
//button function
if (215 < mouseX && mouseX < 395 && 322 < mouseY && mouseY < 372) {
hovers[1].show()
cursor(HAND)
if (mouseIsPressed) {
clicks[1].show()
text("The Next Day...", 237, 352)
sceneNum = 2
}
} else {
hovers[1].hide()
cursor(ARROW)
}
//texture
push()
blendMode(MULTIPLY)
image(texture, 0, 0, 600, 400)
pop()
break
case 2:
cursor(ARROW)
// day 2 maze set
for (var i = 0; i < 120; i++) {
ppl5[i].show(me[2].x, me[2].y)
ppl5[i].move()
if (ppl5[i].check(me[2].x, me[2].y)) {
me[2].x = dayX[2]
me[2].y = dayY[2]
}
ppl7[i].show(me[2].x, me[2].y)
ppl7[i].move()
if (ppl7[i].check(me[2].x, me[2].y)) {
me[2].x = dayX[2]
me[2].y = dayY[2]
}
}
for (var i = 0; i < 70; i++) {
ppl6[i].show(me[2].x, me[2].y)
ppl6[i].move()
if (ppl6[i].check(me[2].x, me[2].y)) {
me[2].x = dayX[2]
me[2].y = dayY[2]
}
ppl8[i].show(me[2].x, me[2].y)
ppl8[i].move()
if (ppl8[i].check(me[2].x, me[2].y)) {
me[2].x = dayX[2]
me[2].y = dayY[2]
}
ppl9[i].show(me[2].x, me[2].y)
ppl9[i].move()
if (ppl9[i].check(me[2].x, me[2].y)) {
me[2].x = dayX[2]
me[2].y = dayY[2]
}
ppl10[i].show(me[2].x, me[2].y)
ppl10[i].move()
if (ppl10[i].check(me[2].x, me[2].y)) {
me[2].x = dayX[2]
me[2].y = dayY[2]
}
}
for (var i = 0; i < 40; i++) {
ppl11[i].show(me[2].x, me[2].y)
ppl11[i].move()
if (ppl11[i].check(me[2].x, me[2].y)) {
me[2].x = dayX[2]
me[2].y = dayY[2]
}
ppl12[i].show(me[2].x, me[2].y)
ppl12[i].move()
if (ppl12[i].check(me[2].x, me[2].y)) {
me[2].x = dayX[2]
me[2].y = dayY[2]
}
ppl13[i].show(me[2].x, me[2].y)
ppl13[i].move()
if (ppl13[i].check(me[2].x, me[2].y)) {
me[2].x = dayX[2]
me[2].y = dayY[2]
}
ppl14[i].show(me[2].x, me[2].y)
ppl14[i].move()
if (ppl14[i].check(me[2].x, me[2].y)) {
me[2].x = dayX[2]
me[2].y = dayY[2]
}
}
// maincharacter
me[2].show()
me[2].move()
// dialog
if (me[2].x > 360 && me[2].y < 110) {
image(scene2, 0, 0, 600, 200, 0, 0, 1200, 400)
}
if (me[2].x < 340 && me[2].y > 185 && me[2].y < 288) {
image(scene2, 0, 200, 600, 200, 0, 400, 1200, 400)
}
//texture
push()
blendMode(MULTIPLY)
image(texture, 0, 0, 600, 400)
pop()
break
case 20: // victory - day 2
image(victory20, 0, 0, 600, 400)
vicBut[0].show()
//button words
textSize(20)
fill(255)
text("The Next Day...", 237, 352)
//button function
if (215 < mouseX && mouseX < 395 && 322 < mouseY && mouseY < 372) {
hovers[2].show()
cursor(HAND)
if (mouseIsPressed) {
clicks[2].show()
text("The Next Day...", 237, 352)
sceneNum = 3
}
} else {
hovers[2].hide()
cursor(ARROW)
}
//texture
push()
blendMode(MULTIPLY)
image(texture, 0, 0, 600, 400)
pop()
break
case 3:
cursor(ARROW)
// day 3 maze set
for (var i = 0; i < 120; i++) {
ppl15[i].show(me[3].x, me[3].y)
ppl15[i].move()
if (ppl15[i].check(me[3].x, me[3].y)) {
me[3].x = dayX[3]
me[3].y = dayY[3]
}
ppl16[i].show(me[3].x, me[3].y)
ppl16[i].move()
if (ppl16[i].check(me[3].x, me[3].y)) {
me[3].x = dayX[3]
me[3].y = dayY[3]
}
push()
// translate(0, sin(frameCount / 40) * 50)
ppl19[i].show(me[3].x, me[3].y)
ppl19[i].move()
if (ppl19[i].check(me[3].x, me[3].y)) {
me[3].x = dayX[3]
me[3].y = dayY[3]
}
pop()
}
for (var i = 0; i < 70; i++) {
ppl17[i].show(me[3].x, me[3].y)
ppl17[i].move()
if (ppl17[i].check(me[3].x, me[3].y)) {
me[3].x = dayX[3]
me[3].y = dayY[3]
}
ppl18[i].show(me[3].x, me[3].y)
ppl18[i].move()
if (ppl18[i].check(me[3].x, me[3].y)) {
me[3].x = dayX[3]
me[3].y = dayY[3]
}
push()
translate(187, 200)
rotate(frameCount / 100)
ppl20[i].show(me[3].x, me[3].y)
ppl20[i].move()
if (ppl20[i].check(me[3].x, me[3].y)) {
me[3].x = dayX[3]
me[3].y = dayY[3]
}
pop()
}
// maincharacter
me[3].show()
me[3].move()
// dialog
if (me[3].x < 330 && me[3].y < 200) {
image(scene3, 0, 0, 600, 200, 0, 0, 1200, 400)
}
if (me[3].x < 210 && me[3].y > 200) {
image(scene3, 0, 200, 600, 200, 0, 400, 1200, 400)
}
//texture
push()
blendMode(MULTIPLY)
image(texture, 0, 0, 600, 400)
pop()
break
case 30: // victory - day 3
image(victory30, 0, 0, 600, 400)
vicBut[0].show()
//button words
textSize(20)
fill(255)
text("The Next Day...", 237, 352)
//button function
if (215 < mouseX && mouseX < 395 && 322 < mouseY && mouseY < 372) {
hovers[3].show()
cursor(HAND)
if (mouseIsPressed) {
clicks[3].show()
text("The Next Day...", 237, 352)
sceneNum = 4
}
} else {
hovers[3].hide()
cursor(ARROW)
}
//texture
push()
blendMode(MULTIPLY)
image(texture, 0, 0, 600, 400)
pop()
break
case 4:
cursor(ARROW)
// day 4 maze set
background("#e8c2a7")
for (var i = 0; i < 150; i++) {
ppl22[i].show(me[4].x, me[4].y)
ppl22[i].move()
if (ppl22[i].check(me[4].x, me[4].y)) {
me[4].x = dayX[4]
me[4].y = dayY[4]
}
ppl23[i].show(me[4].x, me[4].y)
ppl23[i].move()
if (ppl23[i].check(me[4].x, me[4].y)) {
me[4].x = dayX[4]
me[4].y = dayY[4]
}
ppl24[i].show(me[4].x, me[4].y)
ppl24[i].move()
if (ppl24[i].check(me[4].x, me[4].y)) {
me[4].x = dayX[4]
me[4].y = dayY[4]
}
}
// new black ball friend
circle(558, 28, 25)
push()
stroke(255)
strokeWeight(2)
point(553, 26)
point(562, 26)
pop()
//blood
if (me[4].x > 74) {
image(blood, 0, 0, 100, 400, 0, 0, 200, 800)
if (me[4].x < 240) {
image(scene4, 0, 0, 600, 400)
}
}
if (me[4].x > 240 && me[4].x < 500) {
image(blood, 0, 0, 300, 400, 0, 0, 600, 800)
if (me[4].y < 260) {
image(scene42, 0, 200, 600, 200, 0, 400, 1200, 400)
}
}
if (me[4].x > 421) {
image(blood, 0, 0, 600, 400, 0, 0, 1200, 800)
image(scene42, 0, 0, 600, 200, 0, 0, 1200, 400)
}
// main character & knife
me[4].show()
me[4].move()
image(knife, me[4].x - 25, me[4].y, 30, 20)
//texture
push()
blendMode(MULTIPLY)
image(texture, 0, 0, 600, 400)
pop()
break
case 40: // victory - day 3
image(victory40, 0, 0, 600, 400)
vicBut[0].show()
//button words
textSize(20)
fill(255)
text("The Last Day...", 237, 352)
//button function
if (215 < mouseX && mouseX < 395 && 322 < mouseY && mouseY < 372) {
hovers[4].show()
cursor(HAND)
if (mouseIsPressed) {
clicks[4].show()
text("The Last Day...", 237, 352)
sceneNum = 5
}
} else {
hovers[4].hide()
cursor(ARROW)
}
//texture
push()
blendMode(MULTIPLY)
image(texture, 0, 0, 600, 400)
pop()
break
case 5:
cursor(ARROW)
// day 5 maze set
image(finish, 0, 0, 600, 400)
// set a number count from 0 to 350
if (frameCount % 5 == 0 && timer < 350) {
timer++
}
// random people disappear by - timer
for (var i = 0; i < 350 - timer * 1.5; i++) {
ppl25[i].show(me[sceneNum].x, me[sceneNum].y)
ppl25[i].move()
if (ppl25[i].check(me[5].x, me[5].y)) {
me[5].x = dayX[5]
me[5].y = dayY[5]
me[6].x = dayX[6]
me[6].y = dayY[6]
}
}
//dialog
if (0 < timer && timer < 50) {
image(scene5, 0, 0, 600, 120, 0, 0, 1200, 240)
}
if (50 < timer && timer < 100) {
image(scene5, 0, 120, 600, 100, 0, 240, 1200, 200)
}
if (100 < timer && timer < 180) {
image(scene5, 0, 220, 600, 150, 0, 440, 1200, 300)
}
// main characters
me[5].show()
me[5].move()
me[6].show()
me[6].move()
//texture
push()
blendMode(MULTIPLY)
image(texture, 0, 0, 600, 400)
pop()
break
case 50:
image(end, -10, -10, 600, 400)
// play again button
translate(-400, 0)
fill(0)
rect(500, 350, 150, 50, 20)
push()
textSize(20)
fill(255)
text("PLAY AGAIN", 442, 356)
pop()
// click function
if (25 < mouseX && mouseX < 176 && 328 < mouseY && mouseY < 378) {
push()
noFill()
stroke("#C0C3CA")
strokeWeight(5)
rect(500, 350, 150, 50, 20)
pop()
cursor(HAND)
if (mouseIsPressed) {
sceneNum = 0
return
}
}
//texture
push()
blendMode(MULTIPLY)
image(texture, 400, 0, 600, 400)
pop()
break
}
}