Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
b8e06e7
making class for raindrop
atgao Dec 14, 2015
22ef506
fixed raindrop class
atgao Dec 14, 2015
19e9cd4
made arrays for raindrops
atgao Dec 14, 2015
4cb6065
updaed some stuff
atgao Dec 14, 2015
943aa31
added bucket class
atgao Dec 16, 2015
6f88dff
finished bucket constructor
atgao Dec 16, 2015
af78e5c
bucket can catch raindrops
atgao Dec 16, 2015
3fb8701
made arraylist
atgao Dec 18, 2015
2527cd1
fixed arrays list
atgao Dec 18, 2015
1112c07
got rid of some old array cold and stuff
atgao Dec 18, 2015
beebe0f
has more raindrops
atgao Dec 18, 2015
cbdda9e
fixed some stuff with the array list
atgao Jan 4, 2016
8f8a109
other stuff
atgao Jan 4, 2016
b99eb17
asdfjk;l
atgao Jan 4, 2016
c5b6c44
added snowman
atgao Jan 5, 2016
541fc57
made bucket into snowman
atgao Jan 5, 2016
4e9db0a
chanced isINContactWith function
atgao Jan 5, 2016
a9605da
asdf
atgao Jan 5, 2016
f7db29a
stuff
atgao Jan 5, 2016
fa2be66
asdfffff
atgao Jan 5, 2016
d5a1a14
FOUND THE MISSY CURLY BRACKET
atgao Jan 5, 2016
d27ba23
other stuff
atgao Jan 5, 2016
596b407
yay
atgao Jan 5, 2016
a50cd4f
made functin to call upon
atgao Jan 6, 2016
14971ee
added a sun
atgao Jan 6, 2016
41d956f
committing changes just in case
atgao Jan 6, 2016
a5e1289
added a sun to move around
atgao Jan 6, 2016
10eaa44
reput sun stuff into new .pde
atgao Jan 6, 2016
1334d17
got sun to melt stuff
atgao Jan 6, 2016
2664962
oing to add a game mode
atgao Jan 6, 2016
fec9da7
added my gamemodes successfully
atgao Jan 6, 2016
1a169b9
gah a few more glitches
atgao Jan 6, 2016
9822099
eeek
atgao Jan 6, 2016
7a0d51b
other stuff
atgao Jan 6, 2016
b694122
fixed some stuff and added some commnets
atgao Jan 7, 2016
63210f6
Merge remote-tracking branch 'refs/remotes/origin/arraylist'
atgao Jan 7, 2016
05d81a3
final updates!!
atgao Jan 7, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions raindropGameCode/catcher.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
class Bucket { //declare new class for catching raindrops
PVector loc;
PImage s;
float c, d; //control size of image

Bucket () { //create constructor
s = loadImage("snowman.png");
loc = new PVector (random(width), random(height));
imageMode(CENTER); //centers image
c = 250;
d = 278;
}

void display () { //function display bucket
image (s, loc.x, loc.y, c, d); //draw image
}

void update () {
loc.set(mouseX, mouseY); //makes loc = mouse
}

void decrease (float a) { //function to decrease size of img
c = c- a; //decrease width
d = d - a; //decrease height
}
}
Binary file added raindropGameCode/data/snowman.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added raindropGameCode/data/sun.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
152 changes: 135 additions & 17 deletions raindropGameCode/raindropGameCode.pde
Original file line number Diff line number Diff line change
@@ -1,26 +1,144 @@
PVector mouse; //declare a P
Raindrop r; //declare a new Raindrop called r
ArrayList<Raindrop> rds = new ArrayList <Raindrop>(); //make array list

Bucket b; //make bucket catcher
Sun melt;


PVector mouse; //declare a Pvector mouse

int s = 0; //declare + intialize s = score
int count = 0; //counts number of raindrops in bucket
int gamemode = 0; //variabl efor game mode

// 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() {
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(1200, 800); //set size of screen
mouse = new PVector(); //initialize mouse PVector. value is irrelevant since it will be set at the start of void draw(){}
rds.add(new Raindrop(random(width), random(-height, 0))); //add raindrops to arraylist
b = new Bucket(); //bucket with diameter of 100
melt = new Sun();
textAlign(CENTER); //centers text
}

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


void draw () {
if (gamemode == 0) { //if game mode is 0 , show start screen
startscreen();
} else if (gamemode ==1) {
playgame(); //starts game
} else if (gamemode == 2) { //if gamemmode is 2, game over screen
losescreen();
} else if (gamemode == 3) { //if gamemode is 3, you win screen
winscreen();
}
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
}

void startscreen() { //startscreen fuctnion
background(0, 200, 255); //bg color
textSize(100);
fill(255);
text("Snowman", width/2, 350); //beginning info and such
textSize(20);
text("The goal of this game is to make Frosty as big as possible by collecting snowballs.", width/2, height/2);
text("Press 'SHIFT' to start", width/2, 430);
}

void winscreen() { //winscreen function
background(0, 200, 255); //bg color
textSize(50);
text("YOU WIN", width/2, height/2); //you win
textSize(30);
text("Press 'Shift' to restart game", width/2, 450);
}

void losescreen() { //losescreen fnction
background(0, 200, 255); //bg color
textSize(50);
text("GAME OVER", width/2, height/2); //game over
textSize(30);
text("Press 'Shift' to restart game", width/2, 450);
}


