[SOLVED]How to change the background color | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 9

[SOLVED]How to change the background color

I will like to change the background color whenever the ball hits the edge of the canvas. I tried something but it didn't work. https://code.sololearn.com/W9R6A4FG86aj/?ref=app

21st Dec 2018, 2:18 PM
Ikechukwu Okonkwo
Ikechukwu Okonkwo - avatar
6 Answers
+ 2
https://code.sololearn.com/WhnEjXAWzNx2/?ref=app
21st Dec 2018, 3:34 PM
Taste
Taste - avatar
+ 4
Taste can you edit the code with that and paste it here.. Coder and Oma Falk please check out this question...
21st Dec 2018, 3:31 PM
Ikechukwu Okonkwo
Ikechukwu Okonkwo - avatar
+ 3
Taste thanks a lot...
21st Dec 2018, 4:13 PM
Ikechukwu Okonkwo
Ikechukwu Okonkwo - avatar
+ 2
It change actually, but only in the single frame or less. When the ball reach the edge. Your background(100) at line 11 is the one cause the problem. Because it'll always draw what ever the case. To do this, simply put the background value in a variable. Then draw the background using that variable. You can change this variable to change the background color
21st Dec 2018, 2:39 PM
Taste
Taste - avatar
+ 2
Thats kind of not what i meant. My suggestion is store the value in a variable, just like speed. var bgcolor = 100; Then draw the background using that variable background(bgcolor); To change the color, just change the value of that variable bgcolor = newcolor;
21st Dec 2018, 3:07 PM
Taste
Taste - avatar
0
Really how could you teach me?
2nd Jan 2019, 3:16 AM
Bella Riddle
Bella Riddle - avatar