Question: Instructions Review the requirements given below and Complete your work. Please submit all files through Canvas. The grading scheme is provided on Canvas . .


Instructions Review the requirements given below and Complete your work. Please submit all files through Canvas. The grading scheme is provided on Canvas . . Lab9: Bouncing Balls Game . We will be removing the functionality of drawing Squares, Ellipses, Rectangles and Triangle (just comment those key events out) . The application draws Circles when the C key is pressed For this application, as soon as the ball is drawn it should start moving The Circles should bounce off the perimeter of the frame The Circles of different color should bounce off each other, and when they do they should swap colors The Circle of same Color will merge together by absorbing the smaller circle into the bigger circle. The size and the direction of the larger circle may not change o o o ShapeDriver will now need a Timer, and will also need to implement the ActionListener interface . o Add the following to you ShapeDriver class: import javax.swing.Timer; import java.awt.event.ActionEvent import java.awt.event.ActionListener; public class ShapeDriver implements ActionListener private Timer timer public ShapeDrivero I I/ the second argument to the Timer Constructor takes an ActionListener // the this key word informs the JVM to look inside this class for // the actionPerformed method that must be overridden when Il Every tick of the clock will now run the actionPerformed method timer = new Timer(1000/6o, this); timer.start0 / Method that must be implemented since the class implements ActionListener public void actionPerformed(ActionEvent e) [ Ill move each circle Il check if circle is in bounds, and bounce off the borders if need be Il/ check if circle hits another circle of different color l/ bounce circles off each other and swap colors Instructions Review the requirements given below and Complete your work. Please submit all files through Canvas. The grading scheme is provided on Canvas . . Lab9: Bouncing Balls Game . We will be removing the functionality of drawing Squares, Ellipses, Rectangles and Triangle (just comment those key events out) . The application draws Circles when the C key is pressed For this application, as soon as the ball is drawn it should start moving The Circles should bounce off the perimeter of the frame The Circles of different color should bounce off each other, and when they do they should swap colors The Circle of same Color will merge together by absorbing the smaller circle into the bigger circle. The size and the direction of the larger circle may not change o o o ShapeDriver will now need a Timer, and will also need to implement the ActionListener interface . o Add the following to you ShapeDriver class: import javax.swing.Timer; import java.awt.event.ActionEvent import java.awt.event.ActionListener; public class ShapeDriver implements ActionListener private Timer timer public ShapeDrivero I I/ the second argument to the Timer Constructor takes an ActionListener // the this key word informs the JVM to look inside this class for // the actionPerformed method that must be overridden when Il Every tick of the clock will now run the actionPerformed method timer = new Timer(1000/6o, this); timer.start0 / Method that must be implemented since the class implements ActionListener public void actionPerformed(ActionEvent e) [ Ill move each circle Il check if circle is in bounds, and bounce off the borders if need be Il/ check if circle hits another circle of different color l/ bounce circles off each other and swap colors
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