void playgame() { //playgame funcion
println(rds.size()); //check size of array list

background(0, 200, 255); //bg color

mouse.set(mouseX, mouseY); //set value of mouse as mouseX,mouseY
fill(255); //make scoreboard white
rect(1100, 700, 1200, 800); //draw scoreboard
fill(242, 81, 56); //score color
textSize(30); //change text size
text(s, 1150, 750); //displays score

melt.display(); //displays sun

for (int i = 0; i < 40; i++) { //start w/ 40 snowballs
rds.add(new Raindrop(random(width), random(-height, 0))); //add new snowballs to array list
}

b.update(); //updates b.loc as mouse
b.display(); //display bucket

for (int i= rds.size() - 1; i >= 0; i --) {
Raindrop r = rds.get(i); //getting item in array rds at index i
r.display(); //displays raindrop
r.fall(); //raindrops will fall


if (r.melts(melt)) { //if sun touches snowball
rds.remove(i); // remove snowball
}

if (r.isInContactWith(b)) { //if a raindrop is in contact with the bucket
rds.remove(i); //remove raindrop
count++; //increase count each time bucket touches raindrop

if (count >= 100) {
s++; //increase score
count = 0; //reset count to 0
b.decrease(-15); //increases size of snowman
}

if (count <= 500 && s >= 5) { //if the bucket has caught < 199 raindrops and score is > 5
b.decrease(.55); //decreases size of snowman
}

if (r.loc.y > height) { //if randrop hits the bottom of the screen
rds.remove(i); //remove raindrop
rds.clear(); //clears out arraylist
}
}
}
if (b.c <= 50) { //if snowman's width < 50
gamemode = 2; //game over screen
}

if (s == 10 || b.c > 600) { //if score gets to 10
gamemode = 3; //you win screen
}
}

void keyPressed() {
if (keyCode == SHIFT) {
if (gamemode == 0) {
gamemode = 1; //game mode changes
rds.clear(); //clear arraylist
} else if (gamemode == 2) {
gamemode = 1; //game mode changes
s = 0; //reset score
b.c = 250; //reset snowman's width
b.d = 278; //reset snowman's height
rds.clear(); //clear arraylist
} else if (gamemode == 3) {
gamemode = 1; //game mode changes
s = 0; //reset score
b.c = 250; //reset snowman's width
b.d = 278; //reset snowman's height
rds.clear(); //clear arraylist
}
}
}
46 changes: 46 additions & 0 deletions raindropGameCode/raindrop_class.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
class Raindrop { //create class for raindrop
PVector loc, vel, g; //location for raindrop
int diam ; //diameter for raindrop
color c; //color for raindrop


Raindrop (float x, float y) {
diam = 20; //diameter is 20
loc = new PVector(x, y);
c = color(208, 237, 247); //makes raindrop blue
vel = PVector.random2D(); //velocity with random magnitude of 1
vel.mult(random(2, 7)); //multiplies velocity
g = new PVector (0, 0.2); //acceleration of 0,2
}

void display () {
fill(c); //makes raindrop blue
noStroke(); //no stroke
ellipse(loc.x, loc.y, diam, diam); //creates raindrop
}

void fall() {
loc.add(vel); //gives raindrop velocity
vel.add(g); // add gravity
}
void reset () {
loc.y = 0; //brings raindrop back to top of screen
loc.x = random(diam/2, width - diam/2); //resets raindrop in x direction
vel.x = 0;
vel.y = 0; //this way raindrop wont speed up
}
boolean isInContactWith(Bucket b) {
if (loc.dist(b.loc) < diam/2 + b.loc.y*.3) { //if distance between mouse and snowball is less than the snowball's raidus and image's height/3
return true;
} else {
return false;
}
}
boolean melts (Sun m) { //function melt snowballs
if (loc.dist(m.loc) < diam/2 + m.loc.x/4) { //if distance is less than the diameter of the snowball + width of image/4
return true; //then return true
} else { //otherwise
return false; //otherwise return false
}
}
}
25 changes: 25 additions & 0 deletions raindropGameCode/sun
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
class Sun { //declare new class for catching raindrops
PVector loc, vel;
PImage s;
float c, d; //control size of image

Sun () { //create constructor
s = loadImage("sun.png");
loc = new PVector (random(width), 100);
vel = new PVector (random(-10, 10), 0);
imageMode(CENTER); //centers image
c = 250;
d = 200;
}

void display () { //function display bucket
image (s, loc.x, loc.y, c, d);
loc.add(vel); //give sun velocity
if (loc.x + c/2 >= width) { //if sun passes off screen
vel.mult(-1); //reverse direction
}
if (loc.x - c/2 <= 0) {
vel.mult(-1);
}
}
}
25 changes: 25 additions & 0 deletions raindropGameCode/sun.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
class Sun { //declare new class for catching raindrops
PVector loc, vel;
PImage s;
float c, d; //control size of image

Sun () { //create constructor
s = loadImage("sun.png");
loc = new PVector (random(width), 100);
vel = new PVector (random(-10, 10), 0);
imageMode(CENTER); //centers image
c = 250; //width
d = 200; //height
}

void display () { //function display bucket
image (s, loc.x, loc.y, c, d);
loc.add(vel); //give sun velocity
if (loc.x + c/2 >= width) { //if sun passes off right side of screen
vel.mult(-1); //reverse direction
}
if (loc.x - c/2 <= 0) { //if sun passes off left side of screen
vel.mult(-1); //reverse direction
}
}
}