+ 1

OOP with JS ,, Could you help me with OOJS ? Object-oriented javaScript

Hi This is my code canvas test link https://code.sololearn.com/WCfHDima8J3q/?ref=app I want to clear or make the path of the ball disappear, and let ball still moving without his line Thanks...

19th May 2020, 8:45 PM
Raven
Raven - avatar
4 ответов
+ 2
Nice! All you need is a `ctx.clearRect(0, 0, w, h)` over the whole screen before you draw the ball. Either in your draw function but inside the start function is probably a better place.
19th May 2020, 8:55 PM
Schindlabua
Schindlabua - avatar
+ 2
Thank you Schindlabua this is what i want... 👍👍 Did you think my code is ( good practice ) ? This will help me, because i can rewrite the same canvas in different way.
19th May 2020, 9:05 PM
Raven
Raven - avatar
+ 2
Yep looks pretty good! I would make it so the draw function takes the ctx as an argument so the Ball doesn't have to rely on global variables. But that's a really minor thing.
19th May 2020, 9:18 PM
Schindlabua
Schindlabua - avatar
+ 1
Thanks my dear 👍.Schindlabua
19th May 2020, 9:24 PM
Raven
Raven - avatar