Write a program to animate two circles bouncing around


Write a program to animate two circles bouncing around a window. The basic idea is to start the two circles somewhere in the interior of the window. Use the variables dx1 and dy1 (for the first circle) and dx2 and dy2 (for the second circle) to control the movements of the circles (the dx/dy variables should be initialized to 1). Use a large counted loop (say 10000 iterations), and each time through the loop move the circles using dx1, dx2, dy1, and dy2. When the x-value of the center of the first circle gets too high (it hits an edge), change dx1 to -1. When it gets too low, change it to 1. Use a similar approach for dy1 and also for the second circle. If the two circles get too close to each other (i.e. they "collide"), each circle should change directions and continue moving.

Request for Solution File

Ask an Expert for Answer!!
Programming Languages: Write a program to animate two circles bouncing around
Reference No:- TGS0128658

Expected delivery within 24 Hours