xxxxxxxxxx
769
//The pixel art in this game come from various anonymous contributors on pixelart.org and pixelmaker.com; the music in this game is credited to Big Birds Date Night Full Version on Twin Musicom (twinmusicom.org).
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 firePic
let fire
let life
let link
let narpic
let narrator
let scream
let sceneSelection = false
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')
firePic = loadImage('assets/fire.png')
ost= loadSound('assets/ost.mp3')
scream =loadSound('scream.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));
}
//create girl
girl = new Girl()
savedTime = millis() / 1000; // make sure to move this to scene1 once you set up the scene squence
//create fire
fire = new Fire()
//create narrator
narrator = new Narrator()
//music
ost.loop()
//link
link = createA("https://www.youtube.com/watch?v=bEKNFX7LWRk&t=43s", "this video")
}
function draw() {
background(0);
//scene0();
//scene1();
//scene2(); //detection of lives
//sceneAlt(); // press return to return, press space to go to Alt1
//sceneAlt1(); //press space
//sceneAlt2(); //detection of collision
//scenefinal(); //press space
// 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);
//end game
if (narrator.collided == true && sceneNum == 5) {
sceneNum = 6
}
switch (sceneNum) {
case 0:
scene0();
break;
case 1:
scene1();
break;
case 2:
scene2();
break;
case 3:
sceneAlt();
break;
case 4:
sceneAlt1();
break;
case 5:
sceneAlt2();
break;
case 6:
scenefinal();
break;
}
}
function keyPressed() {
if (keyCode === UP_ARROW) {
if (collectedneeds > 4) {
fire.body();
fire.move();
}
}
if (keyCode === 32) {
if (sceneNum < 2) {
sceneNum+=1;
}
if (sceneNum == 3 | sceneNum == 4 ) {
sceneNum+=1;
}
if (sceneNum == 6) {
sceneNum = 0;
link.position(0,600);
collectedmakeup = 0;
collecteditems = 0;
avoidedneeds = 0;
collectedneeds = 0;
girlLives = 4;
sceneSelection = false;
}
}
if (keyCode === RETURN) {
if (sceneNum == 3 ) {
sceneNum = 2
}
}
//return false
}
function currentLives() {
for (let i = 0; i < girlLives; i++) {
image(life,15,height-i*20-50,life.width/45,life.height/45)
}
if (avoidedneeds >= 20) {
girlLives-=1;
avoidedneeds = 0;
}
}
function scene0(){
clear();
background(0);
rectMode(CENTER);
image(girlpic, width/2-120, 20,girlpic.width/1.2,girlpic.height/1.2);
push();
fill(0,0,255);
textSize(25);
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.', width/2, 480, 495, 500);
pop();
}
function scene1(){
clear();
background(0);
push();
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.', width/2, 80, 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.', width/2, 410, 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.', width/2, 550, 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.”', width/2, 700, 495, 550)
pop();
push();
fill(0,0,255)
textFont(pixel)
textAlign(CENTER)
textSize(20)
text('Use left and right arrow to control your character.Press Space to start the game.', width/2, 780, 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) ;
let h = -collecteditems*10 + collectedneeds*30
if (h >= 0) {
h = 0;
}
rect(30,240,20,h);
pop();
push();
fill(255);
textSize(15);
text('coolness level',45,290,30,80) ;
pop();
//emotional health bar
if (avoidedneeds < 15) {
push();
let c = 'rgb(255,182,193)';
fill(c);
rectMode(CENTER);
rect(40,350,20,70);
pop();
} else {
push();
let c = 'rgb(255,0,0)';
fill(c);
rectMode(CENTER);
rect(40,350,20,70);
pop();
}
push();
fill(0);
rectMode(CORNER);
rect(30,315,20,avoidedneeds*3.5);
pop();
push();
fill(255)
textSize(15)
text('emotional health',45,450,30,70)
pop();
//display current lives
currentLives();
//sceneSwitch
if (girlLives < 2 && sceneNum == 2 && sceneSelection == false) {
sceneNum = 3
}
}
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.', width/2, 150, 495, 200);
// //graphic timer
// clear();
// background(0);
// fill(255,255,0);
// textSize(25);
// textFont(pixel)
// textAlign(CENTER)
push();
imageMode(CENTER);
image(girlpic, width/2-5, 455, 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."',width/2, 300, 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.',width/2 , 440, 495, 200);
sceneSelection = true;
}
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 more than 5 emotional needs to build your ammunition and using the up arrow to fire at the narrator. Press Space to proceed.',width/2, 250, 495, 200);
}
function sceneAlt2() {
clear();
background(0);
//reset collectedneeds
collectedneeds = 0
//draw needs
for (let i = 0; i < 5 ; i++) {
needs[i].body();
needs[i].move();
needs[i].checkCollision();
}
//draw player
girl.body();
girl.move();
//narrator
narrator.body();
narrator.move();
narrator.checkCollision();
//fire
keyPressed();
//side bar
push();
rectMode(CORNER);
// stroke(255)
// strokeWeight(1)
fill(0,0,120);
rect(0,0,85,height);
pop();
//display current lives
currentLives();
}
function scenefinal() {
clear();
background(0);
fill(255,255,0);
textSize(27);
textFont(pixel)
textAlign(CENTER)
text('Game Over', width/2, 150, 495, 50)
textSize(20);
text('You have succeeded in killing the narrator. Good job! To learn more about "the cool girl" -- the character trope created by and for male fantasy in popular media, check out', width/2, 270, 480, 200);
link.position(width/2-30,325)
text('Press Space to play again', width/2, 450, 480, 100)
}
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;
}
body(index){
// 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) {
console.log("bumped!");
//this.collided = true
collecteditems+=1
this.y = 100
this.x = random(100,width)
//console.log(collecteditems)
}
}
}
class Need {
constructor(x,y){
this.x = x;
this.y = y;
this.w = 30;
}
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) {
avoidedneeds+=1;
//console.log(avoidedneeds)
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) {
//console.log("bumped!");
//this.collided = true;
collectedneeds+=1;
console.log(collectedneeds);
this.y = 100;
this.x = random(100,width);
}
}
}
class Fire {
constructor(x,y) {
this.x = width/2 + 55;
this.y = height - 30;
}
body() {
push()
imageMode(CENTER)
image(firePic,this.x , this.y, firePic.width/5, firePic.height/5);
pop()
}
move() {
d = int(dist(this.x,this.y,narrator.x,narrator.y));
if (d > 30) {
this.y--
}
}
// checkCollision() {
// d = int(dist(this.x,this.y,narrator.x,narrator.y));
// //console.log(d);
// if (d < 30 && this.collided == false ) {
// console.log("hit!");
// this.collided = true
// this.y = -10
// }
// }
}
class Makeup {
constructor(x,y){
this.x = x;
this.y = y;
this.w = 10;
this.h = 10;
}
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)
}
}
checkCollision(){
d = int(dist(this.x,this.y,girl.x,girl.y));
//console.log(d);
if (d < girl.w/1.5 ) {
console.log("bumped!");
collectedmakeup+=1
this.y = 100
this.x = random(100,width)
console.log(collectedmakeup)
}
}
}
class Narrator {
constructor(){
this.x = random(width/2+10, width/2+45);
this.y = 55;
this.collided = false
}
move() {
this.x =random(width/2+35, width/2 +45);
}
body() {
push()
imageMode(CENTER)
image(narpic,this.x, this.y,narpic.width, narpic.height)
pop()
}
checkCollision() {
d = int(dist(this.x,this.y,fire.x,fire.y));
//console.log(d);
if (d < 30 && this.collided == false) {
console.log("hit!");
this.collided = true
scream.play();
//play some sound effect
//each time draw() is called, i is incremented by one
// let i = 0;
// 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);
// }
}
}
}