Question
need help java Square Rebound For this lab, you'll build on the Dots.java and DotsPanel.java programs. Instead of drawing dots you will draw squares so
need help java
Square Rebound
For this lab, you'll build on the Dots.java and DotsPanel.java programs.
Instead of drawing dots you will draw squares so add that change.
Add animation using a Timer so that the squares all move when drawn. Make each square move at random speed (in x and y directions), and have the squares "bounce" appropriately off all four sides of the screen.
HINTS:
Create 2 arrays of size 1000 to hold random values between 1 and 10 for the X movements and Y movements. This will allow your rectangles to have independent movement speeds.
You will need to create a ActionListener class similar to what is used in ReboundPanel class.
Inside the Actionistener class you create you will want to reference the X and Y array indexes rather than the static moveX and moveY used in the ReboundPanel.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started