Skip to content
56 changes: 56 additions & 0 deletions final_project_stuff/catcher.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
class Catcher {
PVector loc;
int diam;
boolean thekeyleft,thekeyright,thekeyup,thekeydown;

Catcher(int tDiam) {

loc = new PVector(random (width), random(height)); //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(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 (thekeyright) {
loc.x = loc.x+.1;
println("moveright");
}
if (thekeyup) {
loc.y = loc.y-.1;
println("moveup");
}
if (thekeydown) {
loc.y = loc.y+.1;
println("movedown");
}
}

}

173 changes: 173 additions & 0 deletions final_project_stuff/final_project_stuff.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@


int count = 50;
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 = 50;
size(1000, 750);
fill(0);
textSize(25);
text("get ready", 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 (frameCount >= 100) {
fill(0, 35);
rect(0, 0, width, height);
for (int i=0; i < count; i++) {
if (lenghtc >= 0) {
c.display();
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-1;
}
}
}
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-1;
}
}
}

////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
}
}

}
}

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;
}



}
94 changes: 94 additions & 0 deletions final_project_stuff/raindrop.pde
Original file line number Diff line number Diff line change
@@ -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);
//}
}
19 changes: 19 additions & 0 deletions raindropGameCode/catcher.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class Catcher {
PVector loc;
int diam;

Catcher(int tDiam) {
loc = new PVector(mouseX, mouseY); //location of catacher
diam = tDiam; //size
}
void display() { //displaying catcher
fill(255);
noStroke();
ellipse(loc.x, loc.y, diam, diam);

}
void move() {
loc.x = mouseX;
loc.y = mouseY;
}
}
Loading