Beginner question, changing background in pong when ball hits paddle

Hello to all
I have an assignment for art school. we have been given the pong game and we must change the code to create a story… I wish to change the background each time the pong hits a paddle.
any help would be gratefully received

instead of saying background(0);

use a variable that you define before setup()

color colBackground = color(255,0,0);

and say background(colBackground);

NOW

NOW when you have a hit change colBackground with

colBackground = color(random(256),random(20,256),random(256));

Hey and welcome to the forum!

Great to have you here!

1 Like

a program that flashes when key is pressed;

int v = 0, s = -10;
void draw() {
  background(v);
  v = constrain(v+s,0,255);
}
void keyPressed() { v = 255; }
1 Like