diff --git a/data/bucket.jpg b/data/bucket.jpg new file mode 100644 index 0000000..38cbbfb Binary files /dev/null and b/data/bucket.jpg differ diff --git a/data/bucket.png b/data/bucket.png new file mode 100644 index 0000000..9678fd5 Binary files /dev/null and b/data/bucket.png differ diff --git a/data/emilyhappy.png b/data/emilyhappy.png new file mode 100644 index 0000000..11b423d Binary files /dev/null and b/data/emilyhappy.png differ diff --git a/data/emilysad.png b/data/emilysad.png new file mode 100644 index 0000000..a77cf1b Binary files /dev/null and b/data/emilysad.png differ diff --git a/raindropGameCode/Bucket.pde b/raindropGameCode/Bucket.pde new file mode 100644 index 0000000..417415d --- /dev/null +++ b/raindropGameCode/Bucket.pde @@ -0,0 +1,13 @@ +class Bucket { + PImage bucket; + PVector pos; + + Bucket(float x, float y){ + bucket = loadImage("bucket.png"); + pos = new PVector(mouseX, height-375); + } + + void display(){ + image(bucket, mouseX-420 ,pos.y); + } +} \ No newline at end of file diff --git a/raindropGameCode/Raindrop.pde b/raindropGameCode/Raindrop.pde new file mode 100644 index 0000000..9c90a33 --- /dev/null +++ b/raindropGameCode/Raindrop.pde @@ -0,0 +1,42 @@ +class Raindrop { + //declaring all info contained within Raindrop class + PVector loc, vel, acc; + //int diam; + PImage sushi; + + Raindrop(float x, float y) { + //diam = 50; + loc = new PVector(random(90, width-90), 0); + vel = new PVector (0, 5); + acc = new PVector(0, 2); + sushi = loadImage("sushi.png"); + sushi.resize(90, 90); + } + + void display() { + fill(0, 200, 255, 200); + noStroke(); + //ellipse(loc.x, loc.y, diam, diam); + image(sushi, loc.x, loc.y); + } + + void fall() { + loc.add(vel); + vel.add(acc); + vel.limit(15); + } + + boolean isInContactWith(PVector mouth) { + if (loc.dist(mouth) <= 60) { + println("caught it in frame " + frameCount); + return true; + } else { + return false; + } + } + void reset() { + loc = new PVector(random(90, width-90), 0); + vel = new PVector (0, 5); + //ellipse(loc.x, loc.y, diam, diam); + } +} \ No newline at end of file diff --git a/raindropGameCode/data/bucket.jpg b/raindropGameCode/data/bucket.jpg new file mode 100644 index 0000000..38cbbfb Binary files /dev/null and b/raindropGameCode/data/bucket.jpg differ diff --git a/raindropGameCode/data/bucket.png b/raindropGameCode/data/bucket.png new file mode 100644 index 0000000..9678fd5 Binary files /dev/null and b/raindropGameCode/data/bucket.png differ diff --git a/raindropGameCode/data/emilyhappy.png b/raindropGameCode/data/emilyhappy.png new file mode 100644 index 0000000..f860724 Binary files /dev/null and b/raindropGameCode/data/emilyhappy.png differ diff --git a/raindropGameCode/data/emilysad.png b/raindropGameCode/data/emilysad.png new file mode 100644 index 0000000..10845b4 Binary files /dev/null and b/raindropGameCode/data/emilysad.png differ diff --git a/raindropGameCode/data/sushi.png b/raindropGameCode/data/sushi.png new file mode 100644 index 0000000..aafd661 Binary files /dev/null and b/raindropGameCode/data/sushi.png differ diff --git a/raindropGameCode/raindropGameCode.pde b/raindropGameCode/raindropGameCode.pde index 944de61..1aab006 100644 --- a/raindropGameCode/raindropGameCode.pde +++ b/raindropGameCode/raindropGameCode.pde @@ -1,26 +1,113 @@ -PVector mouse; //declare a P -Raindrop r; //declare a new Raindrop called r - -// On your own, create an array of Raindrop objects instead of just one -// Use the array instead of the single object -// You can start out by just using the single Raindrop as you test - +PVector mouth; //declaring variables +Bucket b; +float game; +int timer; +ArrayList particles = new ArrayList(); +int interval; +int score; +int loss; +PImage happy; +PImage sad; void setup() { - size(1200, 800); - mouse = new PVector(); //initialize mouse PVector. value is irrelevant since it will be set at the start of void draw(){} - r = new Raindrop(random(width), 0); //Initialize r. The parameters used are the initial x and y positions + size(800, 600); + mouth = new PVector(); //declaring values + b = new Bucket(mouseX, height-375); + happy = loadImage("emilyhappy.png"); + sad = loadImage("emilysad.png"); + + for (int i = 0; i < 2; i++) { //add sushi + particles.add(new Raindrop(random(width), -random(height))); + } } void draw() { - mouse.set(mouseX, mouseY); //set value of mouse as mouseX,mouseY - background(0, 200, 255); - r.fall(); //make the raindrop fall. It should accelerate as if pulled towards the ground by earth's gravity - r.display(); //display the raindrop - if (r.isInContactWith(mouse)) { //check to see if the raindrop is in contact with the point represented by the PVector called mouse - r.reset(); //if it is, reset the raindrop + background(0); + + if (game == 0) { //start screen + textSize(75); + textAlign(CENTER, CENTER); + fill(205, 92, 92); + text("Hangry Emily", width/2, height/4); + fill(188, 143, 143); + textSize(50); + String s = "Feed Emily sushi to make her happy! (Click to begin)"; + text(s, width/7, height/6, 3*width/4, 3*height/4); } - if (r.loc.y > height + r.diam/2) { //check to see if the raindrop goes below the bottom of the screen - r.reset(); //if it does, reset the raindrop + + if (game == 1) { + mouth.set(mouseX, height-130); //setting mouth position + b.display(); + text("Yum level = " + score, width/4, 100); //Score board + + for (int i = particles.size()-1; i >= 0; i--) { //using array of sushi particles + Raindrop r = particles.get(i); //get the Particle in location i and store it in Particle p + + r.fall(); //make the sushi fall. It should accelerate as if pulled towards the ground by earth's gravity + r.display(); //display the sushi + + if (r.isInContactWith(mouth)) { //check to see if the sushi is in contact with the point represented by the PVector called mouse + r.reset(); //if it is, reset the sushi + timer = frameCount; + score+=1; + } + + if (r.loc.y > height + 45) { //check to see if the raindrop goes below the bottom of the screen + r.reset(); //if it does, reset the raindrop + loss += 1; + } + } + } + + if (score>=20) { //win the game when you get 30 points + game=2; + score = 0; + loss=0; + } + + if (loss>=20) { //lose the game when you drop 20 sushi + game =3; + score = 0; + loss=0; + } + + if (game ==2) { + win(); + } + + if (game == 3) { + failure(); + } + + if (frameCount < timer +20){ //"Yum!" appears for 20 frames (and also at the beginning as a joke) + reaction(); + } +} + + +void mousePressed() { + if (game == 0|| game == 2 || game==3) { //click to restart/start + game = 1; } } + +void win(){ + image(happy, 200, 200); //winning page + fill(205, 92, 92); + textSize(40); + text("Yay! Click to start over", 400, 150); +} + +void failure() { //losing page + image(sad, 200, 30); + fill(188, 143, 143); + textSize(40); + text("You failed Emily. Click to try again", 400, 560); +} + +void reaction() { //"Yum!" + fill(255, 160, 122); + textAlign(CENTER, CENTER); + textSize(50); + text("YUM", width/2, 200); +} \ No newline at end of file