/* built with Studio Sketchpad:
* https://sketchpad.cc
*
* observe the evolution of this sketch:
* https://cst1101.sketchpad.cc/sp/pad/view/ro.bHzoHYK32sP/rev.30
*
* authors:
* Corey Ausby
* Suly Paredes
* license (unless otherwise specified):
* creative commons attribution-share alike 3.0 license.
* https://creativecommons.org/licenses/by-sa/3.0/
*/
// Press R, B, or G to change the color of the rain
/* @pjs preload="/static/uploaded_resources/p.3292/Frog.png", "/static/uploaded_resources/p.3292/frog2.png", "/static/uploaded_resources/p.3292/grass.png", "/static/uploaded_resources/p.3292/tree2.png"; */
PImage grass = loadImage("/static/uploaded_resources/p.3292/grass.png");
PImage tree2 = loadImage("/static/uploaded_resources/p.3292/tree2.png");
PImage Frog = loadImage("/static/uploaded_resources/p.3292/Frog.png");
PImage frog2 = loadImage("/static/uploaded_resources/p.3292/frog2.png");
numbers [] falling;
void setup() {
size (600, 600);
falling = new numbers[150];
for ( int i = 0; i < falling.length; i++) {
falling[i] = new numbers(color(0, 0, 255), int (random(0, width)), int (random(0, height)), 5, i/2);
}
}
void draw() {
background(0);
for ( int i = 0; i < falling.length; i++) {
falling[i].drop();
falling[i].showNum();
falling[i].keypressed();
}
for ( int i = 0; i < falling.length; i++) {
falling[i].horiz();
}
for ( int x=30 ; x < height; x = x + 60) {
fill(155);
stroke(155);
ellipse ( x, 0, 100, 100);
}
image(tree2, 400, 230, 250, 350);
image(frog2, 475, 520, 50, 50);
image(tree2, -30, 230, 250, 350);
image(Frog, 110, 510, 50, 50);
image(grass, 0, 500, width, 100);
}
//--------CLASS-------------
class numbers {
color numColor;
int numX;
int numY;
int YfallSpeed;
int Nsize;
numbers(color numColor_, int numX_, int numY_, int YfallSpeed_, int Nsize_) {
numColor = numColor_;
numX = numX_;
numY = numY_ ;
YfallSpeed = YfallSpeed_;
Nsize = Nsize_;
}
void drop() {
numY = numY + YfallSpeed;
numX = numX + YfallSpeed;
if (numY > 510) {
numY = 0;
}
else if (numX > width) {
numX = 0;
}
}
void horiz () {
float x = int(random(0, width));
int y = int(random(0, height));
color numColor2 = color(random(0, 255), random(0, 255), random(0, 255));
float xSpeed = 10;
x = x + xSpeed;
if ( x > width) {
x = 0;
}
if (y > 510){
y = 0;
}
fill (numColor2);
text("8", x, y, Nsize - 10, Nsize - 10);
}
void showNum() {
fill(numColor);
text( "1", numX, numY, Nsize*6, Nsize);
text("0", numX, numY, Nsize*6, Nsize);
}
void keypressed() {
if (key == 'g' || key == 'G') {
numColor = color( 0, 255, 0);
}
else if ( key == 'r' || key == 'R') {
numColor = color(255, 0, 0);
}
else if ( key == 'b' || key == 'B') {
numColor = color (0, 0, 255);
}
}
}