I'm struggling to figure out what would i need to do in order to make my program start with a white background and once mouseClicked once the white background disappears (and my program actually begins).
Basically i want it to be if the spacebar is pressed something happens, if the left arrow key is pressed something happens, if the right arrow key something else happens and if any other key is pressed something else happens. I'm quite a noob so excuse the question. I'm confused because i don't know how to mix if key==CODED (for left and right arrow keys) with all the other keys at once.
This is what i have so far: (for space and else)
void keyPressed() {
if (key == ' ') {
background(255);
}
else {
background(0);
}
}
thats for is space is pressed and any other key. The following is for the left and right arrows:
if (keyPressed) {
if (key == CODED) {
if (keyCode == LEFT) {
if (position>300) {
position=position-5;
}
}
else if (key == CODED) {
if (keyCode == RIGHT) {
if (position<300) {
Position=Position+5;
}
}
}
}
}
i need to somehow combine these two but can't do it :(