Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added data/bucket.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/bucket.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/emilyhappy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/emilysad.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions raindropGameCode/Bucket.pde
Original file line number Diff line number Diff line change
@@ -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);
}
}
42 changes: 42 additions & 0 deletions raindropGameCode/Raindrop.pde
Original file line number Diff line number Diff line change
@@ -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);
}
}
Binary file added raindropGameCode/data/bucket.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added raindropGameCode/data/bucket.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added raindropGameCode/data/emilyhappy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added raindropGameCode/data/emilysad.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added raindropGameCode/data/sushi.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
123 changes: 105 additions & 18 deletions raindropGameCode/raindropGameCode.pde
Original file line number Diff line number Diff line change
@@ -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<Raindrop> particles = new ArrayList<Raindrop>();
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);
}