To write codes by using javaScript for a bouncing ball in a rectangle ,The ball should bounce up and down,left to right. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

To write codes by using javaScript for a bouncing ball in a rectangle ,The ball should bounce up and down,left to right.

Answers

10th Jul 2020, 9:35 AM
Nuru
Nuru - avatar
3 Answers
+ 1
https://code.sololearn.com/WMUnE2bDEN6n/?ref=app Is this what you mean? If yes then here is the main idea: Lets talk about the coordinates (x = Horizontal, y = Vertical) The main idea of the program is, when the coordinate reach the end of your screen (For example your Horizontal phone size is 100), so when the X coordinate reach 100 (from 0), the ball should be bounced back so that coordinate will be decreased until it reach 0 again. The same with the Y coordinate.
10th Jul 2020, 10:28 AM
Jingga Sona
Jingga Sona - avatar
0
Thanks
10th Jul 2020, 12:50 PM
Nuru
Nuru - avatar