Due: Monday 10/20 10:00am
Submission name: w15_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.
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), andd
(right). (when moving the square, its ok if the line shifts position).
Starter Code:
Use the following global variables and setup
for your program:
int squareX;
int squareY;
int circleX;
int circleY;
int lineX;
int lineY;
boolean movement;
void setup() {
size(600, 400);
squareX = width/2;
squareY = height/2;
movement = true;
lineX = squareX;
lineY = squareY;
fill(255, 0, 255);
}//setup