diff --git a/raindropGameCode/bucket.pde b/raindropGameCode/bucket.pde new file mode 100644 index 0000000..59373d3 --- /dev/null +++ b/raindropGameCode/bucket.pde @@ -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); +} +} \ No newline at end of file diff --git a/raindropGameCode/data/bucket.png b/raindropGameCode/data/bucket.png new file mode 100644 index 0000000..199dc12 Binary files /dev/null and b/raindropGameCode/data/bucket.png differ diff --git a/raindropGameCode/raindropGameCode.pde b/raindropGameCode/raindropGameCode.pde index 944de61..97dfa95 100644 --- a/raindropGameCode/raindropGameCode.pde +++ b/raindropGameCode/raindropGameCode.pde @@ -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 r = new ArrayList();//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 @@ -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; } +} \ No newline at end of file diff --git a/raindropGameCode/raindrop_class.pde b/raindropGameCode/raindrop_class.pde new file mode 100644 index 0000000..9ab06e2 --- /dev/null +++ b/raindropGameCode/raindrop_class.pde @@ -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; + } +} \ No newline at end of file