Last active
October 25, 2015 03:15
-
-
Save jessherzog/ff7f1fa6d2c9d7992b09 to your computer and use it in GitHub Desktop.
state changes / plant growing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// as you click each slide, the plant stem grows! | |
// you can toggle back and forth using the left and right arrow keys. | |
float posX = 2; | |
float posY = 2; | |
float sizeX = 0; | |
float sizeY = 0; | |
int lineX = 0; | |
int lineY = 0; | |
color[] colors = new color[3]; | |
int whichState = 0; | |
void setup() { | |
size(500, 500); | |
smooth(); | |
rectMode(CENTER); | |
} | |
void draw() { | |
posX = sin(80) * 30; | |
posY = -cos(40) * 30; | |
sizeX = -sin(50) * 20; | |
sizeY = cos(120) * 20; | |
if (whichState == 0) { | |
background(0, 0, 0, 2); | |
} else if (whichState == 1) { | |
background(40, 40, 40); | |
} else if (whichState == 2) { | |
background(222, 47, 88); | |
} else if (whichState == 3) { | |
background(#DE2F98); | |
} else if (whichState == 4) { | |
background(#F03602); | |
} else if (whichState == 5) { | |
background(#D37E8F); | |
} else if (whichState == 6) { | |
background(#CB00FA); | |
} else if (whichState == 7) { | |
background(#FA6000); | |
} else if (whichState == 8) { | |
background(#FF035B); | |
} | |
for (int i = 0; i < 9; i++) { | |
fill(255); | |
noStroke(); | |
float posX = 75 + i * 30; | |
float posY = 450; | |
float size = 10; | |
if (whichState == i) { | |
fill(#CBFF6C); | |
} | |
//fill(233, 3); | |
ellipse(posX, posY, size, size); | |
rect(posX, posY, size, size); | |
// water | |
fill(#839FA2); | |
ellipse(200, 330, 200, 40); | |
ellipse(150, 320, 100, 40); | |
ellipse(250, 350, 100, 40); | |
// drops | |
fill(random(255)); | |
ellipse(150, 230, 3, 6); | |
ellipse(170, 220, 3, 6); | |
ellipse(190, 250, 3, 6); | |
ellipse(200, 230, 3, 6); | |
ellipse(230, 220, 3, 6); | |
ellipse(250, 250, 3, 6); | |
ellipse(150, 230, 3, 6); | |
ellipse(170, 320, 3, 6); | |
ellipse(190, 350, 3, 6); | |
ellipse(200, 330, 3, 6); | |
ellipse(230, 310, 3, 6); | |
ellipse(250, 350, 3, 6); | |
drawPlant(100, 120, 200, 300); | |
} | |
} | |
void drawPlant(float xloc, float yloc, int top, int bot) { | |
for (int g = 0; g < 9; g++) { | |
fill(#139D1D); | |
strokeWeight(7); | |
line(100, 100, 200 - g* 4, 200 - g* 9); | |
} | |
} | |
void keyPressed() { | |
if (key == CODED) { | |
if (keyCode == RIGHT) { | |
println("right button just pressed"); | |
whichState++; | |
if (whichState > 8) { | |
whichState = 0; | |
} | |
} | |
if (keyCode == LEFT) { | |
println("left button just pressed"); | |
whichState--; | |
if (whichState < 0) { | |
whichState = 8; | |
} | |
} | |
} | |
} | |
//if (whichState > 0 && key == RIGHT) { | |
// for (int g = 0; g < 9; g++) { | |
// fill(#139D1D); | |
// strokeWeight(7); | |
// line(100, g, 100, 200); | |
// else if (key == LEFT) { | |
// g--; | |
// } else { | |
// g = 100; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment