xxxxxxxxxx
440
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 girlLives = 4
let girl
let d
let savedTime
let girlpic
let pixel
let circlePic
let ballPic
let makeupPic
let beerPic
let circle1Pic
let life
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')
//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 delete this once you set up the scene
}
function draw() {
background(0);
//scene0();
//scene1();
scene2();
// 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(i);
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, 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, 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, 70, 520, 100)}
//coolness level bar
push();
fill(138,43,226);
rectMode(CORNER) ;
rect(30,240,20,-collecteditems*10);
pop();
textSize(15)
text('coolness level',45,290,30,80)
//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,310,20,avoidedneeds*2.5);
pop();
textSize(15)
text('emotional health',45,450,30,70)
//display current lives
currentLives();
}
function currentLives() {
for (let i = 0; i < girlLives; i++) {
image(life,0,height-i*25-30,life.width/45,life.height/45)
}
if (avoidedneeds > 30) {
girlLives-=1;
avoidedneeds = 0;
}
}
class Girl {
constructor(){
this.x = width/2;
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/2 && 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(index){
push();
ellipse(this.x, this.y, this.w);
imageMode(CENTER);
image(needImg[index], this.x, this.y, needImg[index].width/10, needImg[index].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/2 && this.collided == false ) {
//console.log("bumped!");
this.collided = true
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/2 && this.collided == false ) {
console.log("bumped!");
this.collided = true
collectedmakeup+=1
this.y = 100
console.log(collectedmakeup)
}
}
}