I want to create a pattern where i have 4 different squares in different colours that directly change color as a code. This is what i have, but i dont know how to change the color of the sqaures and then turn them back to normal in one time. Please help

please format code with </> button * homework policy * asking questions

int lastTimeCheck;
int timeIntervalFlag = 3000; // 3 seconds because we are working with millis

void setup() {
size(500,500);
background(0);
fill(255,0,0);
square(0,0,250);
fill(0,255,0);
square(250,0,250);
fill(0,0,255);
square(0,250,250);
fill(255,255,0);
square(250,250,250);
lastTimeCheck = millis();
}

void draw() {
if ( millis() > lastTimeCheck + timeIntervalFlag ) {
lastTimeCheck = millis();
println( “something awesome happens here” );
}
}

Hello @LeRonald,

Your code and timer work but need some tweaks!

setup() only runs once:
https://processing.org/reference/setup_.html

You can lookup the reference for draw()

Consider:

  • moving your pattern of squares to draw()
  • use color variables to assign color to each square
  • change the color variable along with your timer

There are lots of resources here to help you on your journey:
https://processing.org/

Nice pattern of squares!

Reference:
https://processing.org/reference/square_.html

:)