I don't know what I'm doing wrong, anyone wanna help a me out?
in
Programming Questions
•
10 months ago
So I'm new to processing. I've only started programing and stuff like a month ago. I'm kinnda stuck. I'm trying to make this sort of drawing thing. You use the arrow keys to change the color but it isn't working out how I thought it would. Can anyone tell me what I'm doing wrong?
color strokeVal = color(255,0,0);
void setup () {
size(600,500);
background(0);
}
void setup () {
size(600,500);
background(0);
}
void draw () {
text("Up arrow for red, the down arrow for blue, the right for yellow and left for green.", 230, 300);
stroke(strokeVal);
if (mousePressed) {
line(mouseX,mouseY,pmouseX,pmouseY);
}
}
text("Up arrow for red, the down arrow for blue, the right for yellow and left for green.", 230, 300);
stroke(strokeVal);
if (mousePressed) {
line(mouseX,mouseY,pmouseX,pmouseY);
}
}
void keyPressed () {
if (key == CODED) {
if (keyCode == UP) {
strokeVal = (255,0,0);
}else if (keyCode == DOWN) {
strokeVal = (0,0,255);
}else if (keyCode == RIGHT) {
strokeVal = (255,255,0);
}else if (keyCode == LEFT) {
strokeVal = (0,255,0);
} else {
strokeVal = (0,0,0);
}
}
if (key == CODED) {
if (keyCode == UP) {
strokeVal = (255,0,0);
}else if (keyCode == DOWN) {
strokeVal = (0,0,255);
}else if (keyCode == RIGHT) {
strokeVal = (255,255,0);
}else if (keyCode == LEFT) {
strokeVal = (0,255,0);
} else {
strokeVal = (0,0,0);
}
}
1