diff --git a/raindropGameCode/Bucket.pde b/raindropGameCode/Bucket.pde new file mode 100644 index 0000000..f21546d --- /dev/null +++ b/raindropGameCode/Bucket.pde @@ -0,0 +1,13 @@ + +class bucket { //bucket class + PVector loc; //vector for bucket + + bucket() { + loc = new PVector(mouseX, mouseY); //loc is equal to new PVector + } + void display() { + loc.set(mouseX, mouseY); //sets the PVector to mouse coordinates + fill(255); //fill of ellipse + ellipse(loc.x, loc.y, 50, 50); //bucket for raindrop + } +} \ No newline at end of file diff --git a/raindropGameCode/Raindrop_Class.pde b/raindropGameCode/Raindrop_Class.pde new file mode 100644 index 0000000..269db3e --- /dev/null +++ b/raindropGameCode/Raindrop_Class.pde @@ -0,0 +1,36 @@ +class Raindrop { //raindrop class + float diam = 30; //intialize needed values for class + int score; + PVector loc, vel, grav; + + Raindrop(float x, float y) { // raindrop values + loc = new PVector(x, y); + vel = PVector.random2D(); //velocity of drops + grav = new PVector(0, 0.08); //gravity affected on drops + } + void display() { + fill(51, 204, 255); //fill of drops + noStroke(); + triangle(loc.x-diam/2, loc.y, loc.x+diam/2, loc.y, loc.x, loc.y-diam); //shape of raindrop + ellipse(loc.x, loc.y, diam, diam); + } + void fall() { //cause raindrops to fall due to velocity and acceleration + loc.add(vel); + vel.add(grav); + } + boolean reset() { //resets position of raindrops if falls past height + if (loc.y > height + diam/2) { + return true; //returns true or returns false + } else { + return false; + } + } + boolean isInContactWith(bucket m) { //checks to see if mouse is in contact with bucket + if ( loc.dist(m.loc) <= diam/2 + 25) { + println("Staying Dry"); //prints if a raindrop is removed + return true;//returns true or returns false + } else { + return false; + } + } +} \ No newline at end of file diff --git a/raindropGameCode/data/Agency-48.vlw b/raindropGameCode/data/Agency-48.vlw new file mode 100644 index 0000000..eb45a87 Binary files /dev/null and b/raindropGameCode/data/Agency-48.vlw differ diff --git a/raindropGameCode/data/DG64E4o.jpg b/raindropGameCode/data/DG64E4o.jpg new file mode 100644 index 0000000..cac21ef Binary files /dev/null and b/raindropGameCode/data/DG64E4o.jpg differ diff --git a/raindropGameCode/data/POL-stealth-mode-short.wav b/raindropGameCode/data/POL-stealth-mode-short.wav new file mode 100644 index 0000000..5ec629b Binary files /dev/null and b/raindropGameCode/data/POL-stealth-mode-short.wav differ diff --git a/raindropGameCode/data/Rain.mp3 b/raindropGameCode/data/Rain.mp3 new file mode 100644 index 0000000..8f81c37 Binary files /dev/null and b/raindropGameCode/data/Rain.mp3 differ diff --git a/raindropGameCode/data/Sky.png b/raindropGameCode/data/Sky.png new file mode 100644 index 0000000..1120f63 Binary files /dev/null and b/raindropGameCode/data/Sky.png differ diff --git a/raindropGameCode/data/Untitled.png b/raindropGameCode/data/Untitled.png new file mode 100644 index 0000000..13b84f2 Binary files /dev/null and b/raindropGameCode/data/Untitled.png differ diff --git a/raindropGameCode/data/img.jpg b/raindropGameCode/data/img.jpg new file mode 100644 index 0000000..603edd3 Binary files /dev/null and b/raindropGameCode/data/img.jpg differ diff --git a/raindropGameCode/raindropGameCode.pde b/raindropGameCode/raindropGameCode.pde index 944de61..1fb98fb 100644 --- a/raindropGameCode/raindropGameCode.pde +++ b/raindropGameCode/raindropGameCode.pde @@ -1,26 +1,185 @@ -PVector mouse; //declare a P -Raindrop r; //declare a new Raindrop called r +import ddf.minim.*; //imported library for audio to work +import ddf.minim.analysis.*; +import ddf.minim.effects.*; +import ddf.minim.signals.*; +import ddf.minim.spi.*; +import ddf.minim.ugens.*; -// 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 +Minim minim; //initial library for audio +AudioPlayer sound; +AudioPlayer sound1; +ArrayList raindrops = new ArrayList(); //declare and initialize the ArrayList +int score; //initialized variable needed for the score +int screen;//initialized variable needed for the screens +bucket b; //using class +PFont f; //custom font f +int health; //health of player +int ld; //loading bar on startup +PImage load; //loading screen images +PImage sc; +PImage sc2; 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 + size(1000, 800); //size of canvas + minim = new Minim(this); //minim audio import + sound = minim.loadFile("POL-stealth-mode-short.wav"); //play first sound + sound.play(); + sound.loop(); //loop first audio + screen = 1; //give screen value + health = 10; //give initial health value + ld = 10; //loading bar value + load = loadImage("DG64E4o.jpg"); //loaded images needed + sc = loadImage("Sky.png"); + sc2 = loadImage("img.jpg"); + b = new bucket(); //b becomes variable for bucket class + f = loadFont("Agency-48.vlw"); //loaded custom font + raindrops.add(new Raindrop(random(40, 960), 0)); //add a new Particle to the particles ArrayList } void draw() { - mouse.set(mouseX, mouseY); //set value of mouse as mouseX,mouseY - background(0, 200, 255); - r.fall(); //make the raindrop fall. It should accelerate as if pulled towards the ground by earth's gravity - r.display(); //display the raindrop - if (r.isInContactWith(mouse)) { //check to see if the raindrop is in contact with the point represented by the PVector called mouse - r.reset(); //if it is, reset the raindrop + if (screen == 1) { //first screen of code + background(0); + image(load, 0, 0, 1000, 800); //load image to entire canvas size + noStroke(); //text attributes + textAlign(CENTER); + textFont(f, 96); //changed text font + text("Presenting GVGames", width/2, height/2); //loading screen text + rect(0, height-25, ld, height-25); //loading bar + if (frameCount>1) { + ld+=10; //increase loading bar to progess to menu but no actions can be done until fully loaded + } + if (ld >= width+20) { //bar fully loaded when reaches slightly past canvas border + background(0); + text("Press Any Key to Load into Menu", width/2, height/2); //text to enter menu + } } - 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 (screen == 2) { //second screen of game or menu screen + background(0); + image(sc2, 0, 0, 1000, 800); //background image of menu + textFont(f, 108); //set text to custom font f + textAlign(CENTER); //text attributes + text("Raindrops Game", width/2, 140); //game title + text("Press Any Key to Cotinue...", width/2, height-170); //press any key on keyboard to continue to next screen + textSize(48); //text attributes + text("Game Created By GiLbSoN", width/2, height-40); //Name (ITS LIT!) + } + if (screen == 3) { //third screen or instruction menu + background(0); + stroke(255); //border of menu attributes + strokeWeight(10); + fill(0); + rect(10, 10, width-20, height-20); + fill(255); + textAlign(CENTER); //text attributes + textSize(56); + text("Try and stay dry as long as possible.", width/2, 260); //instuctions to player + text("If you let more than 10 drops pass", width/2, 370); + text("YOU LOSE!", width/2, 480); + text("Try and see if you can get the high score!", width/2, 590); + if (keyPressed == true) { + sound.pause(); //if key is pressed pauses first audio + minim = new Minim(this); + sound1 = minim.loadFile("Rain.mp3"); //loads second audio + } + } + if (screen == 4) { + game(); //loads into game + } +} +void game() { + background(0); + image(sc, 0, 0, 1000, 800); //background image of game screen + + //next if statements change the number of drops as the players score increases (i added a lot of if statements just so nobody wins) + if (score<10) {//score range for difficulty + if (raindrops.size()<= 1) { + raindrops.add(new Raindrop(random(40, 960), 0)); //add a new drop to the particles ArrayList + } + } + if (score>10 && !(score>20)) { //score range for difficulty + if (raindrops.size()<= 2) { + raindrops.add(new Raindrop(random(40, 960), 0)); //add a new drop to the particles ArrayList + } + } + if (score>20 && !(score>30)) {//score range for difficulty + if (raindrops.size()<= 3) { + raindrops.add(new Raindrop(random(40, 960), 0)); //add a new drop to the particles ArrayList + } + } + if (score>30 && !(score>40)) {//score range for difficulty + if (raindrops.size()<= 4) { + raindrops.add(new Raindrop(random(40, 960), 0)); //add a new drop to the particles ArrayList + } + } + if (score>40 && !(score>50)) {//score range for difficulty + if (raindrops.size()<= 5) { + raindrops.add(new Raindrop(random(40, 960), 0)); //add a new drop to the particles ArrayList + } + } + if (score>50 && !(score>60)) {//score range for difficulty + if (raindrops.size()<= 6) { + raindrops.add(new Raindrop(random(40, 960), 0)); //add a new drop to the particles ArrayList + } + } + if (score>60 && !(score>70)) {//score range for difficulty + if (raindrops.size()<= 7) { + raindrops.add(new Raindrop(random(40, 960), 0)); //add a new drop to the particles ArrayList + } + } + if (score>70 && !(score>80)) {//score range for difficulty + if (raindrops.size()<= 8) { + raindrops.add(new Raindrop(random(40, 960), 0)); //add a new drop to the particles ArrayList + } + } + if (score>80 && !(score>100)) {//score range for difficulty + if (raindrops.size()<= 9) { + raindrops.add(new Raindrop(random(40, 960), 0)); //add a new drop to the particles ArrayList + } + } + sound1.play(); //plays second audio + for (int e = raindrops.size()-1; e >= 0; e--) { //go through the ArrayList backwards to prevent flickering + Raindrop d = raindrops.get(e); //get the drop in location e and store it in raindrop d + d.display(); //display d variable + d.fall(); //make d fall + if (d.reset()) { //if d resets + raindrops.remove(e); //remove drop at location e + health-=1; + } + if (d.isInContactWith(b)) { + raindrops.remove(e); //remove drop at location e + score+=1; + } + } + b.display(); //displays bucket + textSize(32); //text attributes for score and health + text("SCORE", 100, 640); + text(score, 100, 680); + text("HEALTH", width-100, 640); + text(health, width-100, 680); + if (score >= 100) { + background(0); + fill(0, 255, 0); //text attributes + textSize(72); + text("You Win!", width/2, height/2-40); //you won the game text but note this is literally impossible to get + text("You Stayed Dry", width/2, height/2+40); + text("Press Esc to Exit", width/2, height/2+120); //you actually beat the game and you can exit + } + if (health<= 0) { //when health reaches zero it brings up game over screen + background(0); + fill(255, 0, 0); //text attributes + textSize(72); + text("GAME OVER", width/2, height/2-40); //game over text + text("You Are Soaked", width/2, height/2+40); + text("Press Esc to Exit", width/2, height/2+120); //only option is to exit game since you have failed to reach 100 + println("You Are Soaked"); //prints if you lose game } } + +void keyPressed() { + if (ld>width) { //when loading bar is complete you can press a key to advance into game + if (screen == 1 || screen == 2 || screen == 3) { //only allows advances in loading, menu, and instruction screens + screen+=1; //increases screen value + } + } +} \ No newline at end of file