Skip to content
Open

DONE #36

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 catcher {
PVector loc, vel, acc;
int diam;

catcher(int tDiam) {
diam = tDiam;
loc = new PVector(mouseX, mouseY);
}
void display() {

image(bucket, mouseX , mouseY);
}
void move() {
loc.set(mouseX,mouseY);
}
}
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.
59 changes: 45 additions & 14 deletions raindropGameCode/raindropGameCode.pde
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
PVector mouse; //declare a P
Raindrop r; //declare a new Raindrop called r

PVector mouse; //makes the mouse itself a PVector
int count = 20;//count of raindrops to star
int score = 0;//score starting out (amount of drops u caught)
int score2 = 0;//amount u missed
PImage bucket;//bucket pic
ArrayList<Raindrop> r = new ArrayList<Raindrop>();//declare raindrop r as well as the ArrayList
catcher c;
// 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
Expand All @@ -9,18 +13,45 @@ Raindrop r; //declare a new Raindrop called r
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
c = new catcher(6);
r.add(new Raindrop(mouseX, mouseY));
bucket = loadImage("bucket.png");
bucket.resize(50,50);
}

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
println(r.size());
background(0);
mouse.set(mouseX, mouseY);
r.add(new Raindrop(random(width), 0));
fill(255,250,250);
text(score, 550,200);

fill(255,250,250);
text(score2, 550,800);
text("catch as many as you can!!(keep up with it)",200,500);
textSize(30);
//set value of mouse as mouseX,mouseY
for (int i = r.size()-1; i >= 0; i--) {
Raindrop a = r.get(i);
a.fall(); //make the raindrop fall. It should accelerate as if pulled towards the ground by earth's gravity
a.display(); //display the raindrop
if (a.isInContactWith(mouse)) { //check to see if the raindrop is in contact with the point represented by the PVector called mouse
a.reset(); //if it is, reset the raindrop
score = score + 1;
}
if (a.loc.y > height + a.diam/2) { //check to see if the raindrop goes below the bottom of the screen
a.reset();//if it does, reset the raindrop
r.remove(i);
score2 = score2 + 1;
}
}
c.display();
c.move();
if(score2 >= score*10){
count = 0;
background(0);
fill(100,200,250);
text("YOURE BEAT DOOD",200,200);
score = 0;
}
}
30 changes: 30 additions & 0 deletions raindropGameCode/raindrop_class.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
class Raindrop {
PVector loc, vel, acc;
int diam;

Raindrop(float x, int y) {
diam = 25;
loc = new PVector(x,y);
vel = PVector.random2D();
acc = new PVector(0,.2);
vel.mult(.1);
}
void display () {
fill(0, 200, 255);
noStroke();
ellipse(loc.x,loc.y,diam,diam);
}
void fall () {
loc.add(vel);
vel.add(acc);
}
void reset () {
loc.y = 0;
loc.x = random(0,width);
vel = new PVector (0,0);
vel.add(acc);
}
boolean isInContactWith(PVector heh) {
return heh.dist(loc)<=diam;
}
}