From 620c220e3ddc3494d06bc7948bce2c2d33033201 Mon Sep 17 00:00:00 2001 From: JoeHom73 Date: Mon, 14 Dec 2015 14:50:26 -0500 Subject: [PATCH 01/12] working with array need to figure out boolean --- raindropGameCode/functions.pde | 56 +++++++++++++++++++++++++++ raindropGameCode/raindropGameCode.pde | 31 ++++++++------- 2 files changed, 74 insertions(+), 13 deletions(-) create mode 100644 raindropGameCode/functions.pde diff --git a/raindropGameCode/functions.pde b/raindropGameCode/functions.pde new file mode 100644 index 0000000..32a82ae --- /dev/null +++ b/raindropGameCode/functions.pde @@ -0,0 +1,56 @@ +class Raindrop { + PVector loc, vel, acc; + int diam; + color c; + int speed; + + //this is a constructor. you can have more than one constructor for a given class + Raindrop(int tspeed, int size) { + speed = tspeed; + diam = size; + loc = new PVector(random(diam, width-diam), random(diam, height-diam)); + vel = new PVector(0, random (1,5)); + vel.mult(3); + acc = PVector.random2D(); + acc.mult(.001); + c = color(random(255), random(255), 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); + } + void move() { + + acc = PVector.random2D(); + acc.mult(.5); + vel.add(acc); + vel.limit(10); + loc.add(vel); + } + void center() { + if (loc.x-diam >= width || loc.y-diam >= height || loc.x+diam <= 0 || loc.y+diam <= 0) { + loc.x = width/2; + loc.y = height/2; + vel = PVector.random2D(); + c = color(random(255), random(255), random(255)); + } + } + boolean isInContactWith (float mouse) { + if (mouse == loc.x +- diam || mouse == loc.y +- diam) { + + mouse = new PVector(mouseX, mouseY); + } + + void reset() { + loc.y= 0-diam/2; + loc.add(vel); + vel.limit(12); + } + void fall() { + loc.add(vel); + + } +} \ No newline at end of file diff --git a/raindropGameCode/raindropGameCode.pde b/raindropGameCode/raindropGameCode.pde index 944de61..1137e95 100644 --- a/raindropGameCode/raindropGameCode.pde +++ b/raindropGameCode/raindropGameCode.pde @@ -1,5 +1,6 @@ +int count =1000; PVector mouse; //declare a P -Raindrop r; //declare a new Raindrop called r +Raindrop[] r = new Raindrop [count]; //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 @@ -8,19 +9,23 @@ 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 + mouse = new PVector(); + for (int i=0; i < count; i++) { + //initialize mouse PVector. value is irrelevant since it will be set at the start of void draw(){} + r[i] = new Raindrop(5, 10); //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 + for (int i=0; i < count; i++) { + mouse.set(mouseX, mouseY); //set value of mouse as mouseX,mouseY + r[i].fall(); //make the raindrop fall. It should accelerate as if pulled towards the ground by earth's gravity + r[i].display(); //display 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].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 - } -} +} \ No newline at end of file From e7aa3dd1e55a084b1752824666c2b8b950d5520f Mon Sep 17 00:00:00 2001 From: JoeHom73 Date: Wed, 16 Dec 2015 14:50:42 -0500 Subject: [PATCH 02/12] some stuff working. Null pointer error tho --- .../{functions.pde => raindrop.pde} | 45 +++++++++++++++---- raindropGameCode/raindropGameCode.pde | 13 +++--- 2 files changed, 43 insertions(+), 15 deletions(-) rename raindropGameCode/{functions.pde => raindrop.pde} (67%) diff --git a/raindropGameCode/functions.pde b/raindropGameCode/raindrop.pde similarity index 67% rename from raindropGameCode/functions.pde rename to raindropGameCode/raindrop.pde index 32a82ae..76128dd 100644 --- a/raindropGameCode/functions.pde +++ b/raindropGameCode/raindrop.pde @@ -1,3 +1,6 @@ + + + class Raindrop { PVector loc, vel, acc; int diam; @@ -9,10 +12,10 @@ class Raindrop { speed = tspeed; diam = size; loc = new PVector(random(diam, width-diam), random(diam, height-diam)); - vel = new PVector(0, random (1,5)); + vel = new PVector(0, 1, 5); vel.mult(3); acc = PVector.random2D(); - acc.mult(.001); + acc.mult(2); c = color(random(255), random(255), random(255)); } @@ -24,8 +27,8 @@ class Raindrop { } void move() { - acc = PVector.random2D(); - acc.mult(.5); + acc = new PVector(0, 2); + acc.mult(15); vel.add(acc); vel.limit(10); loc.add(vel); @@ -38,19 +41,43 @@ class Raindrop { c = color(random(255), random(255), random(255)); } } - boolean isInContactWith (float mouse) { - if (mouse == loc.x +- diam || mouse == loc.y +- diam) { - - mouse = new PVector(mouseX, mouseY); + + + boolean isInContactWith (Catcher c) { + if (loc.dist(c.loc) <= diam/2) { + + return true; + } else { + return false; + //} + } } + void reset() { loc.y= 0-diam/2; + vel= new PVector(0, random(1, 3)); loc.add(vel); vel.limit(12); } + void fall() { loc.add(vel); - + } +} + + +class Catcher { + PVector loc; + int diam; + + Catcher(int tDiam) { + loc = new PVector(mouseX, mouseY); + diam = tDiam; + } + void display() { + fill(0); + noStroke(); + ellipse(loc.x, loc.y, diam, diam); } } \ No newline at end of file diff --git a/raindropGameCode/raindropGameCode.pde b/raindropGameCode/raindropGameCode.pde index 1137e95..d9f6d86 100644 --- a/raindropGameCode/raindropGameCode.pde +++ b/raindropGameCode/raindropGameCode.pde @@ -1,6 +1,7 @@ -int count =1000; +int count =100; PVector mouse; //declare a P Raindrop[] r = new Raindrop [count]; //declare a new Raindrop called r +Catcher c; // On your own, create an array of Raindrop objects instead of just one // Use the array instead of the single object @@ -12,7 +13,7 @@ void setup() { mouse = new PVector(); for (int i=0; i < count; i++) { //initialize mouse PVector. value is irrelevant since it will be set at the start of void draw(){} - r[i] = new Raindrop(5, 10); //Initialize r. The parameters used are the initial x and y positions + r[i] = new Raindrop(1, 15); //Initialize r. The parameters used are the initial x and y positio); } } void draw() { @@ -20,10 +21,10 @@ void draw() { for (int i=0; i < count; i++) { mouse.set(mouseX, mouseY); //set value of mouse as mouseX,mouseY r[i].fall(); //make the raindrop fall. It should accelerate as if pulled towards the ground by earth's gravity - r[i].display(); //display 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 - }*/ + r[i].display(); //display the raindr); + 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 th*/e raindrop + } 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 } From 4fcdb0e56afe4ac0834d305ce86a1aa72215740c Mon Sep 17 00:00:00 2001 From: JoeHom73 Date: Fri, 18 Dec 2015 14:51:29 -0500 Subject: [PATCH 03/12] broken catcher --- raindropGameCode/catcher.pde | 18 ++++++++++++++++++ raindropGameCode/raindrop.pde | 17 +---------------- raindropGameCode/raindropGameCode.pde | 15 ++++++++++----- 3 files changed, 29 insertions(+), 21 deletions(-) create mode 100644 raindropGameCode/catcher.pde diff --git a/raindropGameCode/catcher.pde b/raindropGameCode/catcher.pde new file mode 100644 index 0000000..44b43b5 --- /dev/null +++ b/raindropGameCode/catcher.pde @@ -0,0 +1,18 @@ +class Catcher { + PVector loc; + int diam; + + Catcher(int tDiam) { + loc = new PVector(mouseX, mouseY); + diam = tDiam; + } + void display() { + fill(255); + noStroke(); + ellipse(loc.x, loc.y, diam, diam); + } + void move() { + loc.x = mouseX; + loc.y = mouseY; + } +} \ No newline at end of file diff --git a/raindropGameCode/raindrop.pde b/raindropGameCode/raindrop.pde index 76128dd..c4c1bb0 100644 --- a/raindropGameCode/raindrop.pde +++ b/raindropGameCode/raindrop.pde @@ -6,6 +6,7 @@ class Raindrop { int diam; color c; int speed; + //this is a constructor. you can have more than one constructor for a given class Raindrop(int tspeed, int size) { @@ -64,20 +65,4 @@ class Raindrop { void fall() { loc.add(vel); } -} - - -class Catcher { - PVector loc; - int diam; - - Catcher(int tDiam) { - loc = new PVector(mouseX, mouseY); - diam = tDiam; - } - void display() { - fill(0); - noStroke(); - ellipse(loc.x, loc.y, diam, diam); - } } \ No newline at end of file diff --git a/raindropGameCode/raindropGameCode.pde b/raindropGameCode/raindropGameCode.pde index d9f6d86..c183c0e 100644 --- a/raindropGameCode/raindropGameCode.pde +++ b/raindropGameCode/raindropGameCode.pde @@ -1,5 +1,5 @@ int count =100; -PVector mouse; //declare a P +//PVector mouse; //declare a P Raindrop[] r = new Raindrop [count]; //declare a new Raindrop called r Catcher c; @@ -10,18 +10,23 @@ Catcher c; void setup() { size(1200, 800); - mouse = new PVector(); + //mouse = new PVector(); for (int i=0; i < count; i++) { //initialize mouse PVector. value is irrelevant since it will be set at the start of void draw(){} - r[i] = new Raindrop(1, 15); //Initialize r. The parameters used are the initial x and y positio); + r[i] = new Raindrop(1, 30); //Initialize r. The parameters used are the initial x and y positio); } + c = new Catcher(50); } void draw() { background(0, 200, 255); + for (int i=0; i < count; i++) { - mouse.set(mouseX, mouseY); //set value of mouse as mouseX,mouseY + c.display(); + c.move(); + //mouse.set(mouseX, mouseY); //set value of mouse as mouseX,mouseY r[i].fall(); //make the raindrop fall. It should accelerate as if pulled towards the ground by earth's gravity - r[i].display(); //display the raindr); + r[i].display(); //display the raindr); + 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 th*/e raindrop } From 46f8861e62e5a416a73eba7ab9adb16ef9efcbb9 Mon Sep 17 00:00:00 2001 From: JoeHom73 Date: Wed, 6 Jan 2016 11:57:13 -0500 Subject: [PATCH 04/12] fixed catcher!!!!!!!!! --- raindropGameCode/catcher.pde | 8 ++-- raindropGameCode/raindrop.pde | 62 ++++++++++++++------------- raindropGameCode/raindropGameCode.pde | 12 +++--- 3 files changed, 42 insertions(+), 40 deletions(-) diff --git a/raindropGameCode/catcher.pde b/raindropGameCode/catcher.pde index 44b43b5..6628c56 100644 --- a/raindropGameCode/catcher.pde +++ b/raindropGameCode/catcher.pde @@ -3,15 +3,15 @@ class Catcher { int diam; Catcher(int tDiam) { - loc = new PVector(mouseX, mouseY); - diam = tDiam; + loc = new PVector(mouseX, mouseY); //location of catacher + diam = tDiam; //size } - void display() { + void display() { //displaying catcher fill(255); noStroke(); ellipse(loc.x, loc.y, diam, diam); } - void move() { + void move() { loc.x = mouseX; loc.y = mouseY; } diff --git a/raindropGameCode/raindrop.pde b/raindropGameCode/raindrop.pde index c4c1bb0..49a4082 100644 --- a/raindropGameCode/raindrop.pde +++ b/raindropGameCode/raindrop.pde @@ -6,47 +6,49 @@ class Raindrop { int diam; color c; int speed; - + //this is a constructor. you can have more than one constructor for a given class - Raindrop(int tspeed, int size) { - speed = tspeed; - diam = size; - loc = new PVector(random(diam, width-diam), random(diam, height-diam)); - vel = new PVector(0, 1, 5); - vel.mult(3); - acc = PVector.random2D(); - acc.mult(2); - c = color(random(255), random(255), random(255)); + Raindrop(int tspeed, int size) { + speed = tspeed; //set speed + diam = size; //set raindrop size + loc = new PVector(random(diam, width-diam), random(diam, height-diam)); //set raindrop location + vel = new PVector(0, random(1, 5)); //choose raindrop velocity + vel.mult(3); //multiply raindrop velocity + acc = new PVector(0, 2); //give a random acceleration + acc.mult(2); // multiply acceleration + c = color(random(255), random(255), random(255)); //set color } //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 display() { //display the raindrop + fill(c); //choose color + noStroke(); //no boarders + ellipse(loc.x, loc.y, diam, diam); //raindrop location } void move() { - acc = new PVector(0, 2); - acc.mult(15); + + //acc.mult(15); vel.add(acc); vel.limit(10); loc.add(vel); } - void center() { - if (loc.x-diam >= width || loc.y-diam >= height || loc.x+diam <= 0 || loc.y+diam <= 0) { - loc.x = width/2; - loc.y = height/2; - vel = PVector.random2D(); - c = color(random(255), random(255), random(255)); - } - } + /******* + void center() { + if (loc.x-diam >= width || loc.y-diam >= height || loc.x+diam <= 0 || loc.y+diam <= 0) { + loc.x = width/2; + loc.y = height/2; + vel = PVector.random2D(); + c = color(random(255), random(255), random(255)); + } + } + *************/ - boolean isInContactWith (Catcher c) { - if (loc.dist(c.loc) <= diam/2) { - + boolean isInContactWith (Catcher thing) { + if (thing.loc.dist(loc) < thing.diam/2+diam) { //if the distace between catcher and raindrop is the less than or equal to diam + println("Caught a raindrop in frame " + frameCount); return true; } else { return false; @@ -62,7 +64,7 @@ class Raindrop { vel.limit(12); } - void fall() { - loc.add(vel); - } + //void fall() { + // loc.add(vel); + //} } \ No newline at end of file diff --git a/raindropGameCode/raindropGameCode.pde b/raindropGameCode/raindropGameCode.pde index c183c0e..cf884da 100644 --- a/raindropGameCode/raindropGameCode.pde +++ b/raindropGameCode/raindropGameCode.pde @@ -15,18 +15,18 @@ void setup() { //initialize mouse PVector. value is irrelevant since it will be set at the start of void draw(){} r[i] = new Raindrop(1, 30); //Initialize r. The parameters used are the initial x and y positio); } - c = new Catcher(50); + c = new Catcher(50); } void draw() { background(0, 200, 255); - + c.display(); + c.move(); for (int i=0; i < count; i++) { - c.display(); - c.move(); + //mouse.set(mouseX, mouseY); //set value of mouse as mouseX,mouseY - r[i].fall(); //make the raindrop fall. It should accelerate as if pulled towards the ground by earth's gravity + r[i].move(); //make the raindrop fall. It should accelerate as if pulled towards the ground by earth's gravity r[i].display(); //display the raindr); - + 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 th*/e raindrop } From 50c4f90d97c55e89a6ddf2e350fbd573191e377c Mon Sep 17 00:00:00 2001 From: JoeHom73 Date: Sat, 9 Jan 2016 19:07:35 -0500 Subject: [PATCH 05/12] broken game mode ok so I added levels a start screen and a score counted as well as changed some of the graphics. problems include levels not working (upping speed and level counter) and I could only figure out how to use a start screen with mousepressed instead of mouse clicked. --- raindropGameCode/catcher.pde | 1 + raindropGameCode/raindrop.pde | 36 ++++++++++--- raindropGameCode/raindropGameCode.pde | 78 ++++++++++++++++++++++----- 3 files changed, 94 insertions(+), 21 deletions(-) diff --git a/raindropGameCode/catcher.pde b/raindropGameCode/catcher.pde index 6628c56..21aff22 100644 --- a/raindropGameCode/catcher.pde +++ b/raindropGameCode/catcher.pde @@ -10,6 +10,7 @@ class Catcher { fill(255); noStroke(); ellipse(loc.x, loc.y, diam, diam); + } void move() { loc.x = mouseX; diff --git a/raindropGameCode/raindrop.pde b/raindropGameCode/raindrop.pde index 49a4082..77653be 100644 --- a/raindropGameCode/raindrop.pde +++ b/raindropGameCode/raindrop.pde @@ -6,17 +6,19 @@ class Raindrop { int diam; color c; int speed; + int fast = 1; + int score = 0; //this is a constructor. you can have more than one constructor for a given class Raindrop(int tspeed, int size) { speed = tspeed; //set speed diam = size; //set raindrop size - loc = new PVector(random(diam, width-diam), random(diam, height-diam)); //set raindrop location + loc = new PVector(random(diam, width-diam), 0); //set raindrop location vel = new PVector(0, random(1, 5)); //choose raindrop velocity vel.mult(3); //multiply raindrop velocity acc = new PVector(0, 2); //give a random acceleration - acc.mult(2); // multiply acceleration + acc.mult(.5); // multiply acceleration c = color(random(255), random(255), random(255)); //set color } @@ -24,15 +26,33 @@ class Raindrop { void display() { //display the raindrop fill(c); //choose color noStroke(); //no boarders - ellipse(loc.x, loc.y, diam, diam); //raindrop location + ellipse(loc.x, loc.y, diam, diam*5); //raindrop location } void move() { //acc.mult(15); - vel.add(acc); - vel.limit(10); + loc.add(vel); + vel.limit(10); + if (score == 25) { + vel = new PVector(0, 2); + println("speed up"); + } + if (score == 100) { + vel = new PVector(0, 3); + println("speed up"); + } + + if (score == 200) { + vel = new PVector(0, 4); + println("speed up"); + } + if (score == 300) { + vel = new PVector(0, 5); + println("speed up"); + } + } /******* void center() { @@ -49,6 +69,7 @@ class Raindrop { boolean isInContactWith (Catcher thing) { if (thing.loc.dist(loc) < thing.diam/2+diam) { //if the distace between catcher and raindrop is the less than or equal to diam println("Caught a raindrop in frame " + frameCount); + score = score +1; return true; } else { return false; @@ -58,10 +79,11 @@ class Raindrop { void reset() { - loc.y= 0-diam/2; + loc.y= 0-diam*5; + loc.x=random(0, width); vel= new PVector(0, random(1, 3)); loc.add(vel); - vel.limit(12); + vel.limit(10); } //void fall() { diff --git a/raindropGameCode/raindropGameCode.pde b/raindropGameCode/raindropGameCode.pde index cf884da..9efcf3b 100644 --- a/raindropGameCode/raindropGameCode.pde +++ b/raindropGameCode/raindropGameCode.pde @@ -1,5 +1,11 @@ -int count =100; + + +int count = 10; +int score= 0; +int stage = 1; +int fast = 1; //PVector mouse; //declare a P + Raindrop[] r = new Raindrop [count]; //declare a new Raindrop called r Catcher c; @@ -9,29 +15,73 @@ Catcher c; void setup() { + count = 10; size(1200, 800); + fill(0); + textSize(25); + text("hold left mouse to play game", width/2, height/2); + text(score, width -50, height -50); //mouse = new PVector(); for (int i=0; i < count; i++) { //initialize mouse PVector. value is irrelevant since it will be set at the start of void draw(){} - r[i] = new Raindrop(1, 30); //Initialize r. The parameters used are the initial x and y positio); + r[i] = new Raindrop(1, 10); //Initialize r. The parameters used are the initial x and y positio); } - c = new Catcher(50); + c = new Catcher(150); } + + + void draw() { - background(0, 200, 255); - c.display(); - c.move(); - for (int i=0; i < count; i++) { + fill(255); + text(score, width -50, height -50); + text("level:", 50, height-50); + text(stage, 115, height-50); - //mouse.set(mouseX, mouseY); //set value of mouse as mouseX,mouseY - r[i].move(); //make the raindrop fall. It should accelerate as if pulled towards the ground by earth's gravity - r[i].display(); //display the raindr); - 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 th*/e raindrop + // background(0, 200, 255); + for (int i=0; i < count; i++) { + if (score == 50 && (r[i].isInContactWith(c))) { + stage = stage +1; + println("level up"); + } + } + for (int i=0; i < count; i++) { + if (score == 100 && (r[i].isInContactWith(c))) { + stage = stage +1; + println("level up"); } - 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 + } + for (int i=0; i < count; i++) { + if (score == 200 && (r[i].isInContactWith(c))) { + stage = stage +1; + println("level up"); + } + } + for (int i=0; i < count; i++) { + if (score == 300 && (r[i].isInContactWith(c))) { + stage = stage +1; + println("level up"); + } + } + + if (mousePressed) { + fill(0, 35); + rect(0, 0, width, height); + c.move(); + c.display(); + for (int i=0; i < count; i++) { + //mouse.set(mouseX, mouseY); //set value of mouse as mouseX,mouseY + r[i].move(); //make the raindrop fall. It should accelerate as if pulled towards the ground by earth's gravity + r[i].display(); //display the raindr); + + 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 th*/e raindrop + score = score +1; + } + 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 + } } } + } \ No newline at end of file From 95a3380964b4c44a82532a35c8d7670df62d272b Mon Sep 17 00:00:00 2001 From: JoeHom73 Date: Sat, 9 Jan 2016 22:00:47 -0500 Subject: [PATCH 06/12] mind the println and its relation to the score --- raindropGameCode/raindrop.pde | 46 ++++++++++++++------------- raindropGameCode/raindropGameCode.pde | 6 ++-- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/raindropGameCode/raindrop.pde b/raindropGameCode/raindrop.pde index 77653be..1e5a5e3 100644 --- a/raindropGameCode/raindrop.pde +++ b/raindropGameCode/raindrop.pde @@ -15,7 +15,7 @@ class Raindrop { speed = tspeed; //set speed diam = size; //set raindrop size loc = new PVector(random(diam, width-diam), 0); //set raindrop location - vel = new PVector(0, random(1, 5)); //choose raindrop velocity + vel = new PVector(0, 2); //choose raindrop velocity vel.mult(3); //multiply raindrop velocity acc = new PVector(0, 2); //give a random acceleration acc.mult(.5); // multiply acceleration @@ -32,27 +32,28 @@ class Raindrop { //acc.mult(15); - + loc.add(vel); - vel.limit(10); - if (score == 25) { - vel = new PVector(0, 2); - println("speed up"); - } - if (score == 100) { - vel = new PVector(0, 3); - println("speed up"); - } + if (score >= 0 && score <= 24) { + vel.limit(2); + if (score >= 25 && score <= 50) { + vel.limit(5); + println("speed up1"); + } + if (score >= 51 && score <= 100) { + vel.limit(7); + println("speed up2"); + } - if (score == 200) { - vel = new PVector(0, 4); - println("speed up"); - } - if (score == 300) { - vel = new PVector(0, 5); - println("speed up"); + if (score >= 101 && score <= 125) { + vel.limit(9); + println("speed up3"); + } + if (score >= 126) { + vel.limit(13); + println("speed up4"); + } } - } /******* void center() { @@ -68,8 +69,9 @@ class Raindrop { boolean isInContactWith (Catcher thing) { if (thing.loc.dist(loc) < thing.diam/2+diam) { //if the distace between catcher and raindrop is the less than or equal to diam - println("Caught a raindrop in frame " + frameCount); - score = score +1; + + score = score +1; + println(score); return true; } else { return false; @@ -81,7 +83,7 @@ class Raindrop { void reset() { loc.y= 0-diam*5; loc.x=random(0, width); - vel= new PVector(0, random(1, 3)); + vel= vel.mult(1.0000000000005); loc.add(vel); vel.limit(10); } diff --git a/raindropGameCode/raindropGameCode.pde b/raindropGameCode/raindropGameCode.pde index 9efcf3b..05e4064 100644 --- a/raindropGameCode/raindropGameCode.pde +++ b/raindropGameCode/raindropGameCode.pde @@ -16,7 +16,7 @@ Catcher c; void setup() { count = 10; - size(1200, 800); + size(1000, 750); fill(0); textSize(25); text("hold left mouse to play game", width/2, height/2); @@ -24,9 +24,9 @@ void setup() { //mouse = new PVector(); for (int i=0; i < count; i++) { //initialize mouse PVector. value is irrelevant since it will be set at the start of void draw(){} - r[i] = new Raindrop(1, 10); //Initialize r. The parameters used are the initial x and y positio); + r[i] = new Raindrop(1, 5); //Initialize r. The parameters used are the initial x and y positio); } - c = new Catcher(150); + c = new Catcher(100); } From 7620e2ca79aecb014f9282f84954a8dcba310eec Mon Sep 17 00:00:00 2001 From: JoeHom73 Date: Sun, 10 Jan 2016 16:24:52 -0500 Subject: [PATCH 07/12] fixed a couple of things --- raindropGameCode/raindrop.pde | 13 +++-- raindropGameCode/raindropGameCode.pde | 69 +++++++++++++++++---------- raindropGameCode/start_count.pde | 16 +++++++ 3 files changed, 67 insertions(+), 31 deletions(-) create mode 100644 raindropGameCode/start_count.pde diff --git a/raindropGameCode/raindrop.pde b/raindropGameCode/raindrop.pde index 77653be..b52bf0e 100644 --- a/raindropGameCode/raindrop.pde +++ b/raindropGameCode/raindrop.pde @@ -32,10 +32,10 @@ class Raindrop { //acc.mult(15); - + loc.add(vel); vel.limit(10); - if (score == 25) { + if (score == 25) { vel = new PVector(0, 2); println("speed up"); } @@ -45,14 +45,13 @@ class Raindrop { } if (score == 200) { - vel = new PVector(0, 4); - println("speed up"); + vel = new PVector(0, 4); + println("speed up"); } if (score == 300) { vel = new PVector(0, 5); println("speed up"); } - } /******* void center() { @@ -68,8 +67,8 @@ class Raindrop { boolean isInContactWith (Catcher thing) { if (thing.loc.dist(loc) < thing.diam/2+diam) { //if the distace between catcher and raindrop is the less than or equal to diam - println("Caught a raindrop in frame " + frameCount); - score = score +1; + score = score +1; + println(score); return true; } else { return false; diff --git a/raindropGameCode/raindropGameCode.pde b/raindropGameCode/raindropGameCode.pde index 9efcf3b..26e91a3 100644 --- a/raindropGameCode/raindropGameCode.pde +++ b/raindropGameCode/raindropGameCode.pde @@ -1,6 +1,6 @@ -int count = 10; +int count = 20; int score= 0; int stage = 1; int fast = 1; @@ -8,6 +8,8 @@ int fast = 1; Raindrop[] r = new Raindrop [count]; //declare a new Raindrop called r Catcher c; +timer t; + // On your own, create an array of Raindrop objects instead of just one // Use the array instead of the single object @@ -15,11 +17,12 @@ Catcher c; void setup() { + frameRate(60); count = 10; + score = 0; size(1200, 800); fill(0); textSize(25); - text("hold left mouse to play game", width/2, height/2); text(score, width -50, height -50); //mouse = new PVector(); for (int i=0; i < count; i++) { @@ -27,61 +30,79 @@ void setup() { r[i] = new Raindrop(1, 10); //Initialize r. The parameters used are the initial x and y positio); } c = new Catcher(150); + t = new timer(); } void draw() { + fill(255); text(score, width -50, height -50); text("level:", 50, height-50); text(stage, 115, height-50); + t.display(); - // background(0, 200, 255); - for (int i=0; i < count; i++) { - if (score == 50 && (r[i].isInContactWith(c))) { - stage = stage +1; - println("level up"); + + for (int i=0; i < count; i++) { + if (score >= 50) { //if score is greater or equal to 50 + stage = 2; //go to level 2 + println("level 2"); } } for (int i=0; i < count; i++) { - if (score == 100 && (r[i].isInContactWith(c))) { - stage = stage +1; - println("level up"); + if (score >= 100) { //if score is greater or equal to 100 + stage = 3; //go to level 3 + println("level 3"); } } for (int i=0; i < count; i++) { - if (score == 200 && (r[i].isInContactWith(c))) { - stage = stage +1; - println("level up"); + if (score >= 200) { //if score is greater or equal to 200 + stage = 4; //go to level 4 + println("level 4"); } } for (int i=0; i < count; i++) { - if (score == 300 && (r[i].isInContactWith(c))) { - stage = stage +1; - println("level up"); + if (score >= 300 && score <= 500) { //if score is greater or equal to 300 and less than 500 + stage = 5; //go to level 5 + println("level 5"); + } + if (score > 500) { //if score is greater than 500 + stage = 6; //go to stage 6 AKA win! + println("WIN!"); } } - if (mousePressed) { - fill(0, 35); + if (frameCount >300 && stage <= 5) { //if framerate is less than 300 and stage is less than or equal to 5 + //run game + fill(0, 35); //background rect(0, 0, width, height); - c.move(); - c.display(); + c.move(); //call cather move + c.display(); //display cather for (int i=0; i < count; i++) { //mouse.set(mouseX, mouseY); //set value of mouse as mouseX,mouseY r[i].move(); //make the raindrop fall. It should accelerate as if pulled towards the ground by earth's gravity r[i].display(); //display the raindr); - 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 th*/e raindrop - score = score +1; + score = score +1; //score goes up by one } 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 + fill(255, 0, 0); //if it does, you lose + rect(0, 0, width, height); + fill(0); + textSize(50); + text("You Lose!", width/2.5, height/2); } } } - + if (stage > 5) { + + fill(0, 255, 0); + rect(0, 0, width, height); + fill(0); + textSize(50); + text("you win!", width/2.5, height/2); + } } \ No newline at end of file diff --git a/raindropGameCode/start_count.pde b/raindropGameCode/start_count.pde new file mode 100644 index 0000000..362ed00 --- /dev/null +++ b/raindropGameCode/start_count.pde @@ -0,0 +1,16 @@ +class timer { + int time = 5; + int timer=0; + + + timer() { + timer=frameCount; + if (timer == timer+60) { + time = time -1; + } + } + void display() { + + text(time, 200, 200); + } +} \ No newline at end of file From 49272f967e2f9182d7273f05fff98f285321e835 Mon Sep 17 00:00:00 2001 From: JoeHom73 Date: Tue, 12 Jan 2016 14:52:06 -0500 Subject: [PATCH 08/12] final project stuff --- final_project_stuff/catcher.pde | 21 ++++ final_project_stuff/final_project_stuff.pde | 108 ++++++++++++++++++++ final_project_stuff/raindrop.pde | 94 +++++++++++++++++ 3 files changed, 223 insertions(+) create mode 100644 final_project_stuff/catcher.pde create mode 100644 final_project_stuff/final_project_stuff.pde create mode 100644 final_project_stuff/raindrop.pde diff --git a/final_project_stuff/catcher.pde b/final_project_stuff/catcher.pde new file mode 100644 index 0000000..82ddf45 --- /dev/null +++ b/final_project_stuff/catcher.pde @@ -0,0 +1,21 @@ +class Catcher { + PVector loc; + int diam; + + Catcher(int tDiam) { + loc = new PVector(mouseX, mouseY); //location of catacher + diam = tDiam; //size + loc.x= width/2; + loc.y=height/2; + } + void display() { //displaying catcher + fill(255); + noStroke(); + ellipse(loc.x, loc.y, diam, diam); + + } + void move() { + loc.x = mouseX; + loc.y = mouseY; + } +} \ No newline at end of file diff --git a/final_project_stuff/final_project_stuff.pde b/final_project_stuff/final_project_stuff.pde new file mode 100644 index 0000000..1e4ff47 --- /dev/null +++ b/final_project_stuff/final_project_stuff.pde @@ -0,0 +1,108 @@ + + +int count = 10; +int score= 0; +int stage = 1; +int fast = 1; +int lenghtc=300; +int lenghtb=300; + +//PVector mouse; //declare a P + +Raindrop[] r = new Raindrop [count]; //declare a new Raindrop called r +Catcher c; +Catcher b; +// 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 + + +void setup() { + count = 10; + size(1000, 750); + fill(0); + textSize(25); + text("hold left mouse to play game", width/2, height/2); + text(score, width -50, height -50); + //mouse = new PVector(); + for (int i=0; i < count; i++) { + //initialize mouse PVector. value is irrelevant since it will be set at the start of void draw(){} + r[i] = new Raindrop(1, 5); //Initialize r. The parameters used are the initial x and y positio); + } + c = new Catcher(100); + b = new Catcher(100); +} + + + +void draw() { + fill(255); + text(score, width -50, height -50); + text("level:", 50, height-50); + text(stage, 115, height-50); +rect(100, height-5, lenghtc, 5); +rect(500, height-5, lenghtb, 5); + + // background(0, 200, 255); + for (int i=0; i < count; i++) { + if (score == 50 && (r[i].isInContactWith(c))) { + stage = stage +1; + println("level up"); + } + } + for (int i=0; i < count; i++) { + if (score == 100 && (r[i].isInContactWith(c))) { + stage = stage +1; + println("level up"); + } + } + for (int i=0; i < count; i++) { + if (score == 200 && (r[i].isInContactWith(c))) { + stage = stage +1; + println("level up"); + } + } + for (int i=0; i < count; i++) { + if (score == 300 && (r[i].isInContactWith(c))) { + stage = stage +1; + println("level up"); + } + } + + if (mousePressed) { + fill(0, 35); + rect(0, 0, width, height); + c.move(); + c.display(); + b.display(); + for (int i=0; i < count; i++) { + //mouse.set(mouseX, mouseY); //set value of mouse as mouseX,mouseY + r[i].move(); //make the raindrop fall. It should accelerate as if pulled towards the ground by earth's gravity + r[i].display(); //display the raindr); + + 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 th*/e raindrop + score = score +1; + lenghtc=lenghtc-2; + } + if (r[i].isInContactWith(b)) { //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 th*/e raindrop + score = score +1; + lenghtb=lenghtb-2; + } + 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(lenghtc <=0){ + fill(0, 255,0); + rect(0,0, width ,height); + } + if(lenghtb <=0){ + fill(255, 0,0); + rect(0,0, width ,height); + } + + } + +} \ No newline at end of file diff --git a/final_project_stuff/raindrop.pde b/final_project_stuff/raindrop.pde new file mode 100644 index 0000000..1e5a5e3 --- /dev/null +++ b/final_project_stuff/raindrop.pde @@ -0,0 +1,94 @@ + + + +class Raindrop { + PVector loc, vel, acc; + int diam; + color c; + int speed; + int fast = 1; + int score = 0; + + + //this is a constructor. you can have more than one constructor for a given class + Raindrop(int tspeed, int size) { + speed = tspeed; //set speed + diam = size; //set raindrop size + loc = new PVector(random(diam, width-diam), 0); //set raindrop location + vel = new PVector(0, 2); //choose raindrop velocity + vel.mult(3); //multiply raindrop velocity + acc = new PVector(0, 2); //give a random acceleration + acc.mult(.5); // multiply acceleration + c = color(random(255), random(255), random(255)); //set color + } + + //after declaring fields and setting up constructors, you can define your methods + void display() { //display the raindrop + fill(c); //choose color + noStroke(); //no boarders + ellipse(loc.x, loc.y, diam, diam*5); //raindrop location + } + void move() { + + + //acc.mult(15); + + loc.add(vel); + if (score >= 0 && score <= 24) { + vel.limit(2); + if (score >= 25 && score <= 50) { + vel.limit(5); + println("speed up1"); + } + if (score >= 51 && score <= 100) { + vel.limit(7); + println("speed up2"); + } + + if (score >= 101 && score <= 125) { + vel.limit(9); + println("speed up3"); + } + if (score >= 126) { + vel.limit(13); + println("speed up4"); + } + } + } + /******* + void center() { + if (loc.x-diam >= width || loc.y-diam >= height || loc.x+diam <= 0 || loc.y+diam <= 0) { + loc.x = width/2; + loc.y = height/2; + vel = PVector.random2D(); + c = color(random(255), random(255), random(255)); + } + } + *************/ + + + boolean isInContactWith (Catcher thing) { + if (thing.loc.dist(loc) < thing.diam/2+diam) { //if the distace between catcher and raindrop is the less than or equal to diam + + score = score +1; + println(score); + return true; + } else { + return false; + //} + } + } + + + void reset() { + loc.y= 0-diam*5; + loc.x=random(0, width); + vel= vel.mult(1.0000000000005); + loc.add(vel); + vel.limit(10); + } + + //void fall() { + // loc.add(vel); + //} +} \ No newline at end of file From 615c18dcf9ffad016a050d9635d4fb15b5d638ce Mon Sep 17 00:00:00 2001 From: JoeHom73 Date: Wed, 13 Jan 2016 14:50:15 -0500 Subject: [PATCH 09/12] working on hitboxes and keys but keys r not working --- final_project_stuff/catcher.pde | 28 +++++++-- final_project_stuff/final_project_stuff.pde | 67 +++++++++++++-------- 2 files changed, 63 insertions(+), 32 deletions(-) diff --git a/final_project_stuff/catcher.pde b/final_project_stuff/catcher.pde index 82ddf45..8185dd2 100644 --- a/final_project_stuff/catcher.pde +++ b/final_project_stuff/catcher.pde @@ -3,7 +3,8 @@ class Catcher { int diam; Catcher(int tDiam) { - loc = new PVector(mouseX, mouseY); //location of catacher + + loc = new PVector(random (width), random(height)); //location of catacher diam = tDiam; //size loc.x= width/2; loc.y=height/2; @@ -12,10 +13,25 @@ class Catcher { fill(255); noStroke(); ellipse(loc.x, loc.y, diam, diam); - } - void move() { - loc.x = mouseX; - loc.y = mouseY; + void move(char thekeyleft, char thekeyright, char thekeyup, char thekeydown) { + if (keyPressed && key == thekeyleft) { + loc.x = loc.x-.1; + println("moveleft"); + } + if (keyPressed && key == thekeyright) { + loc.x = loc.x+.1; + println("moveright"); + } + if (keyPressed && key == thekeyup) { + loc.y = loc.y+.1; + println("moveup"); + } + if (keyPressed && key == thekeydown) { + loc.y = loc.y+.1; + println("movedown"); + } } -} \ No newline at end of file + +} + \ No newline at end of file diff --git a/final_project_stuff/final_project_stuff.pde b/final_project_stuff/final_project_stuff.pde index 1e4ff47..aa0f90f 100644 --- a/final_project_stuff/final_project_stuff.pde +++ b/final_project_stuff/final_project_stuff.pde @@ -1,6 +1,6 @@ -int count = 10; +int count = 50; int score= 0; int stage = 1; int fast = 1; @@ -18,11 +18,11 @@ Catcher b; void setup() { - count = 10; + count = 50; size(1000, 750); fill(0); textSize(25); - text("hold left mouse to play game", width/2, height/2); + text("get ready", width/2, height/2); text(score, width -50, height -50); //mouse = new PVector(); for (int i=0; i < count; i++) { @@ -40,11 +40,11 @@ void draw() { text(score, width -50, height -50); text("level:", 50, height-50); text(stage, 115, height-50); -rect(100, height-5, lenghtc, 5); -rect(500, height-5, lenghtb, 5); + rect(100, height-5, lenghtc, 5); + rect(500, height-5, lenghtb, 5); // background(0, 200, 255); - for (int i=0; i < count; i++) { + for (int i=0; i < count; i++) { if (score == 50 && (r[i].isInContactWith(c))) { stage = stage +1; println("level up"); @@ -69,40 +69,55 @@ rect(500, height-5, lenghtb, 5); } } - if (mousePressed) { + if (frameCount >= 100) { fill(0, 35); rect(0, 0, width, height); - c.move(); - c.display(); - b.display(); - for (int i=0; i < count; i++) { - //mouse.set(mouseX, mouseY); //set value of mouse as mouseX,mouseY - r[i].move(); //make the raindrop fall. It should accelerate as if pulled towards the ground by earth's gravity - r[i].display(); //display the raindr); - - if (r[i].isInContactWith(c)) { //check to see if the raindrop is in contact with the point represented by the PVector called mouse + for (int i=0; i < count; i++) { + if (lenghtc >= 0) { + c.display(); + c.move('a', 'd', 'w', 's' ); + 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 th*/e raindrop score = score +1; + if (lenghtc > -2) { lenghtc=lenghtc-2; + } } - if (r[i].isInContactWith(b)) { //check to see if the raindrop is in contact with the point represented by the PVector called mouse + } + if (lenghtb >= 0) { + b.display(); + b.move('h', 'k','u','j'); + if (r[i].isInContactWith(b)) { //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 th*/e raindrop score = score +1; + if (lenghtb > -2) { lenghtb=lenghtb-2; } + } + } + + ////mouse.set(mouseX, mouseY); //set value of mouse as mouseX,mouseY + r[i].move(); //make the raindrop fall. It should accelerate as if pulled towards the ground by earth's gravity + r[i].display(); //display the raindr); + //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 + // score = score +1; + // if (lenghtc > -2) { + // lenghtc=lenghtc-2; + // } + // } + + //if (r[i].isInContactWith(b)) { //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 + // score = score +1; + // if (lenghtb > -2) { + // lenghtb=lenghtb-2; + //} + //} 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(lenghtc <=0){ - fill(0, 255,0); - rect(0,0, width ,height); - } - if(lenghtb <=0){ - fill(255, 0,0); - rect(0,0, width ,height); - } } - } \ No newline at end of file From bc27e4e850e65343e5f2de2f3ee1d2fdbcfeeb22 Mon Sep 17 00:00:00 2001 From: JoeHom73 Date: Thu, 14 Jan 2016 14:52:12 -0500 Subject: [PATCH 10/12] lots of changes --- final_project_stuff/catcher.pde | 31 ++++++++--- final_project_stuff/final_project_stuff.pde | 58 +++++++++++++++++++-- 2 files changed, 79 insertions(+), 10 deletions(-) diff --git a/final_project_stuff/catcher.pde b/final_project_stuff/catcher.pde index 8185dd2..8b833ca 100644 --- a/final_project_stuff/catcher.pde +++ b/final_project_stuff/catcher.pde @@ -1,6 +1,7 @@ class Catcher { PVector loc; int diam; + boolean thekeyleft,thekeyright,thekeyup,thekeydown; Catcher(int tDiam) { @@ -14,20 +15,38 @@ class Catcher { noStroke(); ellipse(loc.x, loc.y, diam, diam); } - void move(char thekeyleft, char thekeyright, char thekeyup, char thekeydown) { - if (keyPressed && key == thekeyleft) { + //void move(char thekeyleft, char thekeyright, char thekeyup, char thekeydown) { + // if (keyPressed && key == thekeyleft) { + // loc.x = loc.x-.1; + // println("moveleft"); + // } + // if (keyPressed && key == thekeyright) { + // loc.x = loc.x+.1; + // println("moveright"); + // } + // if (keyPressed && key == thekeyup) { + // loc.y = loc.y-.1; + // println("moveup"); + // } + // if (keyPressed && key == thekeydown) { + // loc.y = loc.y+.1; + // println("movedown"); + // } + //} + void move() { + if(thekeyleft) { loc.x = loc.x-.1; println("moveleft"); } - if (keyPressed && key == thekeyright) { + if (thekeyright) { loc.x = loc.x+.1; println("moveright"); } - if (keyPressed && key == thekeyup) { - loc.y = loc.y+.1; + if (thekeyup) { + loc.y = loc.y-.1; println("moveup"); } - if (keyPressed && key == thekeydown) { + if (thekeydown) { loc.y = loc.y+.1; println("movedown"); } diff --git a/final_project_stuff/final_project_stuff.pde b/final_project_stuff/final_project_stuff.pde index aa0f90f..9f59a44 100644 --- a/final_project_stuff/final_project_stuff.pde +++ b/final_project_stuff/final_project_stuff.pde @@ -75,23 +75,23 @@ void draw() { for (int i=0; i < count; i++) { if (lenghtc >= 0) { c.display(); - c.move('a', 'd', 'w', 's' ); + c.move(); 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 th*/e raindrop score = score +1; if (lenghtc > -2) { - lenghtc=lenghtc-2; + lenghtc=lenghtc-1; } } } if (lenghtb >= 0) { b.display(); - b.move('h', 'k','u','j'); + b.move();//('h', 'k','u','j'); if (r[i].isInContactWith(b)) { //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 th*/e raindrop score = score +1; if (lenghtb > -2) { - lenghtb=lenghtb-2; + lenghtb=lenghtb-1; } } } @@ -120,4 +120,54 @@ void draw() { } } +} + +void keyPressed(){ + if(key=='h'){ + b.thekeyleft=true; + } + if(key=='k'){ + b.thekeyright=true; + }if(key=='u'){ + b.thekeyup=true; + }if(key=='j'){ + b.thekeydown=true; + } + if(key=='a'){ + c.thekeyleft=true; + } + if(key=='d'){ + c.thekeyright=true; + }if(key=='w'){ + c.thekeyup=true; + }if(key=='s'){ + c.thekeydown=true; + } +} + +void keyReleased() { + + if(key=='h'){ + b.thekeyleft=false; + } + if(key=='k'){ + b.thekeyright=false; + }if(key=='u'){ + b.thekeyup=false; + }if(key=='j'){ + b.thekeydown=false; + } + if(key=='a'){ + c.thekeyleft=false; + } + if(key=='d'){ + c.thekeyright=false; + }if(key=='w'){ + c.thekeyup=false; + }if(key=='s'){ + c.thekeydown=false; + } + + + } \ No newline at end of file From c8c645d3ec85372d5c644fc5ceb64999db801eba Mon Sep 17 00:00:00 2001 From: JoeHom73 Date: Sat, 9 Jan 2016 21:47:27 -0500 Subject: [PATCH 11/12] everything is typing double????? --- raindropGameCode/raindrop.pde | 73 ++++-------------------- raindropGameCode/raindropGameCode.pde | 80 ++++++++++++--------------- raindropGameCode/start_count.pde | 28 ++++++++-- 3 files changed, 68 insertions(+), 113 deletions(-) diff --git a/raindropGameCode/raindrop.pde b/raindropGameCode/raindrop.pde index f7f140a..4282509 100644 --- a/raindropGameCode/raindrop.pde +++ b/raindropGameCode/raindrop.pde @@ -1,6 +1,3 @@ - - - class Raindrop { PVector loc, vel, acc; int diam; @@ -8,20 +5,18 @@ class Raindrop { int speed; int fast = 1; int score = 0; - - + float xvel = random(3); //this is a constructor. you can have more than one constructor for a given class - Raindrop(int tspeed, int size) { - speed = tspeed; //set speed + Raindrop(int tspeed, int size) { diam = size; //set raindrop size + loc = new PVector(random(diam, width-diam), 0); //set raindrop location - vel = new PVector(0, 2); //choose raindrop velocity + vel = new PVector(xvel, tspeed); //choose raindrop velocity vel.mult(3); //multiply raindrop velocity acc = new PVector(0, 2); //give a random acceleration acc.mult(.5); // multiply acceleration c = color(random(255), random(255), random(255)); //set color } - //after declaring fields and setting up constructors, you can define your methods void display() { //display the raindrop fill(c); //choose color @@ -29,52 +24,19 @@ class Raindrop { ellipse(loc.x, loc.y, diam, diam*5); //raindrop location } void move() { - - //acc.mult(15); - loc.add(vel); -<<<<<<< HEAD - vel.limit(10); - if (score == 25) { - vel = new PVector(0, 2); - println("speed up"); - } - if (score == 100) { - vel = new PVector(0, 3); - println("speed up"); - } - - if (score == 200) { - vel = new PVector(0, 4); - println("speed up"); - } - if (score == 300) { - vel = new PVector(0, 5); - println("speed up"); -======= - if (score >= 0 && score <= 24) { - vel.limit(2); - if (score >= 25 && score <= 50) { - vel.limit(5); - println("speed up1"); - } - if (score >= 51 && score <= 100) { - vel.limit(7); - println("speed up2"); + for (int i=0; i < count; i++) { + if (r[i].loc.x > width + r[i].diam/2) { + vel.x= -abs(vx); } + + + - if (score >= 101 && score <= 125) { - vel.limit(9); - println("speed up3"); - } - if (score >= 126) { - vel.limit(13); - println("speed up4"); - } ->>>>>>> origin/joe-version - } + } + /******* void center() { if (loc.x-diam >= width || loc.y-diam >= height || loc.x+diam <= 0 || loc.y+diam <= 0) { @@ -85,14 +47,8 @@ class Raindrop { } } *************/ - - boolean isInContactWith (Catcher thing) { if (thing.loc.dist(loc) < thing.diam/2+diam) { //if the distace between catcher and raindrop is the less than or equal to diam -<<<<<<< HEAD -======= - ->>>>>>> origin/joe-version score = score +1; println(score); return true; @@ -101,16 +57,11 @@ class Raindrop { //} } } - - void reset() { loc.y= 0-diam*5; loc.x=random(0, width); - vel= vel.mult(1.0000000000005); loc.add(vel); - vel.limit(10); } - //void fall() { // loc.add(vel); //} diff --git a/raindropGameCode/raindropGameCode.pde b/raindropGameCode/raindropGameCode.pde index 9f1fdef..0af5fc0 100644 --- a/raindropGameCode/raindropGameCode.pde +++ b/raindropGameCode/raindropGameCode.pde @@ -1,16 +1,12 @@ - - int count = 20; int score= 0; int stage = 1; int fast = 1; -//PVector mouse; //declare a P - +int speed = 1; Raindrop[] r = new Raindrop [count]; //declare a new Raindrop called r Catcher c; timer t; - // 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 @@ -18,62 +14,50 @@ timer t; void setup() { frameRate(60); - count = 10; -<<<<<<< HEAD + count = 20; score = 0; - size(1200, 800); -======= - size(1000, 750); ->>>>>>> origin/joe-version + size(1000, 600); fill(0); textSize(25); text(score, width -50, height -50); + //mouse = new PVector(); for (int i=0; i < count; i++) { //initialize mouse PVector. value is irrelevant since it will be set at the start of void draw(){} - r[i] = new Raindrop(1, 5); //Initialize r. The parameters used are the initial x and y positio); + r[i] = new Raindrop(speed, 5); //Initialize r. The parameters used are the initial x and y positio); } -<<<<<<< HEAD - c = new Catcher(150); + c = new Catcher(125); t = new timer(); -======= - c = new Catcher(100); ->>>>>>> origin/joe-version } - - - void draw() { - + println(speed); fill(255); text(score, width -50, height -50); text("level:", 50, height-50); text(stage, 115, height-50); - t.display(); - - - + if (frameCount < 300) { + t.display(); + } for (int i=0; i < count; i++) { if (score >= 50) { //if score is greater or equal to 50 stage = 2; //go to level 2 + speed = speed*2; println("level 2"); } - } - for (int i=0; i < count; i++) { if (score >= 100) { //if score is greater or equal to 100 stage = 3; //go to level 3 + speed = speed*2; println("level 3"); } - } - for (int i=0; i < count; i++) { if (score >= 200) { //if score is greater or equal to 200 stage = 4; //go to level 4 + speed = speed*2; println("level 4"); + ; } - } - for (int i=0; i < count; i++) { if (score >= 300 && score <= 500) { //if score is greater or equal to 300 and less than 500 stage = 5; //go to level 5 + speed = speed*2; println("level 5"); } if (score > 500) { //if score is greater than 500 @@ -81,22 +65,26 @@ void draw() { println("WIN!"); } } - - if (frameCount >300 && stage <= 5) { //if framerate is less than 300 and stage is less than or equal to 5 - //run game + if (frameCount >300) { //if framerate is less than 300 and stage is less than or equal to 5 + //run game fill(0, 35); //background rect(0, 0, width, height); - c.move(); //call cather move - c.display(); //display cather for (int i=0; i < count; i++) { - //mouse.set(mouseX, mouseY); //set value of mouse as mouseX,mouseY - r[i].move(); //make the raindrop fall. It should accelerate as if pulled towards the ground by earth's gravity - r[i].display(); //display the raindr); - 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 th*/e raindrop - score = score +1; //score goes up by one - } - if (r[i].loc.y > height + r[i].diam/2) { //check to see if the raindrop goes below the bottom of the screen + if (r[i].loc.y < height + r[i].diam/2) { + if (stage <= 5) { + + c.move(); //call cather move + c.display(); //display cather + //mouse.set(mouseX, mouseY); //set value of mouse as mouseX,mouseY + r[i].move(); //make the raindrop fall. It should accelerate as if pulled towards the ground by earth's gravity + r[i].display(); //display the raindr); + 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 th*/e raindrop + score = score +1; //score goes up by one + } + } + } else { + //check to see if the raindrop goes below the bottom of the screen fill(255, 0, 0); //if it does, you lose rect(0, 0, width, height); fill(0); @@ -106,11 +94,11 @@ void draw() { } } if (stage > 5) { - fill(0, 255, 0); rect(0, 0, width, height); fill(0); textSize(50); text("you win!", width/2.5, height/2); } -} \ No newline at end of file + + } \ No newline at end of file diff --git a/raindropGameCode/start_count.pde b/raindropGameCode/start_count.pde index 362ed00..8303c23 100644 --- a/raindropGameCode/start_count.pde +++ b/raindropGameCode/start_count.pde @@ -1,16 +1,32 @@ class timer { int time = 5; - int timer=0; + timer() { - timer=frameCount; - if (timer == timer+60) { - time = time -1; - } + + } void display() { - + if (frameCount < 300) { + background(0); + text("starting soon, try to get to 500 points!", 300, 300); + } + if (frameCount <= 60) { + time = 5; + } + if (frameCount > 60 && frameCount <= 120) { + time = 4; + } + if (frameCount > 120 && frameCount <= 180) { + time = 3; + } + if (frameCount > 180 && frameCount <= 240) { + time = 2; + } + if (frameCount > 240 && frameCount <= 300) { + time = 1; + } text(time, 200, 200); } } \ No newline at end of file From 208f82dfe45e4db9727683e24d4b2ebc357dd866 Mon Sep 17 00:00:00 2001 From: JoeHom73 Date: Sat, 9 Jan 2016 21:43:05 -0500 Subject: [PATCH 12/12] done so I fixed that weird double typing thing and tweaked a couple of things my restart code wasnt working so I took it out --- raindropGameCode/raindrop.pde | 52 +++++++++++++++------------ raindropGameCode/raindropGameCode.pde | 12 +++++-- raindropGameCode/start_count.pde | 3 +- 3 files changed, 41 insertions(+), 26 deletions(-) diff --git a/raindropGameCode/raindrop.pde b/raindropGameCode/raindrop.pde index 4282509..9a14e13 100644 --- a/raindropGameCode/raindrop.pde +++ b/raindropGameCode/raindrop.pde @@ -1,21 +1,25 @@ class Raindrop { - PVector loc, vel, acc; + PVector loc, acc; + PVector vel [] = new PVector [count]; int diam; color c; int speed; int fast = 1; int score = 0; - float xvel = random(3); + float xvel [] = new float [count]; //this is a constructor. you can have more than one constructor for a given class - Raindrop(int tspeed, int size) { - diam = size; //set raindrop size + Raindrop(float tspeed, int size) { - loc = new PVector(random(diam, width-diam), 0); //set raindrop location - vel = new PVector(xvel, tspeed); //choose raindrop velocity - vel.mult(3); //multiply raindrop velocity - acc = new PVector(0, 2); //give a random acceleration - acc.mult(.5); // multiply acceleration - c = color(random(255), random(255), random(255)); //set color + diam = size; //set raindrop size + for (int i=0; i < count; i++) { + tspeed = random(5); + loc = new PVector(random(diam, width-diam), 0); //set raindrop location + vel[i] = new PVector(0, tspeed); //choose raindrop velocity + vel[i].mult(3); //multiply raindrop velocity + acc = new PVector(0, 2); //give a random acceleration + acc.mult(.5); // multiply acceleration + c = color(random(255), random(255), random(255)); //set color + } } //after declaring fields and setting up constructors, you can define your methods void display() { //display the raindrop @@ -25,18 +29,18 @@ class Raindrop { } void move() { //acc.mult(15); - loc.add(vel); - for (int i=0; i < count; i++) { - if (r[i].loc.x > width + r[i].diam/2) { - vel.x= -abs(vx); - } - - - - + for (int i=0; i < count; i++) { + loc.add(vel[i]); + vel[i].limit(.18); + if (r[i].loc.x + r[i].diam/2 >= width ) { + vel[i].x= -abs(vel[i].x); + } + if (r[i].loc.x - r[i].diam/2 <= 0 ) { + vel[i].x= abs(vel[i].x); + } + } } - /******* void center() { if (loc.x-diam >= width || loc.y-diam >= height || loc.x+diam <= 0 || loc.y+diam <= 0) { @@ -58,9 +62,11 @@ class Raindrop { } } void reset() { - loc.y= 0-diam*5; - loc.x=random(0, width); - loc.add(vel); + for (int i=0; i < count; i++) { + loc.y= 0-diam*5; + loc.x=random(0, width); + loc.add(vel[i]); + } } //void fall() { // loc.add(vel); diff --git a/raindropGameCode/raindropGameCode.pde b/raindropGameCode/raindropGameCode.pde index 0af5fc0..0f8be76 100644 --- a/raindropGameCode/raindropGameCode.pde +++ b/raindropGameCode/raindropGameCode.pde @@ -3,6 +3,9 @@ int score= 0; int stage = 1; int fast = 1; int speed = 1; +int tspeed = 1; + + Raindrop[] r = new Raindrop [count]; //declare a new Raindrop called r Catcher c; timer t; @@ -13,6 +16,7 @@ timer t; void setup() { + frameRate(60); count = 20; score = 0; @@ -90,6 +94,7 @@ void draw() { fill(0); textSize(50); text("You Lose!", width/2.5, height/2); + } } } @@ -100,5 +105,8 @@ void draw() { textSize(50); text("you win!", width/2.5, height/2); } - - } \ No newline at end of file + + + } + + \ No newline at end of file diff --git a/raindropGameCode/start_count.pde b/raindropGameCode/start_count.pde index 8303c23..1c1784b 100644 --- a/raindropGameCode/start_count.pde +++ b/raindropGameCode/start_count.pde @@ -10,7 +10,8 @@ class timer { void display() { if (frameCount < 300) { background(0); - text("starting soon, try to get to 500 points!", 300, 300); + text("starting soon, try to get to 500 points!", 300, 300); + text("don't let the rain drops hit the ground!", 300, 500); } if (frameCount <= 60) { time = 5;