xxxxxxxxxx
654
let sceneNum = 0
let itemNum = 5
let items = []
let needs = []
let makeup = []
let itemImg = []
let needImg = []
let collectedmakeup = 0
let collecteditems = 0
let avoidedneeds = 0
let collectedneeds = 0
let girlLives = 4
let girl
let d
let savedTime
let newSavedTime
let girlpic
let pixel
let circlePic
let ballPic
let makeupPic
let beerPic
let circle1Pic
let life
let narpic
function preload() {
girlpic = loadImage('assets/girl.png')
circlePic = loadImage('assets/circle.png')
circle1Pic = loadImage('assets/circle1.png')
ballPic = loadImage('assets/ball.png')
makeupPic = loadImage('assets/makeup.png')
beerPic = loadImage('assets/Beer.png')
life = loadImage('assets/life.png')
pixel = loadFont('assets/pixel1.ttf')
narpic = loadImage('eye.png')
ost= loadSound('assets/ost.mp3')
//load needs
for (let i = 0; i < 5; i++) {
needImg[i] = loadImage('assets/need'+ i + '.png')
}
//load items
for (let i = 0; i < 6; i++) {
itemImg[i] = loadImage('assets/item'+ i + '.png')
}
}
function setup() {
createCanvas(600, 600);
//create items
for (let i = 0; i < 6; i++) {
items[i] = new Item (random(100,width),random(100, height-100));
}
//create needs
for (let i = 0; i < 5; i++) {
needs[i] = new Need (random(100,width),random(100, height-100));
}
//create makeup
for (let i = 0; i < 3; i++) {
makeup[i] = new Makeup (random(100,width),random(100, height-100));
}
girl = new Girl()
savedTime = millis() / 1000; // make sure to move this to scene1 once you set up the scene squence
//music
ost.loop()
}
function draw() {
background(0);
//scene0();
//scene1();
//scene2();
//sceneAlt();
//sceneAlt1();
sceneAlt2();
// image(itemImg[0], 10, 10, itemImg[0].width/20, itemImg[0].height/20);
// for (let i = 0; i < 6; i++) {
// image(itemImg[i], 10, 10, itemImg[i].width * 0.6, itemImg[i].height * 0.6);
// switch (sceneNum) {
// case 0:
// scene0();
// break;
// case 1:
// scene1();
// break;
// case 2:
// console.log("scene2")
// break;
// }
}
function scene0(){
clear();
background(0);
image(girlpic, 200, 20, girlpic.width/1.2,girlpic.height/1.2);
fill(0,0,255);
textSize(27);
textFont(pixel)
textAlign(CENTER)
text('"Hello! Welcome to the cool girl challenge. A cool girl is carefree. A cool girl never gets angry.A cool girl acts like one of the guys but is also effortlessly hot. Are you ready to be the cool girl?" Press Space to proceed.', 70, 230, 495, 500);
}
function scene1(){
clear();
background(0);
fill(255);
textSize(15);
textFont(pixel)
textAlign(CENTER)
//rules
text('“Items like this below reflect stereotypical male interests. You must pick up as many of them as possible.', 70, 30, 495, 100);
image(ballPic, 247, 100, ballPic.width/23, ballPic.height/23);
image(beerPic, 315, 95, beerPic.width/8, beerPic.height/8);
text('Circles like this below represents your emotional needs.You must avoid them at all cost, because a cool girl is not needy.', 70, 170, 495, 500);
image(circlePic, 250, 240, circlePic.width/9, circlePic.height/9);
image(circle1Pic, 320, 245, circle1Pic.width/9, circle1Pic.height/9);
text('You must also be effortlessly hot, so you would need to pick up 2 or 3 makeups every minute. But not too many.', 70, 310, 495, 500)
image(makeupPic, 295, 360, makeupPic.width/13, makeupPic.height/13);
text('The purple bar represents your level of coolness.When you follow the three rules above, it will go up. Your goal is to keep it as high as you can.”', 70, 435, 495, 550)
push()
fill(0,0,255)
textSize(20)
text('Press Space to start the game', 70, 530, 495, 550)
pop()
savedTime = millis() / 1000;
}
function scene2(){
clear();
background(0);
//draw items
for (let i = 0; i < 6 ; i++) {
items[i].body(i);
items[i].move();
items[i].checkCollision();
}
//draw needs
for (let i = 0; i < 5 ; i++) {
needs[i].body();
needs[i].move();
needs[i].checkCollision();
}
//draw makeup
for (let i = 0; i < 3 ; i++) {
makeup[i].body();
makeup[i].move();
makeup[i].checkCollision();
}
//draw player
girl.body();
girl.move();
//message on makeup
let passedTime = millis() / 1000 - savedTime;
if (passedTime > 100) {
collectedmakeup = 0
savedTime = millis() / 1000;
}
textFont(pixel)
textSize(20)
textAlign(CENTER)
if(collectedmakeup > 2 && collectedmakeup <= 5) {
fill(255,255,0)
text('"congrats, you have met the beauty standard of a cool girl."', width/2 + 50, 70, 500, 100)
}
else if (collectedmakeup > 5) {
fill(255,255,0)
text('"You put too much effort into your appearance. You have failed to be effortlessly hot as a cool girl."', width/2 + 50, 65, 500, 100)}
else if (collectedmakeup <= 2 ) {
fill(255,255,0)
text('"You are too unkempt for a cool girl. Get more makeup."', width/2 + 50, 70, 520, 100)}
//side bar
push();
rectMode(CORNER);
//fill(240,230,140)
//fill(65,105,225)
// stroke(255)
// strokeWeight(1)
fill(0,0,120)
rect(0,0,85,height)
pop();
//coolness level bar
push();
fill(138,43,226);
rectMode(CORNER) ;
rect(30,240,20,-collecteditems*10);
pop();
push();
fill(255);
textSize(15)
text('coolness level',45,290,30,80)
pop();
//emotional health bar
if (avoidedneeds < 20) {
let c = 'rgb(255,182,193)'
fill(c);
rectMode(CENTER);
rect(40,350,20,70);
} else {
let c = 'rgb(255,0,0)'
fill(c);
rectMode(CENTER);
rect(40,350,20,70);
}
push();
fill(0);
rectMode(CORNER);
rect(30,315,20,avoidedneeds*2.5);
pop();
push();
fill(255)
textSize(15)
text('emotional health',45,450,30,70)
pop();
//display current lives
currentLives();
}
function sceneAlt() {
clear();
background(0);
//image(girlpic, 200, 20, girlpic.width/1.2,girlpic.height/1.2);
fill(255,255,0);
textSize(20);
textFont(pixel)
textAlign(CENTER)
text('The message shows up because you only have one life left. It seems that you have lost lives because you have been neglecting your emotional health.', 70, 100, 495, 200);
// //graphic timer
// clear();
// background(0);
// fill(255,255,0);
// textSize(25);
// textFont(pixel)
// textAlign(CENTER)
push();
imageMode(CENTER);
image(girlpic, width/2+10, 370, girlpic.width/8,girlpic.height/8);
pop();
text('"Keep going! You are almost at the top of your coolness level. You can use your last life to fully become a cool girl."',70, 250, 495, 200);
text('Press return to follow the narrator and continue with the game. Press Space if you want to challenge the rules of the game.',70, 400, 495, 200);
}
function sceneAlt1() {
clear();
background(0);
fill(255,255,0);
textSize(20);
textFont(pixel)
textAlign(CENTER)
text('To rewrite the rules, you must destroy the narrator of the game. In your remaining time at the game, collect the emotional needs as your ammunition and using the up arrow to fire at the narrator. Press Space to proceed.', 70, 200, 495, 200);
}
function sceneAlt2() {
clear();
background(0);
textAlign(CENTER)
textFont(pixel)
//draw items
for (let i = 0; i < 6 ; i++) {
items[i].body(i);
items[i].move();
items[i].checkCollision();
}
//draw needs
for (let i = 0; i < 5 ; i++) {
needs[i].body();
needs[i].move();
needs[i].checkCollision();
}
//draw makeup
for (let i = 0; i < 3 ; i++) {
makeup[i].body();
makeup[i].move();
makeup[i].checkCollision();
}
//draw player
girl.body();
girl.move();
//narrator
//side bar
push();
rectMode(CORNER);
//fill(240,230,140)
//fill(65,105,225)
// stroke(255)
// strokeWeight(1)
fill(0,0,120)
rect(0,0,85,height)
pop();
// //coolness level bar
// push();
// fill(138,43,226);
// rectMode(CORNER) ;
// rect(30,240,20,-collecteditems*10);
// pop();
// push();
// fill(255);
// textSize(15)
// text('coolness level',45,290,30,80)
// pop();
// //emotional health bar
// if (avoidedneeds < 20) {
// let c = 'rgb(255,182,193)'
// fill(c);
// rectMode(CENTER);
// rect(40,350,20,70);
// } else {
// let c = 'rgb(255,0,0)'
// fill(c);
// rectMode(CENTER);
// rect(40,350,20,70);
// }
// push();
// fill(0);
// rectMode(CORNER);
// rect(30,315,20,avoidedneeds*2.5);
// pop();
// push();
// fill(255)
// textSize(15)
// text('emotional health',45,450,30,70)
// pop();
//display current lives
currentLives();
}
function currentLives() {
for (let i = 0; i < girlLives; i++) {
image(life,15,height-i*20-50,life.width/45,life.height/45)
}
if (avoidedneeds > 30) {
girlLives-=1;
avoidedneeds = 0;
}
}
class Girl {
constructor(){
this.x = width/2 + 55;
this.y = height - 30;
this.w = 40;
this.h = 40;
}
body(){
push();
imageMode(CENTER);
image(girlpic,this.x,this.y,girlpic.width/5,girlpic.height/5);
pop();
}
move(){
if (keyIsDown(39)) {
girl.x++
}
if (keyIsDown(37)) {
girl.x--
}
}
}
class Item {
constructor(x,y){
this.x = x;
this.y = y;
this.w = 30;
this.h = 30;
this.collided = false;
}
body(index){
rectMode(CENTER);
// rect(this.x, this.y, this.w, this.h);
push();
imageMode(CENTER);
image(itemImg[index], this.x, this.y, itemImg[index].width*0.8, itemImg[index].height*0.8);
pop();
}
move(){
this.y++
if (this.y > height) {
this.y = 100
this.x = random(100,width)
this.collided = false
}
}
checkCollision(){
d = int(dist(this.x,this.y,girl.x,girl.y));
//console.log(d);
if (d < girl.w/1.5 && this.collided == false ) {
console.log("bumped!");
this.collided = true
collecteditems+=1
this.y = 100
//console.log(collecteditems)
}
}
}
class Need {
constructor(x,y){
this.x = x;
this.y = y;
this.w = 30;
this.collided = false;
}
body(){
push();
//ellipse(this.x, this.y, this.w);
imageMode(CENTER);
image(needImg[0], this.x , this.y, needImg[0].width/10, needImg[0].height/10);
pop();
}
move(){
this.y++
if (this.y > height) {
if(this.collided == false) {
avoidedneeds+=1;
//console.log(avoidedneeds)
}
else {
this.collided = false;
}
this.y = 100;
this.x = random(100,width);
}
}
checkCollision() {
d = int(dist(this.x,this.y,girl.x,girl.y));
//console.log(d);
if (d < girl.w/1.5 && this.collided == false ) {
//console.log("bumped!");
this.collided = true
collectedneeds+=1
this.y = 100
}
}
}
class Makeup {
constructor(x,y){
this.x = x;
this.y = y;
this.w = 10;
this.h = 10;
this.collided = false;
}
body(){
push();
imageMode(CENTER);
rect(this.x, this.y, this.w, this.h);
image(makeupPic,this.x, this.y, makeupPic.width/17, makeupPic.height/17);
pop();
}
move(){
this.y++
if (this.y > height) {
this.y = 100
this.x = random(100,width)
this.collided = false
}
}
checkCollision(){
d = int(dist(this.x,this.y,girl.x,girl.y));
//console.log(d);
if (d < girl.w/1.5 && this.collided == false ) {
console.log("bumped!");
this.collided = true
collectedmakeup+=1
this.y = 100
console.log(collectedmakeup)
}
}
}
class Narrator {
constructor(){
this.x = random(width/2-90, width/2 -80);
this.y = -50;
this.collided = false;
}
body() {
image(narpic,this.x, this.y,narpic.width, narpic.height)
}
checkCollision(){
d = int(dist(this.x,this.y,need.x,need.y));
//console.log(d);
if (d < need.w/1.5 && this.collided == false ) {
console.log("hit!");
this.collided = true
hittimes+=1
if (hittimes > 5) {
// each time draw() is called, i is incremented by one
i = i + 1
// every 10th time, the condition is true
if (i % 10 === 0){
} else {
// all the otehr times, fill with 255
fill(255);
rect(this.x,this.y,narpic.width,narpic.height);
}
}
}
}
}