Why ball going out of canvas? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why ball going out of canvas?

See the update function in the javascript code. https://code.sololearn.com/WpCy1MtOEX8s/?ref=app

12th Jul 2020, 10:49 AM
Souptik Nath
Souptik Nath - avatar
7 Answers
0
check the ball position against the boundary (x being 0, y being 0)
12th Jul 2020, 10:51 AM
Gordon
Gordon - avatar
0
Gordon See the update function I have made an if statement there.
12th Jul 2020, 10:52 AM
Souptik Nath
Souptik Nath - avatar
0
check the y also.
12th Jul 2020, 10:53 AM
Gordon
Gordon - avatar
0
Gordon Same problem exists.
12th Jul 2020, 10:57 AM
Souptik Nath
Souptik Nath - avatar
0
Gordon After debugging many times also I couldn't understand why this happens.
12th Jul 2020, 10:58 AM
Souptik Nath
Souptik Nath - avatar
0
Bagon Then also there is a bug. If you lower the canvas height then ball bounces before touching the wall
12th Jul 2020, 12:56 PM
Souptik Nath
Souptik Nath - avatar
0
Bagon Now visit I have reduced the canvas size to 250
12th Jul 2020, 12:57 PM
Souptik Nath
Souptik Nath - avatar