diff --git a/raindropGameCode/Bucket.pde b/raindropGameCode/Bucket.pde new file mode 100644 index 0000000..4b9aa5d --- /dev/null +++ b/raindropGameCode/Bucket.pde @@ -0,0 +1,15 @@ + +class Buckets{ +PVector loc; //variables loc and diam which is the size of the bucket +float diam=100; + Buckets(){ + loc= new PVector(mouseX,mouseY); //create new loc vector + } + + void display(){ //set a fill and draw circle + fill(0,255,255); + loc= new PVector(mouseX,height-diam); + ellipse(loc.x,loc.y,diam,diam); + } + +} \ No newline at end of file diff --git a/raindropGameCode/Raindrop.pde b/raindropGameCode/Raindrop.pde new file mode 100644 index 0000000..e2f4a21 --- /dev/null +++ b/raindropGameCode/Raindrop.pde @@ -0,0 +1,30 @@ +class Raindrops { + float diam=20; + PVector loc, acc, vel; + Raindrops(float x, float y) { + loc=new PVector(x, y); + vel=PVector.random2D(); + acc=new PVector(0,.05); + } + void fall() { + vel.add(acc); + loc.add(vel); + } + void display() { + fill(255, 0, 10); + ellipse(loc.x, loc.y, diam, diam); + } + void reset(){ + loc.y=0; + loc.x=random(width); + vel=PVector.random2D(); + vel.add(acc); + } + boolean isInContactWith(Buckets other){ + if(loc.dist(other.loc) < diam/2 + other.diam/2){ + return true; + }else{ + return false; +} +} +} \ No newline at end of file diff --git a/raindropGameCode/data/ArialMT-48.vlw b/raindropGameCode/data/ArialMT-48.vlw new file mode 100644 index 0000000..afeeebf Binary files /dev/null and b/raindropGameCode/data/ArialMT-48.vlw differ diff --git a/raindropGameCode/raindropGameCode.pde b/raindropGameCode/raindropGameCode.pde index 944de61..6bee8f9 100644 --- a/raindropGameCode/raindropGameCode.pde +++ b/raindropGameCode/raindropGameCode.pde @@ -1,26 +1,58 @@ 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 +ArrayList raindrops= new ArrayList();//create arraylist named raindrops from class Raindrops +Buckets b = new Buckets(); //make variable b from class Buckets +int stage; //variables stage, score, bigger, time +int score=0; +PFont bigger; +int time; 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 + raindrops.add(new Raindrops(mouseX, mouseY)); //create new raindrop at arbitrary location + stage=1; //start stage at 1 + bigger=loadFont("ArialMT-48.vlw"); //load the font + textFont(bigger, 20); //set text to bigger } 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 (stage==1) { //if stage is equal to 1 + background(0, 0, 0); //background black + textAlign(CENTER); //align text to center + text("Score 100 as quick as possible", width/2, height/2); //write out these things + text("Click to play", width/2, height/2+20); + if (mousePressed) { //when mouse is pressed, go to stage 2 + stage=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 (stage==2) { //when stage is 2 + background(0, 200, 255); //background turquoise + b.display(); //display b variable + raindrops.add(new Raindrops(random(width), 0)); //add raindrops every frame + for (int i=raindrops.size()-1; i>=0; i--) { //for when i is equal to the arraylists size, and the other things + Raindrops r= raindrops.get(i); //basically create raindrops + 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(b)) { //check to see if the raindrop is in contact with the bucket + raindrops.remove(i);//if it is, reset the raindrop + score=score+1; //add 1 to score every time it touches the bucket + fill(255); //whit + } + if (r.loc.y > height + r.diam/2) { //check to see if the raindrop goes below the bottom of the screen + raindrops.remove(i); //if it does, reset the raindrop + } + text(score, width/2, height/2); //text of score and time + time=millis(); + text(time, width/2, height/2+30); + } + if (score==100) { //when score is 100 go to stage 3 + stage=3; + } } -} + if (stage==3) { //when stage 3, troll players by not telling them there time + background(0); + text("You took:", width/2, height/2); + score=score/100; + text("You will never know", width/2, height/2+30); + } +} \ No newline at end of file