Question: I REALLY need help with the following assignment: In the assignment you will gain experience with the following: Swing, Event handling in Swing, Swing Timers
I REALLY need help with the following assignment:
In the assignment you will gain experience with the following:
Swing, Event handling in Swing, Swing Timers
The assignment is to utilize the above mentioned packages to track the mouse position. There should be a turtle created in a new world/window. This is created by using the import edu.support.EndWorld; This creates a new world: EndWorld w= new EndWorld(); To create a turtle use: import edu.gatech.mediacomp.Turtle; This places a turtle in that world/window: Turtle t = new Turtle(w);
The assignment is to move the turtle around with the mouse. When the mouse enters the new world/window, the turtle should turn towards the mouse and start moving forward until it reaches the mouse's position. If the mouse moves, the turtle should adjust and continue moving towards the new position. If the mouse exits the world, the turtle should stop moving. We must use a timer to control the speed of the turtle!
Be sure to add the mouse listeners to the EndWorld directly NOT the frame!
There are 2 different interfaces you will need for handling mouse events.
As noted above you need to have the turtle start/stop moving based on:
1) Whether it is already at the position of the mouse.
2) If the mouse pointer is in the drawing area. This latter one can be handled by using the Point object that the TurtleMouseFollower has.
cop2513 turtlemousefollow: ain +main (String args): void edu support EndWorld edu.gatech.media comp: Turtle javax.swing: Timer java.awt: Point cop2513.turtlemousefollow::TurtleMouseFollower C-FORWARD PIXELS: int +TurtleMouseFollower(): ctorStep by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
