Jessica - Project 2

By Jessica Thornburgh
int page = 1; Me me1; Me me2; People p1; People p2; People p3; People d1; People d2; People d3; PImage welcome; PImage me; PImage mespace; PImage bruinwalk; PImage girl; PImage guy; PImage boy; PImage deadgirl; PImage deadguy; PImage deadboy; PImage gameover; PImage win; boolean mepush = false; float backgroundx = 0; int numFrames = 5; int frame = 0; void setup() { size(600,400); smooth(); frameRate(60); welcome = loadImage("welcome.png"); me = loadImage("colorme1.png"); mespace = loadImage("colormepush.png"); bruinwalk = loadImage("longbackground.png"); girl = loadImage("colorpeoplegirl.png"); guy = loadImage("colorpeopleman.png"); boy = loadImage("colorpeopleboy.png"); deadgirl = loadImage("colorpeoplegirldead.png"); deadguy = loadImage("colorpeopleguydead.png"); deadboy = loadImage("colorpeopleboydead.png"); gameover = loadImage("gameover.png"); win = loadImage("win.png"); me1 = new Me(me, 50, 500, 80); me2 = new Me(mespace, 70, 400, 80); p1 = new People(girl, 700, 250, 3.0, 80); p2 = new People(guy, 720, 250, 3.5, 80); p3 = new People(boy, 740, 250, 4.0, 80); } void keyPressed() { if ((page == 1) && (key == ' ')) { page = 2; } else if ((page == 2) && (key == ' ')) { mepush = true; } else if ((page == 3) && (key == ' ')) { page = 1; p1.reset(); p2.reset(); p3.reset(); } } void keyReleased() { if (page == 2) { mepush = false; } } void draw() { if (page == 1) { image(welcome, 0,0, 600, 400); } else if (page == 2) { backgroundx = backgroundx-1.5; backgroundx = constrain(backgroundx, width-bruinwalk.width-500, 0); image(bruinwalk, backgroundx, 0, 3600, 400); color c = get(int (me1.x), int (me1.y-150)); if (red(c) == 89) { image(win, 0, 0 , 600, 400); page = 4; } frame++; if (frame ==numFrames) { frame = 0; } me1.display(); me2.display(); p1.display(); p2.display(); p3.display(); p1.move(); p2.move(); p3.move(); if (mepush == false) { if (p1.collide != true && 120 > p1.x && //if i collide with a person because i failed to hit space in time then i must die me1.x < (p1.x + p1.w)) { page = 3; } } if (mepush == true) { if (130 >= p1.x && //if i collide with a person while pushing they must die 100 < (p1.x + p1.w)) { p1.collide = true; } } if (mepush == true) { if (130 >= p2.x && //if i collide with a person while pushing they must die 100 < (p2.x + p2.w)) { p2.collide = true; } } if (mepush == true) { if (130 >= p3.x && //if i collide with a person while pushing they must die 100 < (p3.x + p3.w)) { p3.collide = true; } } } else if (page == 3) { image(gameover, 0, 0, 600, 400); p1.reset(); p2.reset(); p3.reset(); backgroundx=0; } else if (page == 4) { image(win, 0, 0, 600, 400); } } class Me { float x; float y; float w; PImage img; Me (PImage pic, float xpos, float ypos, float win) { img = pic; x = xpos; y = ypos; w = win; } void display () { if (keyPressed ==false) { image(me, 60, 280, 80, 120); } if (mepush == true) { image(mespace, 100, 270, 80, 130); } } } class People { float x; float y; float xstart; float ystart; float w; float speed; PImage img; PImage img2; boolean collide = false; int peopleType; int direction = -1; People (PImage pic, float xpos, float ypos, float sp, float win) { x = xpos; y = ypos; xstart = xpos; ystart = ypos; speed = sp; img = pic; img2 = pic; w = win; peopleType = int(random(1, 4)); if (peopleType == 1) { img = girl; img2 = deadgirl; } else if (peopleType == 2) { img = guy; img2 = deadguy; } else if (peopleType == 3) { img = boy; img2 = deadboy; } } void move() { x += (speed*direction+1); if (x<-img.width){ collide = false; x = xstart; peopleType= int(random(1,3.1)); if (peopleType == 1){ img = girl; img2 = deadgirl; } else if (peopleType ==2){ img= guy; img2 = deadguy; } else if (peopleType ==3){ img= boy; img2 = deadboy; } } } void reset() { collide = false; x = xstart; peopleType = int(random(1, 3.1)); if(peopleType == 1) { img = girl; } else if (peopleType == 2) { img = guy; } else if (peopleType == 3) { img = boy; } } void display() { if (collide == false) { image(img, x, 280, 80, 130); //randomly selcted people image appears } else if (collide == true) { //if we collide at the mespace location the person dies so image(img2, x, 300, 55, 100); //the dead image appearsif (mepush == true) { } } }

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*