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
18 changes: 18 additions & 0 deletions raindropGameCode/Catcher_class.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
class Catcher {
PVector loc; //declare PVector for location of the catcher
PImage basket; //declare PImage variable for basket (which is the water bottle)

Catcher() {
loc = new PVector(); //make the location of the updated catcher
basket = loadImage("water#1.png"); //bring in the water bottle image
}

void display () {
image(basket, loc.x, loc.y); //make the water bottle image centered on the mouse

}

void update() {
loc.set(mouseX-40, mouseY-40); //when the catcher is updated, make its location the center of the image
}
}
Binary file added raindropGameCode/data/DJ Khaled.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/LION.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/Steph-Curry.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/key to success.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/nba basket.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/nba basketball.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/played.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/water#1.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/water.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
72 changes: 56 additions & 16 deletions raindropGameCode/raindropGameCode.pde
Original file line number Diff line number Diff line change
@@ -1,26 +1,66 @@
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 mouse; //declare a PVector for mouse
ArrayList<Raindrop> keys = new ArrayList<Raindrop>();
Catcher c; //declare catcher class
int score; //declare score variable
int screen; //declare screen variable
PImage bkgrnd; //declare background variable
PImage LION; //declare LION variable
PImage played; //declare played vartiable


void setup() {
size(1200, 800);
size(1200, 800); //make a canvas 1200 across and 800 down
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
c = new Catcher(); //initialize catcher class
score = 0; //set initial score to 0
screen = 0; //make a circumstance for a situation to be true and thus allow something to happen once that situation is true
bkgrnd = loadImage("DJ Khaled.jpg"); //bring in DJ Khaled image
LION = loadImage("LION.jpg"); //bring in LION image
played = loadImage("played.jpg"); //bring in "Congrats, You Played Yourself Image
}

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(LION); //make the background=DJ Khaled's LION
fill(0); //give the text black fill
textSize(75);
text("Ride With Me on The Path", 200, 150);
text("to More Success", 300, 400);
text("*hold down any key", 300, 500); //draw text on start screen
keys.add(new Raindrop(random(width), 0)); //add more keys to the existing keys
if (keyPressed) { //if key is Pressed...
background(LION); //make background
textSize(75);
text("Notice How I Said More", 200, 300);
textSize(25);
text("Click to Receive As Many Keys to Success You Need", 225, 400); //more text that appears when any key is pressed
}
if (mousePressed) { //if mouse Pressed, a certain condition exists that allows for the game to occur
screen = 2;
}
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 (screen == 2) { //this condition is true, therefore sets everything in motion
background(bkgrnd); //use DJ Khaled background when mouse is Pressed
mouse.set(mouseX, mouseY); //set value of mouse as mouseX,mouseY
textSize(50);
text(score, 1100, 300); //display score (how many keys are in the catcher)
for (int i = keys.size()-1; i >= 0; i--) {
Raindrop k = keys.get(i);
c.display(); //display catcher
c.update();
k.fall(); //make the keys to success fall
k.display(); //display te keys to success
if (k.Touches(c.loc)) { //if a key is touching the water bottle...
keys.remove(i); //remove the key touching the water bottle
score ++; //every time a key touches the water bottle, add 1 to the score
}
}
if (score > 200) { //if the score reaches 119, the game ends and a pic of Dj Khaled w/ his quote appears along with some text
theend(); //use theend function
}
}
}
void theend () {
background(played); //make the background the DJ Khaled Vine scene
textSize(35);
fill(38, 255, 217); //give the text a light blue color
text("Don't EVER Play Yourself", 100, 50); //end screen text
}
34 changes: 34 additions & 0 deletions raindropGameCode/raindrop_class.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
class Raindrop {
float diam; //declare diam
PVector vel, accel, loc; //declare PVector's for velocity, acceleration, and location of each key to success
PImage key; //declare PImage variable for the keys to success

Raindrop(float a, float b) {
loc = new PVector(a, b);
vel = new PVector(0, 3); //assign velocity to each new Raindrop
accel = new PVector(0, random(.02, .08)); //assign acceleration to each new Raindrop
key = loadImage("key to success.png"); //bring in the key to success image
}

void fall () {
loc.add(vel); //add velocity to the location of each Raindrop
vel.add(accel); //add acceleration to velocity of each Raindrop
}

void display () {
image(key, loc.x, loc.y); //give the key to success image position
}

boolean Touches(PVector z) { //set up true/false generator for conditions to be used in the main raindrop code
if (loc.dist(z) < 30) { //if the distance b/w PVector c and loc is less than 30, boolean e is true
return true;
} else { //else if not, boolean e is false
return false;
}
}

void reset() {
loc.y = 0; //reset location of y to 0 and set a initial velocity b/w 0 and 7
vel.set(0, 7);
}
}