How can I make my code briefer?
Hi
-
void setup()
{
size(400,400);
background(255);
}
void draw()
{
if(((keyPressed == true)&(key =='a')))
drawplease(50); -
if(((keyPressed == true)&&(key =='s')))
drawplease(74); -
if(((keyPressed == true)&&(key =='d')))
drawplease(98);
} -
void drawplease(int x)
{
noStroke();
fill(0);
rect(x,278,24,31);
}
void keyReleased()
{
noStroke();
fill(255,255,255);
rect(50,278,24,31);
rect(74,278,24,31);
rect(98,278,24,31);
}
What can I do in “void keyReleased()” which instead of writing all these lines of code:
rect(50,278,24,31);
rect(74,278,24,31);
rect(98,278,24,31);
Just write a brief code. Like using for loop or while or I don’t know function maybe!
thanks