I am coding for an assignment and I am having a hard time. I want to make a shape, then particles, change between red. yellow and blue by hitting keys. I can’t tell what I’m doing wrong. Please help!
float offset =180;
boolean isKeyPressedLeft = false;
boolean isKeyPressedDown= false;
boolean isKeyPressedRight= false;
float centerX;
float centerY;
void setup()
{
size(200, 200);
centerX= width / 2.0f;
centerY = height /2.0f;
}
void draw ()
{
background (63);
circle (100, 100, 100);
noStroke();
if (isKeyPressedLeft)
fill ( 228, 46,46);
if (isKeyPressedDown)
fill ( 237, 201,41);
if (isKeyPressedRight)
fill( 56, 76, 228);
}
void keyPressed()
{
updateKeyboard(true);
}
void keyReleased()
{
updateKeyboard(false);
}
void updateKeyboard(boolean state)
{
if (keyCode ==LEFT)
isKeyPressedLeft = state;
if (keyCode ==DOWN)
isKeyPressedLeft = state;
if(keyCode == RIGHT)
isKeyPressedLeft = state;
}