My program simulates peeing in the snow. I have the bulk of my code done, but I'm running into some problems.
1.) I want to add some off-white to my white snow background. I'm using a nested for loop in draw():
for (int i = 1; i =< 399; i = i + 5) {
for (int j = 1; j =< 399; j = l + 5) {
color antiquewhite = color(250, 235, 215);
set(i, j, antiquewhite);
}
}
---
When I compile, I get this error message:
unexpected token: <
I don't understand what this is telling me since I'm not literally using a "<" in my code and am formatting a for loop correctly (to my knowledge.) Also, are there more interesting ways to add texture without using an image or something like that?
2.) The main part of my code should be drawing streams of yellow while the mouse is pressed down and leaving only a trail following only where the cursor has been when the mouse is released. As of right now, I have the streams being drawn as well as the pixels following the cursor:
Code:
boolean Dragging;
boolean Pressed;
// setup
void setup(){
size(400, 400);
smooth();
frameRate(60);
background(255);//white background for looking down at snow
}
void draw() {
/**for (int i = 1; i =< 399; i = i + 5) {
for (int j = 1; j =< 399; j = l + 5) {
color antiquewhite = color(250, 235, 215);
set(i, j, antiquewhite);
}
}*/
//draw boy
color blue = color(0, 0, 255);//blue sweater
fill(blue);
noStroke();
rect(100, 360, 200, 60);
ellipse(103, 364, 10, 10);//smoothing shoulders
ellipse(297, 364, 10, 10);//smoothing shoulders
rect(102, 359, 197, 4);//smoothing shoulders
rect(98, 365, 4, 55);//smoothing shoulders
rect(298, 365, 4, 55);//smoothing shoulders
color brown = color(165, 42, 42);//brown hair
fill(brown);
ellipse(200, 400, 120, 120);//top of head
if (Pressed) {
color yellow = color(255, 255, 0);
stroke(yellow);
line(201, 339, mouseX, mouseY);//stream
set(mouseX, mouseY, yellow);//trail
}
if (Dragging) {
color yellow = color(255, 255, 0);
stroke(yellow);
line(201, 339, mouseX, mouseY);
set(mouseX, mouseY, yellow);
}
}
//draw stream
void mousePressed() {
Pressed = true;
if (mouseY < 339) {
color yellow = color(255, 255, 0);
stroke(yellow);
line(201, 339, mouseX, mouseY);
set(mouseX, mouseY, yellow);
}
}
void mouseDragged() {
Dragging = true;
if (mouseY < 339) {
color yellow = color(255, 255, 0);
fill(yellow);
line(201, 339, mouseX, mouseY);
set(mouseX, mouseY, yellow);
}
}
void mouseReleased() {
Dragging = false;
Pressed = false;
}
void keyPressed() {
setup();
}
---
I'm having a really hard time trying to figure out how to use a combonation of loop(), noLoop(), draw(), redraw(), and frameRate() so that only the most recently drawn stream (yellow line) is displayed, but all of the pixels that have been drawn are displayed. What should I use? This is the key to my program.
3.) I don't want a pixel or line to be drawn is the mouse's y position is more than 339, since then it would be drawn on the illustration of the boy or beside or behind him, which isn't realistic. Hence, I have the if statements in mousePressed() and mouseDragged(). This doesn't seem to be effecting anything at all, though. What am I doing wrong?
Thanks so much for any help.