Random color in Lesson 22 Game

I have a student who is creating a pong type game. He wants it to set the background to a random color every time the puck/ball leaves the screen and resets.

I have attached a link to the code. Any help or suggestions is greatly appreciated!

Hi @sarah.dudley,

The link is sending me to the generic Code.org page so I can’t see his project directly. From what you’ve described, it sounds like something he could solve by setting the background to RGB(red_var, green_var, blue_var) where red_var, green_var, and blue_var reset to a random number between 0 and 255 every time it resets.

If you relink this to the student’s project, one of us can take a look & provide recommendations.

Thanks!
–Michael K.

Sorry about that!

Here’s a link to one possible solution as @mkmietowicz suggested. I didn’t fix the code beyond that, though. It looks like he still needs to implement the code for what happens if the ball leaves the right side of the screen. He already coded it so it resets if it leaves the top or the left side.

:slight_smile:

Mike