xxxxxxxxxx
/*
I'm stumped! I can't get my "currentCount" variable
to work (see below). I tried everything I could think
of and have been stuck for hours. Do you know why
it's not working? It may just be something small that
needs a fresh pair of eyes to be seen. I have no idea
what it could be though. The start count is defintely
working fine, and the % operator that i just learned from Saman
also seems to be working from my test.
This is the second drawing I'm attempting for this week,
but Saman bailed me out on the last one, so I wanted to
do one totally on my own to turn in (which is this one).
Also, if you force the program to test out the triangles,
you'll see there aren't 200 appearing at once like the
circles. Why is that?
*/
int max_circle_num = 200;
float triangle_x1;
float triangle_y1;
float triangle_x2;
float triangle_y2;
float triangle_x3;
float triangle_y3;
int max_triangle_num = 200;
int startCount = 2;
int currentCount = startCount % 2;
//int currentCount = 3 % 2;
int checkMe = 1;
/*
circles changing color
a click changes them to triangles, then another click back to circles
*/
void setup() {
smooth();
size(600, 600);
frameRate(5);//This is here to check what's being drawn; feel free to change it
}
void draw() {
entireDrawing();
}
void entireDrawing() {
if (currentCount < 1) {
drawCircles();
println(startCount);
println(currentCount);
println(checkMe % 2);
checkMe++;
} else {
drawTriangles();
println(startCount + 100);
println(currentCount + 100);
}
}
void drawCircles() {
for (int circle_num = 0; circle_num < max_circle_num; circle_num += 1) {
if ((mouseX > 255) || (mouseY > 255)) {
fill(mouseX/3, mouseY/4, mouseX/3);
} else {
fill(mouseX, mouseY, mouseX);
}
ellipse(random(0, width), random(height), 40, 40);
}
}
void drawTriangles() {
triangle_x1 = random(500);
triangle_y1 = random(400);
triangle_x2 = random(300);
triangle_y2 = random(450);
triangle_x3 = random(350);
triangle_y3 = random(550);
for (int triangle_num = 0; triangle_num < max_triangle_num; triangle_num += 1) {
if ((mouseX > 255) || (mouseY > 255)) {
fill(mouseY/2.5, mouseX/3, mouseY/2.5);
} else {
fill(mouseY, mouseX, mouseY);
}
triangle(triangle_x1, triangle_y1, triangle_x2, triangle_y2, triangle_x3, triangle_y3);
}
}
void keyTyped() {
startCount += 1;
}