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
16 changes: 16 additions & 0 deletions raindropGameCode/Bucket.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class Bucket {
PVector loc;
float diam;
PImage thompkins;

Bucket() {
ellipse(mouseX-45,490,50,50);
loc = new PVector(mouseX,mouseY);
thompkins = loadImage("Thompkins.png");
}
void display () {
imageMode(CENTER);
image(thompkins, mouseX, 490, 250, 250);
imageMode(CORNER);
}
}
32 changes: 32 additions & 0 deletions raindropGameCode/Raindrop.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
class Raindrop {
PVector loc, vel, accel;
float diam, score;

Raindrop (float x, float y) {
loc= new PVector(x, y);
vel= PVector.random2D();
accel= new PVector (.5, 1);
}
void display () {
noStroke();
fill(51, 0, 0);
ellipse(loc.x, loc.y, 70, 35);
}

void fall () {
vel.add(accel);
loc.add(vel);
}
boolean isInContactWith(PVector thing) {
if (loc.dist(thing) <= 60) {
return true;
} else {
return false;
}
}

void reset(float x) {
loc.set(x, 0);
vel = PVector.random2D();
}
}
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/Jets.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/Thompkins.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/Thompkins.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/football.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 39 additions & 13 deletions raindropGameCode/raindropGameCode.pde
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
PVector mouse; //declare a P
Raindrop r; //declare a new Raindrop called r
Raindrop r;//declare a new Raindrop called r
Bucket b;
PImage jets;
int score;
ArrayList<Raindrop> raindrop = new ArrayList<Raindrop>();

// On your own, create an array of Raindrop objects instead of just one
// Use the array instead of the single object
Expand All @@ -8,19 +12,41 @@ Raindrop r; //declare a new Raindrop called r

void setup() {
size(1200, 800);
jets = loadImage("Jets.jpg");
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
b = new Bucket();
raindrop.add(new Raindrop(random(width), 0));
}




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
}
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
}
}
image(jets, 0, 0, 1200, 800);
fill(145, 20, 0);
text("JETS BILLS 22", 50, 600, 300, 300);
text(score, 200, 660);
textSize(64);
mouse.set(mouseX, mouseY); //set value of mouse as mouseX,mouseY
b.display();
for (int i = raindrop.size()-1; i >= 0; i--) { //go through the ArrayList backwards to prevent flickering
Raindrop r = raindrop.get(i);
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(random(0,750)); //if it is, reset the raindrop
score+=7;
}
if (r.loc.y > height + r.diam/2) { //check to see if the raindrop goes below the bottom of the screen
r.reset(random(0, 500)); //if it does, reset the raindrop
}

if (score>= 28) {
background(0);
fill(0,255,0);
text("YOU BEAT THE BILLS 28-22!", 130, 250);
text("ON TO THE PLAYOFFS YOU GO!", 100,350);
textSize(32);
}
}
}