Posted: Thu Oct 15

Due: Friday 10/16 10:00am

Submission name: w11_events

Events

This program should have a square and a circle, which will respond to events as follows:

Mouse:

  • The circle’s location should be centered at the mouse’s coordinates.
  • When the mouse button is pressed, draw a line from the square’s upper-left corner to the circle’s center. The line should remain on the screen even after the mouse has been released.
  • When the mouse is dragged, the endpoint of the line should continuously change to stay inside the circle.

Keyboard:

  • Pressing the spacebar (' ') should enable or disable all movement (mouse or keyboard based).
  • Pressing q should move the square so that it’s upper left corder is at the center of the screen.
  • You should be able to move the square using the arrow keys or w (up), a (left), s (down), and d (right). (when moving the square, its ok if the line shifts position).

Runnable example: