Exercise 2

(Artist Sketch) In this exercise, I used a grid-based positioning system to move an image based on A W S D key presses, captured by key event functions and key properties. I used a switch statement to make a selector between 3 different images (a turtle, dolphin, or a fish) using key presses. I also added a light purple tint on the images. I incorportated text with a custom font and allowed it to show up on the canvas at the mouse position using the mousePressed() function. I used global variables to keep track of counting states for the background colors and I reset them using if statements. I used toggle logic with key presses to have global variables alternate between true/false or toggle betweeen certain color values. For example, the border can be toggled between sqaures and diamonds, and the red value in the background color can be toggled between 20 and 255. Lastly, I used the && logical operator so that the large moving text only shows when both the mouse and any key are pressed.

I found the grid-based positioning system easy to work with in the code. I was able use control statements to keep the image within the canvas by checking if the next move would make the image go past the edge of the canvas. In the case that it would move off the canvas, I did not allow the key presses to affect the position of the image.

How to use:
'1' - turtle image
'2' - dolphin image
'3' - fish image
'a' - move left
'w' - move up
's' - move down
'd' - move right
'e' - move upper-right diagonal
'q' - move upper-left diagonal
'r' or 'R' - toggle background red value bwteen 20 and 255 & stop counting blue value
RETURN key - toggle border between squares and diamonds
mouse click - show text at mouse position of what the currently selected image is
hold mouse press and any any key at same time - show moving 'HELLO' text