diff --git a/final_project_stuff/catcher.pde b/final_project_stuff/catcher.pde new file mode 100644 index 0000000..8b833ca --- /dev/null +++ b/final_project_stuff/catcher.pde @@ -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"); + } + } + +} + \ 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..9f59a44 --- /dev/null +++ b/final_project_stuff/final_project_stuff.pde @@ -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; + } + + + +} \ 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 diff --git a/raindropGameCode/catcher.pde b/raindropGameCode/catcher.pde new file mode 100644 index 0000000..21aff22 --- /dev/null +++ b/raindropGameCode/catcher.pde @@ -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; + } +} \ No newline at end of file diff --git a/raindropGameCode/raindrop.pde b/raindropGameCode/raindrop.pde new file mode 100644 index 0000000..9a14e13 --- /dev/null +++ b/raindropGameCode/raindrop.pde @@ -0,0 +1,74 @@ +class Raindrop { + PVector loc, acc; + PVector vel [] = new PVector [count]; + int diam; + color c; + int speed; + int fast = 1; + int score = 0; + float xvel [] = new float [count]; + //this is a constructor. you can have more than one constructor for a given class + Raindrop(float tspeed, int size) { + + 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 + fill(c); //choose color + noStroke(); //no boarders + ellipse(loc.x, loc.y, diam, diam*5); //raindrop location + } + void move() { + //acc.mult(15); + + 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) { + 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() { + 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); + //} +} \ No newline at end of file diff --git a/raindropGameCode/raindropGameCode.pde b/raindropGameCode/raindropGameCode.pde index 944de61..0f8be76 100644 --- a/raindropGameCode/raindropGameCode.pde +++ b/raindropGameCode/raindropGameCode.pde @@ -1,5 +1,14 @@ -PVector mouse; //declare a P -Raindrop r; //declare a new Raindrop called r +int count = 20; +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; // On your own, create an array of Raindrop objects instead of just one // Use the array instead of the single object @@ -7,20 +16,97 @@ 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 -} + + frameRate(60); + count = 20; + score = 0; + 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(speed, 5); //Initialize r. The parameters used are the initial x and y positio); + } + c = new Catcher(125); + t = new timer(); +} 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 + println(speed); + fill(255); + text(score, width -50, height -50); + text("level:", 50, height-50); + text(stage, 115, height-50); + if (frameCount < 300) { + t.display(); } - if (r.loc.y > height + r.diam/2) { //check to see if the raindrop goes below the bottom of the screen - r.reset(); //if it does, reset the raindrop + 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"); + } + if (score >= 100) { //if score is greater or equal to 100 + stage = 3; //go to level 3 + speed = speed*2; + println("level 3"); + } + if (score >= 200) { //if score is greater or equal to 200 + stage = 4; //go to level 4 + speed = speed*2; + println("level 4"); + ; + } + 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 + stage = 6; //go to stage 6 AKA win! + println("WIN!"); + } } -} + 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); + for (int i=0; i < count; i++) { + 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); + 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..1c1784b --- /dev/null +++ b/raindropGameCode/start_count.pde @@ -0,0 +1,33 @@ +class timer { + int time = 5; + + + + timer() { + + + } + void display() { + if (frameCount < 300) { + background(0); + 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; + } + 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