From 56da842c46a4cf2d21b21225d1d3e6625837ff9e Mon Sep 17 00:00:00 2001 From: Eric Carlson Date: Mon, 14 Dec 2015 14:50:13 -0500 Subject: [PATCH 1/7] almost done need to figure our mouse thingy --- raindropGameCode/raindrop.pde | 41 +++++++++++++++++++++++++++ raindropGameCode/raindropGameCode.pde | 40 +++++++++++++++----------- 2 files changed, 64 insertions(+), 17 deletions(-) create mode 100644 raindropGameCode/raindrop.pde diff --git a/raindropGameCode/raindrop.pde b/raindropGameCode/raindrop.pde new file mode 100644 index 0000000..041902a --- /dev/null +++ b/raindropGameCode/raindrop.pde @@ -0,0 +1,41 @@ +class Raindrop { + PVector loc, vel, mouse; + int diam; + color c; + + Raindrop() { + diam = 5; + loc = new PVector(random(diam, width-diam), random(diam, height-diam)); + vel= new PVector(0, random(1)); + c = color(50, 50, 50); + } + + //after declaring fields and setting up constructors, you can define your methods + void display() { + fill(c); + noStroke(); + ellipse(loc.x, loc.y, diam, diam); + } + void fall() { + loc.add(vel); + } + + void bounceoffwalls() { + if (loc.x + diam/2 >= width) { + vel.x = -abs(vel.x); //if the ball hits the right wall, assign x velocity the negative version of itself + } else if (loc.x - diam/2 <= 0) { + vel.x = abs(vel.x); //if the ball hits the left wall, assign x velocity the positive version of itself + } + } + + void reset() { + loc.y=0; + loc.add(vel); + } + + +boolean isInContactWith() { + if( loc.dist(mouse){ + return true; +} +} \ No newline at end of file diff --git a/raindropGameCode/raindropGameCode.pde b/raindropGameCode/raindropGameCode.pde index 944de61..5889514 100644 --- a/raindropGameCode/raindropGameCode.pde +++ b/raindropGameCode/raindropGameCode.pde @@ -1,26 +1,32 @@ -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 +int count = 500; +PVector mouse; //declare a P +Raindrop[] r= new Raindrop[count]; //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 + mouse = new PVector(); + for ( int i=0; i< r.length; i++) { + r[i]= new Raindrop(); + } } +// r = new Raindrop(random(width), 0); //Initialize r. The parameters used are the initial x and y positions + 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 + background(255); + for (int i=0; i height + r[i].diam/2) { //check to see if the raindrop goes below the bottom of the screen + r[i].reset(); //if it does, reset the raindrop + } + if (r[i].isInContactWith(mouse)) { //check to see if the raindrop is in contact with the point represented by the PVector called mouse + r[i].reset(); //if it is, reset the raindrop + } } -} +} \ No newline at end of file From 53afa23997b211097edf5e6daa5a89ee47040ecf Mon Sep 17 00:00:00 2001 From: Eric Carlson Date: Wed, 16 Dec 2015 14:54:41 -0500 Subject: [PATCH 2/7] added catcher --- raindropGameCode/Catcher.pde | 21 +++++++++++++++++++++ raindropGameCode/raindrop.pde | 23 ++++++++++++++++------- raindropGameCode/raindropGameCode.pde | 23 ++++++++++++----------- 3 files changed, 49 insertions(+), 18 deletions(-) create mode 100644 raindropGameCode/Catcher.pde diff --git a/raindropGameCode/Catcher.pde b/raindropGameCode/Catcher.pde new file mode 100644 index 0000000..79bc534 --- /dev/null +++ b/raindropGameCode/Catcher.pde @@ -0,0 +1,21 @@ +class Catcher { + PVector loc; + color c; + int diam; + + Catcher() { + diam = 100; + loc = new PVector(); + c = color(0); + } + + //after declaring fields and setting up constructors, you can define your methods + void display() { + fill(c); + noStroke(); + ellipse(loc.x, loc.y, diam, diam); + } + void update() { + loc.set(mouseX,mouseY); + } +} \ No newline at end of file diff --git a/raindropGameCode/raindrop.pde b/raindropGameCode/raindrop.pde index 041902a..1da4f55 100644 --- a/raindropGameCode/raindrop.pde +++ b/raindropGameCode/raindrop.pde @@ -1,13 +1,15 @@ class Raindrop { - PVector loc, vel, mouse; + PVector loc, vel, acc; int diam; color c; Raindrop() { - diam = 5; + diam = 10; loc = new PVector(random(diam, width-diam), random(diam, height-diam)); vel= new PVector(0, random(1)); - c = color(50, 50, 50); + acc = PVector.random2D(); + acc.mult(.01); + c = color(random(255), random(255), random(255)); } //after declaring fields and setting up constructors, you can define your methods @@ -17,6 +19,8 @@ class Raindrop { ellipse(loc.x, loc.y, diam, diam); } void fall() { + vel.add(acc); + vel.limit(5); loc.add(vel); } @@ -31,11 +35,16 @@ class Raindrop { void reset() { loc.y=0; loc.add(vel); + vel.add(acc); } -boolean isInContactWith() { - if( loc.dist(mouse){ - return true; -} + boolean isInContactWith(Catcher thing) { + + if (thing.loc.dist(loc) < thing.diam/2 + diam/2 ) { + return true; + } else { + return false; + } + } } \ No newline at end of file diff --git a/raindropGameCode/raindropGameCode.pde b/raindropGameCode/raindropGameCode.pde index 5889514..1043440 100644 --- a/raindropGameCode/raindropGameCode.pde +++ b/raindropGameCode/raindropGameCode.pde @@ -1,32 +1,33 @@ - -int count = 500; -PVector mouse; //declare a P +int count = 10000; Raindrop[] r= new Raindrop[count]; //declare a new Raindrop called r - +Catcher c; void setup() { size(1200, 800); - mouse = new PVector(); + //mouse = new PVector(); for ( int i=0; i< r.length; i++) { r[i]= new Raindrop(); } + c = new Catcher(); } -// r = new Raindrop(random(width), 0); //Initialize r. The parameters used are the initial x and y positions +//Initialize r. The parameters used are the initial x and y positions void draw() { background(255); + c.display(); + c.update(); for (int i=0; i height + r[i].diam/2) { //check to see if the raindrop goes below the bottom of the screen r[i].reset(); //if it does, reset the raindrop } - if (r[i].isInContactWith(mouse)) { //check to see if the raindrop is in contact with the point represented by the PVector called mouse - r[i].reset(); //if it is, reset the raindrop + if (r[i].isInContactWith(c)) { //check to see if the raindrop is in contact with the point represented by the PVector called mouse + r[i].reset(); + //if it is, reset the raindrop } } } \ No newline at end of file From 61d098e2cf6283fadc4d9ef8b74a18f83a328495 Mon Sep 17 00:00:00 2001 From: Eric Carlson Date: Fri, 18 Dec 2015 14:51:49 -0500 Subject: [PATCH 3/7] added arrayl;ist --- raindropGameCode/raindrop.pde | 4 ++-- raindropGameCode/raindropGameCode.pde | 26 +++++++++++++------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/raindropGameCode/raindrop.pde b/raindropGameCode/raindrop.pde index 1da4f55..79e6161 100644 --- a/raindropGameCode/raindrop.pde +++ b/raindropGameCode/raindrop.pde @@ -3,8 +3,8 @@ class Raindrop { int diam; color c; - Raindrop() { - diam = 10; + Raindrop(float x,float y) { + diam = 20; loc = new PVector(random(diam, width-diam), random(diam, height-diam)); vel= new PVector(0, random(1)); acc = PVector.random2D(); diff --git a/raindropGameCode/raindropGameCode.pde b/raindropGameCode/raindropGameCode.pde index 1043440..78852ed 100644 --- a/raindropGameCode/raindropGameCode.pde +++ b/raindropGameCode/raindropGameCode.pde @@ -1,13 +1,11 @@ -int count = 10000; +//int count = 10000; -Raindrop[] r= new Raindrop[count]; //declare a new Raindrop called r +ArrayList rain = new ArrayList (); //declare a new Raindrop called r Catcher c; void setup() { size(1200, 800); //mouse = new PVector(); - for ( int i=0; i< r.length; i++) { - r[i]= new Raindrop(); - } + rain.add(new Raindrop(width/2, height/2)); c = new Catcher(); } //Initialize r. The parameters used are the initial x and y positions @@ -17,16 +15,18 @@ void draw() { background(255); c.display(); c.update(); - for (int i=0; i=0; i--) { + Raindrop r = rain.get(i); + r.fall(); //make the raindrop fall. It should accelerate as if pulled towards the ground by earth's gravity + r.display(); + r.bounceoffwalls(); - if (r[i].loc.y > height + r[i].diam/2) { //check to see if the raindrop goes below the bottom of the screen - r[i].reset(); //if it does, 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 } - if (r[i].isInContactWith(c)) { //check to see if the raindrop is in contact with the point represented by the PVector called mouse - r[i].reset(); + if (r.isInContactWith(c)) { //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 } } From 8da25dcb8bc830aefd265441548673af5b23b701 Mon Sep 17 00:00:00 2001 From: Eric Carlson Date: Mon, 4 Jan 2016 14:51:40 -0500 Subject: [PATCH 4/7] added score --- raindropGameCode/Catcher.pde | 6 +++++- raindropGameCode/raindrop.pde | 4 ++-- raindropGameCode/raindropGameCode.pde | 11 +++++++++-- raindropGameCode/score.pde | 19 +++++++++++++++++++ 4 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 raindropGameCode/score.pde diff --git a/raindropGameCode/Catcher.pde b/raindropGameCode/Catcher.pde index 79bc534..57f25d8 100644 --- a/raindropGameCode/Catcher.pde +++ b/raindropGameCode/Catcher.pde @@ -1,7 +1,7 @@ class Catcher { PVector loc; color c; - int diam; + float diam; Catcher() { diam = 100; @@ -18,4 +18,8 @@ class Catcher { void update() { loc.set(mouseX,mouseY); } + +void grow(){ + diam=diam+0.1; +} } \ No newline at end of file diff --git a/raindropGameCode/raindrop.pde b/raindropGameCode/raindrop.pde index 79e6161..d3b9f6f 100644 --- a/raindropGameCode/raindrop.pde +++ b/raindropGameCode/raindrop.pde @@ -1,10 +1,10 @@ class Raindrop { PVector loc, vel, acc; - int diam; + float diam; color c; Raindrop(float x,float y) { - diam = 20; + diam = random(20,50); loc = new PVector(random(diam, width-diam), random(diam, height-diam)); vel= new PVector(0, random(1)); acc = PVector.random2D(); diff --git a/raindropGameCode/raindropGameCode.pde b/raindropGameCode/raindropGameCode.pde index 78852ed..9db3a7c 100644 --- a/raindropGameCode/raindropGameCode.pde +++ b/raindropGameCode/raindropGameCode.pde @@ -1,12 +1,12 @@ -//int count = 10000; - ArrayList rain = new ArrayList (); //declare a new Raindrop called r Catcher c; +Score s; void setup() { size(1200, 800); //mouse = new PVector(); rain.add(new Raindrop(width/2, height/2)); c = new Catcher(); + s=new Score(); } //Initialize r. The parameters used are the initial x and y positions @@ -15,7 +15,11 @@ void draw() { background(255); c.display(); c.update(); + s.display(); + if(rain.size() < 100){ rain.add(new Raindrop(width/2, height/2)); + } + for (int i=rain.size()-1; i>=0; i--) { Raindrop r = rain.get(i); r.fall(); //make the raindrop fall. It should accelerate as if pulled towards the ground by earth's gravity @@ -27,7 +31,10 @@ void draw() { } if (r.isInContactWith(c)) { //check to see if the raindrop is in contact with the point represented by the PVector called mouse r.reset(); + s.addscore(); + c.grow(); //if it is, reset the raindrop } } + } \ No newline at end of file diff --git a/raindropGameCode/score.pde b/raindropGameCode/score.pde new file mode 100644 index 0000000..d2d36d7 --- /dev/null +++ b/raindropGameCode/score.pde @@ -0,0 +1,19 @@ +class Score { + int score5=0; + + Score() { + fill(255); + textSize(30); + } + + //after declaring fields and setting up constructors, you can define your methods + void display() { + text("Score:",10,50); + text(score5, 100, 50); + } + +void addscore() { +score5=score5+1; + + } +} \ No newline at end of file From 93fae66dff93a4e92eebda3c3c33fc5527761b29 Mon Sep 17 00:00:00 2001 From: Eric Carlson Date: Wed, 6 Jan 2016 11:03:46 -0500 Subject: [PATCH 5/7] almost done --- raindropGameCode/Catcher.pde | 6 +- raindropGameCode/raindrop.pde | 16 ++--- raindropGameCode/raindropGameCode.pde | 92 ++++++++++++++++++++------- raindropGameCode/score.pde | 35 ++++++++-- 4 files changed, 107 insertions(+), 42 deletions(-) diff --git a/raindropGameCode/Catcher.pde b/raindropGameCode/Catcher.pde index 57f25d8..cb2b7ec 100644 --- a/raindropGameCode/Catcher.pde +++ b/raindropGameCode/Catcher.pde @@ -6,7 +6,7 @@ class Catcher { Catcher() { diam = 100; loc = new PVector(); - c = color(0); + c = color(255); } //after declaring fields and setting up constructors, you can define your methods @@ -18,8 +18,4 @@ class Catcher { void update() { loc.set(mouseX,mouseY); } - -void grow(){ - diam=diam+0.1; -} } \ No newline at end of file diff --git a/raindropGameCode/raindrop.pde b/raindropGameCode/raindrop.pde index d3b9f6f..92c1708 100644 --- a/raindropGameCode/raindrop.pde +++ b/raindropGameCode/raindrop.pde @@ -5,21 +5,21 @@ class Raindrop { Raindrop(float x,float y) { diam = random(20,50); - loc = new PVector(random(diam, width-diam), random(diam, height-diam)); - vel= new PVector(0, random(1)); - acc = PVector.random2D(); - acc.mult(.01); - c = color(random(255), random(255), random(255)); + loc = new PVector(random(diam, width-diam), 0); + vel= new PVector(0, random(15)); + c = color(0, 0, random(255)); } //after declaring fields and setting up constructors, you can define your methods void display() { fill(c); noStroke(); - ellipse(loc.x, loc.y, diam, diam); + for (int i = 2; i < diam/2; i++ ) { + ellipse(loc.x,loc.y + i*4,i*2,i*2); + } + } void fall() { - vel.add(acc); vel.limit(5); loc.add(vel); } @@ -35,7 +35,7 @@ class Raindrop { void reset() { loc.y=0; loc.add(vel); - vel.add(acc); + } diff --git a/raindropGameCode/raindropGameCode.pde b/raindropGameCode/raindropGameCode.pde index 9db3a7c..9c5cbcd 100644 --- a/raindropGameCode/raindropGameCode.pde +++ b/raindropGameCode/raindropGameCode.pde @@ -1,6 +1,8 @@ ArrayList rain = new ArrayList (); //declare a new Raindrop called r -Catcher c; +Catcher c;//other classes declared Score s; +int mode=0; //for start screen + void setup() { size(1200, 800); //mouse = new PVector(); @@ -12,29 +14,75 @@ void setup() { void draw() { - background(255); - c.display(); - c.update(); - s.display(); - if(rain.size() < 100){ - rain.add(new Raindrop(width/2, height/2)); + if (mode==0) { //start screen and adding text and instructions + background(255); + textSize(100); + fill(0, 0, 255); + textAlign(CENTER, CENTER); + text("Raindrop Game", width/2, height/3); + textSize(30); + fill(0); + text("OBJECTIVE: CATCH AS MANY RAINDROPS AS POSSIBLE", width/2, height/2); + text("YOU GAIN A POINT FOR EACH RAINDROP YOU CATCH", width/2, height/2 + 40); + text("AND LOSE 2 POINTS FOR EVERY RAINDROP YOU MISS", width/2, height/2 +80); + text("YOU WIN WHEN U GET A SCORE OF 30 ", width/2, height/2+120); + text("AND LOSE IF YOUR SCORE GOES BELOW ZERO", width/2, height/2+160); + text("Click Screen and hit any key to start", width/2, height/2+200);//text for title screen + + if (keyPressed) { // title screen goes away if key is pressed + mode=1; + } } - - for (int i=rain.size()-1; i>=0; i--) { - Raindrop r = rain.get(i); - r.fall(); //make the raindrop fall. It should accelerate as if pulled towards the ground by earth's gravity - r.display(); - r.bounceoffwalls(); - - 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 (mode==1) { //if statement to make the start screen go away when key is pressed + + background(200); + c.display(); + c.update(); + s.display(); + if (rain.size() < 10) { + rain.add(new Raindrop(width/2, height/2)); + } + + for (int i=rain.size()-1; i>=0; i--) { + Raindrop r = rain.get(i); + r.fall(); //make the raindrop fall. It should accelerate as if pulled towards the ground by earth's gravity + r.display(); + + 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 + s.subScore(); + } + + if (r.isInContactWith(c)) { //check to see if the raindrop is in contact with the point represented by the PVector called mouse + r.reset(); + s.addscore(); + } + } + + if (s.scoref(c)) { + mode=2; + + if (mode==2) { + background(0); + fill(255); + text("HOLLA YOU WON CONGRATS!!!", width/2, height/3); + text("Exit window and run program again to play again", width/2, height/2); + text("sorry couldnt loop it back to start screen :(", width/2, height/2+40); + } } - if (r.isInContactWith(c)) { //check to see if the raindrop is in contact with the point represented by the PVector called mouse - r.reset(); - s.addscore(); - c.grow(); - //if it is, reset the raindrop + + if (s.scoref2(c)) { + mode=3; + s.score5=0; + } + + + if (mode==3) { + background(0); + fill(255); + text("YOU LOSE BETTER LUCK NEXT TIME", width/2, height/3); + text("Exit window and run program again to play again ", width/2, height/2); + text("sorry couldnt loop it back to start screen :(", width/2, height/2+40); } } - } \ No newline at end of file diff --git a/raindropGameCode/score.pde b/raindropGameCode/score.pde index d2d36d7..2c63a1a 100644 --- a/raindropGameCode/score.pde +++ b/raindropGameCode/score.pde @@ -2,18 +2,39 @@ class Score { int score5=0; Score() { - fill(255); + fill(0); textSize(30); } //after declaring fields and setting up constructors, you can define your methods void display() { - text("Score:",10,50); - text(score5, 100, 50); + fill(0); + text("Score:", 50, 50); + text(score5, 115, 50); } - -void addscore() { -score5=score5+1; - + + void addscore() { + score5=score5+1; + } + void subScore() { + score5=score5-2; + } + + boolean scoref (Catcher thing) { + + if (score5==30) { + return true; + } else { + return false; + } + } + boolean scoref2 (Catcher thing) { + + if (score5<0) { + return true; + + } else { + return false; + } } } \ No newline at end of file From 5a0949a587db14975eb766d9873d0b351f4a6eab Mon Sep 17 00:00:00 2001 From: Eric Carlson Date: Wed, 6 Jan 2016 11:58:38 -0500 Subject: [PATCH 6/7] almost --- raindropGameCode/raindropGameCode.pde | 40 ++++++++++++++++----------- raindropGameCode/score.pde | 12 ++++---- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/raindropGameCode/raindropGameCode.pde b/raindropGameCode/raindropGameCode.pde index 9c5cbcd..d08afa6 100644 --- a/raindropGameCode/raindropGameCode.pde +++ b/raindropGameCode/raindropGameCode.pde @@ -61,28 +61,36 @@ void draw() { if (s.scoref(c)) { mode=2; - - if (mode==2) { - background(0); - fill(255); - text("HOLLA YOU WON CONGRATS!!!", width/2, height/3); - text("Exit window and run program again to play again", width/2, height/2); - text("sorry couldnt loop it back to start screen :(", width/2, height/2+40); - } } if (s.scoref2(c)) { mode=3; - s.score5=0; + s.score = 0; + } + } - - if (mode==3) { - background(0); - fill(255); - text("YOU LOSE BETTER LUCK NEXT TIME", width/2, height/3); - text("Exit window and run program again to play again ", width/2, height/2); - text("sorry couldnt loop it back to start screen :(", width/2, height/2+40); + if (mode==2) { + background(0); + fill(255); + text("HOLLA YOU WON CONGRATS!!!", width/2, height/3); + text("Click To Play Again!!!", width/2, height/2); + text("Have Fun :)", width/2, height/2+40); + if (mousePressed) { + mode=0; + s.score=0; + } + } + if (mode==3) { + + background(0); + fill(255); + text("YOU LOSE BETTER LUCK NEXT TIME", width/2, height/3); + text("Click Screen To Play Again ", width/2, height/2); + text("you can do it this time :)", width/2, height/2+40); + if (mousePressed) { + mode = 0; + s.score = 0; } } } \ No newline at end of file diff --git a/raindropGameCode/score.pde b/raindropGameCode/score.pde index 2c63a1a..a5f9067 100644 --- a/raindropGameCode/score.pde +++ b/raindropGameCode/score.pde @@ -1,5 +1,5 @@ class Score { - int score5=0; + int score=0; Score() { fill(0); @@ -10,19 +10,19 @@ class Score { void display() { fill(0); text("Score:", 50, 50); - text(score5, 115, 50); + text(score, 115, 50); } void addscore() { - score5=score5+1; + score=score+1; } void subScore() { - score5=score5-2; + score=score-2; } boolean scoref (Catcher thing) { - if (score5==30) { + if (score==30) { return true; } else { return false; @@ -30,7 +30,7 @@ class Score { } boolean scoref2 (Catcher thing) { - if (score5<0) { + if (score<0) { return true; } else { From 73dc84652cbf976934b7268f9dc9d889f0007c1c Mon Sep 17 00:00:00 2001 From: Eric Carlson Date: Thu, 7 Jan 2016 11:23:41 -0500 Subject: [PATCH 7/7] finished game --- raindropGameCode/Catcher.pde | 1 + raindropGameCode/raindrop.pde | 15 ++------------- raindropGameCode/raindropGameCode.pde | 21 +++++++++++---------- raindropGameCode/score.pde | 8 ++++---- 4 files changed, 18 insertions(+), 27 deletions(-) diff --git a/raindropGameCode/Catcher.pde b/raindropGameCode/Catcher.pde index cb2b7ec..3cfcb30 100644 --- a/raindropGameCode/Catcher.pde +++ b/raindropGameCode/Catcher.pde @@ -1,3 +1,4 @@ + class Catcher { PVector loc; color c; diff --git a/raindropGameCode/raindrop.pde b/raindropGameCode/raindrop.pde index 92c1708..4162a89 100644 --- a/raindropGameCode/raindrop.pde +++ b/raindropGameCode/raindrop.pde @@ -24,25 +24,14 @@ class Raindrop { loc.add(vel); } - void bounceoffwalls() { - if (loc.x + diam/2 >= width) { - vel.x = -abs(vel.x); //if the ball hits the right wall, assign x velocity the negative version of itself - } else if (loc.x - diam/2 <= 0) { - vel.x = abs(vel.x); //if the ball hits the left wall, assign x velocity the positive version of itself - } - } - void reset() { loc.y=0; - loc.add(vel); - + loc.add(vel); } - boolean isInContactWith(Catcher thing) { - if (thing.loc.dist(loc) < thing.diam/2 + diam/2 ) { - return true; + return true; //if it hits any part of the catcher reset the raindrop } else { return false; } diff --git a/raindropGameCode/raindropGameCode.pde b/raindropGameCode/raindropGameCode.pde index d08afa6..d44c220 100644 --- a/raindropGameCode/raindropGameCode.pde +++ b/raindropGameCode/raindropGameCode.pde @@ -59,14 +59,13 @@ void draw() { } } - if (s.scoref(c)) { + if (s.scoref(c)) { //if the score is the winscore display win screen mode=2; } - if (s.scoref2(c)) { + if (s.scoref2(c)) { //if you lose display the lose mode=3; s.score = 0; - } } @@ -74,23 +73,25 @@ void draw() { background(0); fill(255); text("HOLLA YOU WON CONGRATS!!!", width/2, height/3); - text("Click To Play Again!!!", width/2, height/2); + text("Click To Play Again!!!", width/2, height/2); //win screen text("Have Fun :)", width/2, height/2+40); if (mousePressed) { - mode=0; - s.score=0; + mode=0; //if you click mouse go back to start screen + s.score=0; //reset ther score + rain.clear(); //reset the raindrops } } if (mode==3) { - + background(0); fill(255); text("YOU LOSE BETTER LUCK NEXT TIME", width/2, height/3); - text("Click Screen To Play Again ", width/2, height/2); + text("Click Screen To Play Again ", width/2, height/2); //lose screen text("you can do it this time :)", width/2, height/2+40); if (mousePressed) { - mode = 0; - s.score = 0; + mode = 0; //if you click mouse go back to start screen + s.score = 0; //reset ther score + rain.clear(); //reset the raindrops } } } \ No newline at end of file diff --git a/raindropGameCode/score.pde b/raindropGameCode/score.pde index a5f9067..5552ba1 100644 --- a/raindropGameCode/score.pde +++ b/raindropGameCode/score.pde @@ -13,16 +13,16 @@ class Score { text(score, 115, 50); } - void addscore() { + void addscore() { //adds score score=score+1; } - void subScore() { + void subScore() { //subtract score score=score-2; } boolean scoref (Catcher thing) { - if (score==30) { + if (score==30) { //win score return true; } else { return false; @@ -30,7 +30,7 @@ class Score { } boolean scoref2 (Catcher thing) { - if (score<0) { + if (score<0) { //lose score return true; } else {