From 4487e2511a8cbdff3b528a968511e965527e704e Mon Sep 17 00:00:00 2001 From: Robert Argasinski Date: Tue, 15 Dec 2015 09:16:16 -0500 Subject: [PATCH 1/7] It works... --- raindropGameCode/RaindropClass.pde | 41 +++++++++++++++++++++++++++ raindropGameCode/raindropGameCode.pde | 40 +++++++++++++++----------- 2 files changed, 64 insertions(+), 17 deletions(-) create mode 100644 raindropGameCode/RaindropClass.pde diff --git a/raindropGameCode/RaindropClass.pde b/raindropGameCode/RaindropClass.pde new file mode 100644 index 0000000..55aea45 --- /dev/null +++ b/raindropGameCode/RaindropClass.pde @@ -0,0 +1,41 @@ +class Raindrop { + PVector loc; + PVector vel; + PVector acc; + float diam; + color c; + + Raindrop(float x, float y, color c){ + loc = new PVector(random(width), 0); + vel = new PVector(0, 5); + acc = new PVector(0, 0.01); + diam = 30; + c = 255; + } + + void fall(){ + loc.add(vel); + vel.add(acc); + } + + void display(){ + stroke(0); + strokeWeight(1); + ellipse(loc.x, loc.y, diam, diam); + } + + void reset(){ + loc = new PVector(random(width), 0); + vel = new PVector(0, 5); + acc = new PVector(0, 0.01); + } + + boolean isInContactWith(PVector mouse){ + if(loc.dist(mouse) < diam/2){ + return true; + } + else { + return false; + } + } +} \ No newline at end of file diff --git a/raindropGameCode/raindropGameCode.pde b/raindropGameCode/raindropGameCode.pde index 944de61..a963289 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 - +PVector mouse; +Raindrop r; +int score = 0; 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(); + r = new Raindrop(random(width), 0, 255); } void draw() { - mouse.set(mouseX, mouseY); //set value of mouse as mouseX,mouseY + mouse.set(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 + r.fall(); + r.display(); + fill(255); + textSize(50); + textAlign(CENTER); + text(score, width/2, 300); + text("RAINDROP GAME", width/2, 100); + strokeWeight(4); + stroke(255); + line(370, 110, 830, 110); + if (r.isInContactWith(mouse)) { + r.reset(); + score += 1; } - 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.loc.y > height + r.diam/2) { + r.reset(); + score -= 1; } -} +} \ No newline at end of file From 8fb2096c4085eb59f9a8ea6d05b4939f60aff979 Mon Sep 17 00:00:00 2001 From: Robert Argasinski Date: Thu, 17 Dec 2015 08:07:12 -0500 Subject: [PATCH 2/7] commit --- raindropGameCode/RaindropClass.pde | 4 ++-- raindropGameCode/raindropGameCode.pde | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/raindropGameCode/RaindropClass.pde b/raindropGameCode/RaindropClass.pde index 55aea45..452f7d3 100644 --- a/raindropGameCode/RaindropClass.pde +++ b/raindropGameCode/RaindropClass.pde @@ -5,11 +5,11 @@ class Raindrop { float diam; color c; - Raindrop(float x, float y, color c){ + Raindrop(float x, float y){ loc = new PVector(random(width), 0); vel = new PVector(0, 5); acc = new PVector(0, 0.01); - diam = 30; + diam = 40; c = 255; } diff --git a/raindropGameCode/raindropGameCode.pde b/raindropGameCode/raindropGameCode.pde index a963289..06193af 100644 --- a/raindropGameCode/raindropGameCode.pde +++ b/raindropGameCode/raindropGameCode.pde @@ -1,18 +1,17 @@ PVector mouse; Raindrop r; int score = 0; +int count = 5; void setup() { size(1200, 800); mouse = new PVector(); - r = new Raindrop(random(width), 0, 255); + r = new Raindrop(random(width), 0); } void draw() { mouse.set(mouseX, mouseY); background(0, 200, 255); - r.fall(); - r.display(); fill(255); textSize(50); textAlign(CENTER); @@ -21,6 +20,8 @@ void draw() { strokeWeight(4); stroke(255); line(370, 110, 830, 110); + r.fall(); + r.display(); if (r.isInContactWith(mouse)) { r.reset(); score += 1; From 0bf69ed8c1b4fefa148051522594bb1c3dd6d056 Mon Sep 17 00:00:00 2001 From: Robert Argasinski Date: Thu, 17 Dec 2015 08:28:09 -0500 Subject: [PATCH 3/7] Added states --- raindropGameCode/raindropGameCode.pde | 77 ++++++++++++++++++++------- 1 file changed, 57 insertions(+), 20 deletions(-) diff --git a/raindropGameCode/raindropGameCode.pde b/raindropGameCode/raindropGameCode.pde index 06193af..195b20f 100644 --- a/raindropGameCode/raindropGameCode.pde +++ b/raindropGameCode/raindropGameCode.pde @@ -1,33 +1,70 @@ PVector mouse; -Raindrop r; +Raindrop /*[]*/ r; int score = 0; int count = 5; +int state = 1; void setup() { size(1200, 800); mouse = new PVector(); - r = new Raindrop(random(width), 0); + /*for (int i = 0; i < count; i++) {*/ + r/*[i]*/ = new Raindrop(random(width), 0); + /*}*/ } void draw() { - mouse.set(mouseX, mouseY); - background(0, 200, 255); - fill(255); - textSize(50); - textAlign(CENTER); - text(score, width/2, 300); - text("RAINDROP GAME", width/2, 100); - strokeWeight(4); - stroke(255); - line(370, 110, 830, 110); - r.fall(); - r.display(); - if (r.isInContactWith(mouse)) { - r.reset(); - score += 1; + if (state == 1) { + background(0, 200, 255); + fill(255); + textAlign(CENTER); + textSize(100); + text("RAINDROP GAME", width/2, height/2); + textSize(50); + text("PRESS SPACE", width/2, 700); + strokeWeight(4); + stroke(255); + line(200, 450, 1000, 450); } - if (r.loc.y > height + r.diam/2) { - r.reset(); - score -= 1; + if (state == 2) { + background(0, 200, 255); + textSize(100); + text("CONTROLS", width/2, 300); + textSize(50); + text("Catch the raindrops to get points. \nIf you let a raindrop fall, you lose a point.", width/2, 450); + text("PRESS SPACE", width/2, 700); + strokeWeight(4); + stroke(255); + line(300, 350, 900, 350); + } + if (state == 3) { + mouse.set(mouseX, mouseY); + background(0, 200, 255); + fill(255); + textSize(50); + textAlign(CENTER); + text(score, width/2, 300); + text("RAINDROP GAME", width/2, 100); + strokeWeight(4); + stroke(255); + line(370, 110, 830, 110); + /*for (int i = 0; i < count; i++) {*/ + r/*[i]*/.fall(); + r/*[i]*/.display(); + if (r/*[i]*/.isInContactWith(mouse)) { + r/*[i]*/.reset(); + score += 1; + } + if (r/*[i]*/.loc.y > height + r/*[i]*/.diam/2) { + r/*[i]*/.reset(); + score -= 1; + } + /*}*/ + } +} + +void keyPressed(){ + state += 1; + if(state == 4){ + state = 3; } } \ No newline at end of file From 6ee90bd3e5174893ce2424c00e6944c82cdc7ed7 Mon Sep 17 00:00:00 2001 From: Robert Argasinski Date: Thu, 17 Dec 2015 09:18:52 -0500 Subject: [PATCH 4/7] Buckets! --- raindropGameCode/BucketClass.pde | 14 ++++++++++++++ raindropGameCode/RaindropClass.pde | 4 ++-- raindropGameCode/raindropGameCode.pde | 28 ++++++++++++++++++++++----- 3 files changed, 39 insertions(+), 7 deletions(-) create mode 100644 raindropGameCode/BucketClass.pde diff --git a/raindropGameCode/BucketClass.pde b/raindropGameCode/BucketClass.pde new file mode 100644 index 0000000..66defd9 --- /dev/null +++ b/raindropGameCode/BucketClass.pde @@ -0,0 +1,14 @@ +class Catcher { + int diam; + PVector loc; + + Catcher(int tDiam){ + diam = tDiam; + loc = new PVector(mouseX, mouseY); + } + + void display(){ + fill(0); + ellipse(mouseX, mouseY, diam, diam); + } +} \ No newline at end of file diff --git a/raindropGameCode/RaindropClass.pde b/raindropGameCode/RaindropClass.pde index 452f7d3..412914d 100644 --- a/raindropGameCode/RaindropClass.pde +++ b/raindropGameCode/RaindropClass.pde @@ -30,8 +30,8 @@ class Raindrop { acc = new PVector(0, 0.01); } - boolean isInContactWith(PVector mouse){ - if(loc.dist(mouse) < diam/2){ + boolean isInContactWith(Catcher c){ + if(loc.dist(mouse) < diam/2 + c.diam/2){ return true; } else { diff --git a/raindropGameCode/raindropGameCode.pde b/raindropGameCode/raindropGameCode.pde index 195b20f..07f73da 100644 --- a/raindropGameCode/raindropGameCode.pde +++ b/raindropGameCode/raindropGameCode.pde @@ -3,6 +3,7 @@ Raindrop /*[]*/ r; int score = 0; int count = 5; int state = 1; +Catcher bucket; void setup() { size(1200, 800); @@ -10,6 +11,7 @@ void setup() { /*for (int i = 0; i < count; i++) {*/ r/*[i]*/ = new Raindrop(random(width), 0); /*}*/ + bucket = new Catcher(60); } void draw() { @@ -24,6 +26,7 @@ void draw() { strokeWeight(4); stroke(255); line(200, 450, 1000, 450); + backgroundBubbles(); } if (state == 2) { background(0, 200, 255); @@ -32,13 +35,13 @@ void draw() { textSize(50); text("Catch the raindrops to get points. \nIf you let a raindrop fall, you lose a point.", width/2, 450); text("PRESS SPACE", width/2, 700); - strokeWeight(4); - stroke(255); line(300, 350, 900, 350); + backgroundBubbles(); } if (state == 3) { mouse.set(mouseX, mouseY); background(0, 200, 255); + bucket.display(); fill(255); textSize(50); textAlign(CENTER); @@ -50,7 +53,7 @@ void draw() { /*for (int i = 0; i < count; i++) {*/ r/*[i]*/.fall(); r/*[i]*/.display(); - if (r/*[i]*/.isInContactWith(mouse)) { + if (r/*[i]*/.isInContactWith(bucket)) { r/*[i]*/.reset(); score += 1; } @@ -62,9 +65,24 @@ void draw() { } } -void keyPressed(){ +void keyPressed() { state += 1; - if(state == 4){ + if (state == 4) { state = 3; } +} + +void backgroundBubbles() { + ellipse(20, 20, 10, 10); + ellipse(1180, 20, 10, 10); + ellipse(1180, 780, 10, 10); + ellipse(20, 780, 10, 10); + ellipse(30, 40, 20, 20); + ellipse(1170, 40, 20, 20); + ellipse(1170, 760, 20, 20); + ellipse(30, 760, 20, 20); + ellipse(60, 60, 30, 30); + ellipse(1140, 60, 30, 30); + ellipse(1140, 740, 30, 30); + ellipse(60, 740, 30, 30); } \ No newline at end of file From 3195b563530028748d21a4a87c8520fdb0a82a5c Mon Sep 17 00:00:00 2001 From: Robert Argasinski Date: Thu, 17 Dec 2015 09:23:54 -0500 Subject: [PATCH 5/7] Lines! --- raindropGameCode/raindropGameCode.pde | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/raindropGameCode/raindropGameCode.pde b/raindropGameCode/raindropGameCode.pde index 07f73da..e14f9fd 100644 --- a/raindropGameCode/raindropGameCode.pde +++ b/raindropGameCode/raindropGameCode.pde @@ -85,4 +85,10 @@ void backgroundBubbles() { ellipse(1140, 60, 30, 30); ellipse(1140, 740, 30, 30); ellipse(60, 740, 30, 30); + strokeWeight(4); + stroke(255); + line(100, 10, 1100, 10); + line(100, 790, 1100, 790); + line(10, 100, 10, 700); + line(1190, 100, 1190, 700); } \ No newline at end of file From a59235826017efdf050535579ad303f060bcb5c4 Mon Sep 17 00:00:00 2001 From: Robert Argasinski Date: Thu, 7 Jan 2016 08:01:27 -0500 Subject: [PATCH 6/7] DONE --- raindropGameCode/BucketClass.pde | 22 +-- raindropGameCode/RaindropClass.pde | 116 ++++++++++----- raindropGameCode/data/PiCircle.png | Bin 0 -> 8538 bytes raindropGameCode/raindropGameCode.pde | 197 ++++++++++++++++---------- 4 files changed, 218 insertions(+), 117 deletions(-) create mode 100644 raindropGameCode/data/PiCircle.png diff --git a/raindropGameCode/BucketClass.pde b/raindropGameCode/BucketClass.pde index 66defd9..adadd0c 100644 --- a/raindropGameCode/BucketClass.pde +++ b/raindropGameCode/BucketClass.pde @@ -1,14 +1,16 @@ -class Catcher { - int diam; +class Catcher { //initializing class + int diam; //declaring variables PVector loc; - - Catcher(int tDiam){ - diam = tDiam; - loc = new PVector(mouseX, mouseY); + PImage Pi; + + Catcher(int tDiam) { //creates constructor that has an input of the diameter of the circle + diam = tDiam; //the diameter declared in the class above is equal to that of the input + loc = new PVector(mouseX, mouseY); //the catcher is initally at a random location + Pi = loadImage("PiCircle.png"); //retrieving image file from the data folder } - - void display(){ - fill(0); - ellipse(mouseX, mouseY, diam, diam); + + void display() { //method called display that, well, displays the catcher + Pi.resize(100,100); //scales the image down to the size of the catcher + image(Pi, mouseX - diam/2, mouseY - diam/2); //displays the image at the location of the mouse as its center } } \ No newline at end of file diff --git a/raindropGameCode/RaindropClass.pde b/raindropGameCode/RaindropClass.pde index 412914d..ac92d19 100644 --- a/raindropGameCode/RaindropClass.pde +++ b/raindropGameCode/RaindropClass.pde @@ -1,40 +1,92 @@ -class Raindrop { - PVector loc; +class Raindrop { //initialize class + PVector loc; //declare variables PVector vel; PVector acc; float diam; - color c; - - Raindrop(float x, float y){ - loc = new PVector(random(width), 0); - vel = new PVector(0, 5); - acc = new PVector(0, 0.01); - diam = 40; - c = 255; - } - - void fall(){ - loc.add(vel); - vel.add(acc); - } - - void display(){ - stroke(0); - strokeWeight(1); - ellipse(loc.x, loc.y, diam, diam); - } - - void reset(){ - loc = new PVector(random(width), 0); - vel = new PVector(0, 5); - acc = new PVector(0, 0.01); - } - - boolean isInContactWith(Catcher c){ - if(loc.dist(mouse) < diam/2 + c.diam/2){ + float r; + float g; + float b; + int points; + + Raindrop(float x, float y) { //create constructor + loc = new PVector(x, y); //turns input location into a vector + vel = new PVector(0, 3); //creates a velocity vector + acc = new PVector(0, 0.01); //creates an acceleration vector + diam = 20; //all raindrops have a diameter of 20 + if (isGold()) { //if the raindrop "isGold" (defined below), it's gold and if you catch it, then +20 + r = 255; + g = 215; + b = 0; + points = 20; + } else if (isRed()) { //if the raindrop "isRed" (defined below), it's red and if you catch it, then -10 + r = 255; + g = 0; + b = 0; + points = -10; + } else if (isBlack()) { + r = 0; + g = 0; + b = 0; + points = -score; + } else { //else, it's white and if you catch it, then +1 + r = 255; + g = 255; + b = 255; + points = 1; + } + } + + void fall() { //function dealing with the movement of the raindrop + loc.add(vel); //velocity is added to location and ... + vel.add(acc); //acceleration is added to velocity + } + + void display() { //function dealing with displaying the raindrop (pretty important :D) + stroke(0); //black border + strokeWeight(1); //default line weight + fill(r, g, b); //values for r, g, and b are determined above in the constructor + ellipse(loc.x, loc.y, diam, diam); //finally, we can create the raindrop + } + + void reset() { //function dealing with bringing a raindrop back to the top + loc = new PVector(random(width), 0); //resets location + vel = new PVector(0, 3); //resets velocity + acc = new PVector(0, 0.01); //resets acceleration + } + + boolean isInContactWith(Catcher c) { //boolean which checks to see if you caught a raindrop + if (loc.dist(mouse) < diam/2 + c.diam/2) { //two circles are touching if the distance between them is less that their combined radii + return true; + } else { + return false; + } + } + boolean isGold() { //probability boolean to create gold raindrops + float number = random(100); //from numbers 0-100... + number = round(number); //round the number (we don't want any floats!) + if (number == 5 || number == 1 || number == 10) { //basically 3% chance of getting gold (unless previously caught a gold raindrop...) + return true; + } else { + return false; + } + } + + boolean isRed() { //probability boolean to create red raindrops + float number = random(100); //from numbers 0-100... + number = round(number); //round the number (once again) + if (number == 2 || number == 4) { //basically 2% chance of getting red (unless previously caught a red raindrop...) return true; + } else { + return false; } - else { + } + + boolean isBlack() { + float number = random(100); //from numbers 0-100... + number = round(number); //round the number (once again) + if (number == 3) { //basically 1% chance of getting black + return true; + } else { return false; } } diff --git a/raindropGameCode/data/PiCircle.png b/raindropGameCode/data/PiCircle.png new file mode 100644 index 0000000000000000000000000000000000000000..4b876d37e62a33d77689ac9af2050dff07eb4521 GIT binary patch literal 8538 zcmbVyWmuGN)AueNQqoALNbShA_gJ=06?Otp=yM=XZ}42@Gw`p zURE~DjUK6Hjx1OKyGlJRL2Y8}jvH$?Kx6>1Iq`9t+G!)?` zX#1B&(BI7i!wmq)D)@WYLS0};Ry&x3le--IQCk-~tCPJPyP23SNY_IJ=IEpm=mj$l z)O!LAbb(6Qvn$B6%KA%V1h~PFwygecuI}E_{&MX9k}HjQ{`*>po%LTNNEbQwe=B9K zYrv|4@Pe_535p3oLBe2G2`NFan5YyO%+D$e0*eTNK|;b(0${MTsDw0Fob^8kJ7zX7 zd$_cbs``KC!i?nD9g#>6X(1s$KR-b~5kZ8PgAiCsN=gVMEF>%}fT0lZ4sb`>`U|*w zbNnMg73K}~a`HerA>3L2O0=~@_#oxjF`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RNw!rU^onf2q#C#r=}#vh>WdG%aja z%WYB+VC-8L^At)vObksr;lb{4qwV}E=pXs3z`=d2lq=TKz18W#{75WA8cu#KfNtHi zwT$pCRxXQBUu(^n{0TJ8wfit3REbJ8(Kn@j!%;W0%W>c=*%(kNK1{Z)&D~-nwDFX? z@=g+GH`-Wv67svRJ>b_xi&_bn;KknrTH@T|JKp0VQT>hp#C6kE?SrRyZY5pyB!B3M zS|yH5bmB|gqE$x)nK2u`h6KI46+zjM?KB0mJ@b3jOn_3y>{9uh$D7+Luxe?gYJy2? za-*^W0Lg)BP>1TIdKY@CWkA8@+=~44w`$_!aKfe5g)*P}_OUN`b$aZoamvUyV%upy zYV$0`oCUl&~k~p-WX?O4!dJs@Wd_f_dec z$MG}*!W@hJ*fkSL4!Hr(hg83L&HbYK25&}>Hw01ei3vS@T1bfj>~X=SaTT^i&7K}~ zxIICpF~88!DcKq{kRJ)0y^jfiGs}-PCcK=5BD+E!`#(1@8oHdcd3PWh>x-Ak-rsw% zFd7aa99F6{usF{v-=2S)a)=}4!%D>=lgXqM6Ic*h#-lynONi;i52y}^j|W-jMk#Vi zEPMWZ3jj5`CY{zXmJtNCP}wnM70!K-qz{xV#-P2NTwDzLgrj@R0Ypaw*M?-O^R~Rl zvXLMonZsg(uhU{LfSsChbAqD412(RW_wJ9zeg!O#1{=>v` ziC-w5Y+Ly0xptz?u#$Sdh@rW;W2lgT0JYad-$%zH^+K2VYWNj;f8TZTqm6<{gmmZi z_78^acXJw{#_27lf7F`duRHc>54l}#oLlvq0rjEkDw`uis&4&q?^3=pxi2qdM$t%X z&EN?$tJS^J|4>~`!^Oo_*xYQc0eto*EiEf-{GE)0_1`+0P!aG@N~&cpB_q}DJ1%0r z`rYLxhw)r?F)X*4@cWB-<5cu%xh(1QDi5yagHPS+L(4Dxk*W zE9f}5rZf2ziJO3{lA;l;4DC)N1$i9xSwMRJ raindrops = new ArrayList(); //creates an ArrayList from the Raindrop class void setup() { - size(1200, 800); - mouse = new PVector(); - /*for (int i = 0; i < count; i++) {*/ - r/*[i]*/ = new Raindrop(random(width), 0); - /*}*/ - bucket = new Catcher(60); + size(1200, 800); //canvas size of 1200px x 800px + mouse = new PVector(); //creates an empty PVector to be used to find the mouse's position + bucket = new Catcher(100); //creates a Catcher object called bucket with a diameter of 60 + raindrops.add(new Raindrop(random(width), 0)); //creates one raindrop to start out } void draw() { - if (state == 1) { - background(0, 200, 255); - fill(255); - textAlign(CENTER); - textSize(100); - text("RAINDROP GAME", width/2, height/2); - textSize(50); - text("PRESS SPACE", width/2, 700); - strokeWeight(4); - stroke(255); - line(200, 450, 1000, 450); - backgroundBubbles(); + if (state == 1) { //first screen to be displayed is the title screen + background(0, 200, 255); //beautiful (Skype-looking) blue background + fill(255); //white text + textAlign(CENTER); //centered text + textSize(100); //100px text + text("RAINDROP GAME", width/2, height/2); //Title of the game centered on the screen + textSize(50); //50px text + text("PRESS ANY KEY", width/2, 700); //instructs the player to press any key so that we can move onto the ACTUAL game. + strokeWeight(4); //4px lines + stroke(255); //white lines + line(200, 450, 1000, 450); //line + backgroundBubbles(); //see function way, way, way below :) } - if (state == 2) { - background(0, 200, 255); - textSize(100); - text("CONTROLS", width/2, 300); - textSize(50); - text("Catch the raindrops to get points. \nIf you let a raindrop fall, you lose a point.", width/2, 450); - text("PRESS SPACE", width/2, 700); - line(300, 350, 900, 350); - backgroundBubbles(); + if (state == 2) { //finally, we're getting somewhere: the instructions! + fill(255); //white text + background(0, 200, 255); //same gorgeous background + backgroundBubbles(); //same function that creates a nice border + textSize(100); //100px text + text("CONTROLS", width/2, 300); //heading for the screen; just in case you were wondering if indeed these were controls + textSize(25); //30px text + text("Using your mouse, catch the right raindrops to get points. \nWhite raindrops are worth 1 point. \nGold raindrops are worth 20 points. \nRed raindrops deduct 10 points. \nBlack raindrops deduct ALL points. \nIf you let a raindrop fall, you lose a point.", width/2, 440); //simple instructions on the objective of the game; notice the '\n' which starts following text on a new line + textSize(50); //50px text + text("PRESS ANY KEY", width/2, 700); //if think you have understood the mechanics of the game, please press any key + line(300, 350, 900, 350); //another stylistic line + fill(255); //white color + stroke(0); //black outline... + strokeWeight(1); //of 1px + ellipse(300, 473, 20, 20); //white raindrop + fill(255, 215, 0); //gold color + ellipse(300, 508, 20, 20); //gold raindrop + fill(255, 0, 0); //red color + ellipse(300, 545, 20, 20); //red raindrop + fill(0, 0, 0); //black color + ellipse(300, 581, 20, 20); //black raindrop + fill(255); //white color + ellipse(900, 473, 20, 20); //white raindrop + fill(255, 215, 0); //gold color + ellipse(900, 508, 20, 20); //gold raindrop + fill(255, 0, 0); //red color + ellipse(900, 545, 20, 20); //red raindrop + fill(0, 0, 0); //black color + ellipse(900, 581, 20, 20); //black raindrop + score = 0; //the reason why this is initialized twice is because if the player decides to play again (without refreshing game), we want them to start from zero } - if (state == 3) { - mouse.set(mouseX, mouseY); - background(0, 200, 255); - bucket.display(); - fill(255); - textSize(50); - textAlign(CENTER); - text(score, width/2, 300); - text("RAINDROP GAME", width/2, 100); - strokeWeight(4); - stroke(255); - line(370, 110, 830, 110); - /*for (int i = 0; i < count; i++) {*/ - r/*[i]*/.fall(); - r/*[i]*/.display(); - if (r/*[i]*/.isInContactWith(bucket)) { - r/*[i]*/.reset(); - score += 1; + if (state == 3) { //the RAINDROP game is upon us + if (score <= -1) { //this is checked at the start to prevent crashing + state += 1; //if so, redirect to Game Over screen } - if (r/*[i]*/.loc.y > height + r/*[i]*/.diam/2) { - r/*[i]*/.reset(); - score -= 1; + background(0, 200, 255); //you have to love this background color! + mouse.set(mouseX, mouseY); //sets the mouse as the mouse's position (keep in mind, it's a vector) + bucket.display(); //display the bucket (otherwise known as the pi symbol) + fill(255); //white text + textSize(50); //50px text + textAlign(CENTER); //centered text + text(score, width/2, 200); //display the score + text("RAINDROP GAME", width/2, 100); //just making sure you know that this is the Raindrop Game + strokeWeight(4); //4px line + stroke(255); //white line + line(370, 110, 830, 110); //line + for (int i = raindrops.size()-1; i >= 0; i--) { //for each object in the raindrops ArrayList... (starting from the back to prevent flickering) + Raindrop r = raindrops.get(i); //isolate the raindrop + r.fall(); //make it fall + r.display(); //display it + if (r.isInContactWith(bucket)) { //if the bucket is touching the raindrop... + r.reset(); //spawn the same raindrop from the top + score += r.points; //score changes based on color (white, gold, red) + if (raindrops.size() < 50) { //limits the amount of raindrops on the screen to 50 to prevent crashing + raindrops.add(new Raindrop(random(width), 0)); + } + } + if (r.loc.y > height + r.diam/2) { //if the raindrop reaches the bottom of the screen... + raindrops.remove(r); //it is removed + if (raindrops.size() < 50) { //once again, if there is less than 50 raindrops... + raindrops.add(new Raindrop(random(width), 0)); //add a random one + } + score -= 1; //in the end, dropping a raindrop (no matter the color) is worth the same + } } - /*}*/ + } + if (state == 4) { //Game Over screen + resetArrayList(); //function defined below; gets rid of all stored entries in the ArrayList + background(0, 200, 255); //this background never gets old, does it? + fill(255); //white text + textSize(100); //100px text + textAlign(CENTER); //centered text + text("GAME OVER", width/2, height/2); //the infamous Game Over text smack dab in the center of your computer screen + textSize(50); //50px text + text("PRESS ANY KEY TO PLAY AGAIN", width/2, 700); //you'll never escape this game unless you close your window! :D + backgroundBubbles(); //once again, wonderful border } } -void keyPressed() { - state += 1; - if (state == 4) { - state = 3; +void keyPressed() { //this explains the 'press any key' mechanism; CAN WE FIGURE OUT HOW TO NOT BE ABLE TO SKIP DURING GAMEPLAY UNLESS YOU LOSE? ************ + state += 1; //self-explanatory + if (state == 5) { //this is how the loop functions: if you reach a 5th state (non-existent), you are redirected to the title screen + state = 1; //title screen + raindrops.add(new Raindrop(random(width), 0)); //starts out the game with a single raindrop (since this is normally created in void setup()) } } -void backgroundBubbles() { - ellipse(20, 20, 10, 10); - ellipse(1180, 20, 10, 10); - ellipse(1180, 780, 10, 10); - ellipse(20, 780, 10, 10); - ellipse(30, 40, 20, 20); - ellipse(1170, 40, 20, 20); - ellipse(1170, 760, 20, 20); - ellipse(30, 760, 20, 20); - ellipse(60, 60, 30, 30); - ellipse(1140, 60, 30, 30); - ellipse(1140, 740, 30, 30); - ellipse(60, 740, 30, 30); - strokeWeight(4); - stroke(255); - line(100, 10, 1100, 10); - line(100, 790, 1100, 790); - line(10, 100, 10, 700); - line(1190, 100, 1190, 700); +void backgroundBubbles() { //beautiful detailed background + noStroke(); //by not having a stroke, it is clear to see which balls are meant to be caught + ellipse(20, 20, 10, 10); //ellipse #1 + ellipse(1180, 20, 10, 10); //ellipse #2 + ellipse(1180, 780, 10, 10); //ellipse #3 + ellipse(20, 780, 10, 10); //ellipse #4 + ellipse(30, 40, 20, 20); //ellipse #5 + ellipse(1170, 40, 20, 20); //ellipse #6 + ellipse(1170, 760, 20, 20); //ellipse #7 + ellipse(30, 760, 20, 20); //ellipse #8 + ellipse(60, 60, 30, 30); //ellipse #9 + ellipse(1140, 60, 30, 30); //ellipse #10 + ellipse(1140, 740, 30, 30); //ellipse #11 + ellipse(60, 740, 30, 30); //ellipse #12 + strokeWeight(4); //4px line + stroke(255); //white line + line(100, 10, 1100, 10); //line #1 + line(100, 790, 1100, 790); //line #2 + line(10, 100, 10, 700); //line #3 + line(1190, 100, 1190, 700); //line #4 +} + +void resetArrayList() { //function used during Game Over screen + for (int i = raindrops.size()-1; i >= 0; i--) { //deletes all arrays starting from the end working back to zero + raindrops.remove(i); + } } \ No newline at end of file From 93002c319753befed1cd60d5363602fb761f6611 Mon Sep 17 00:00:00 2001 From: Robert Argasinski Date: Thu, 7 Jan 2016 08:02:18 -0500 Subject: [PATCH 7/7] Real Final DONE --- raindropGameCode/{BucketClass.pde => CatcherClass.pde} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename raindropGameCode/{BucketClass.pde => CatcherClass.pde} (100%) diff --git a/raindropGameCode/BucketClass.pde b/raindropGameCode/CatcherClass.pde similarity index 100% rename from raindropGameCode/BucketClass.pde rename to raindropGameCode/CatcherClass.pde