This assignment builds on a previous one. You should have two small (no more than 32x32) graphics on screen, one controlled by the arrow keys, the other controlled by w/a/s/d.

In this assignment, your program should notice whatever collectible item is closest to each player. The game should automatically shoot at the collectible item from each player, with a fire rate of once every 2 seconds. You can draw a line to represent a laser, like in this example. When the collectible is shot, it should count the same as when the player's sprite collides with it, i.e. the player should get +10 points.

Range Detection
To make this work, you will need a variation on a collision function. Check the positions of each collectible, and calculate the distance from the center of each player and the center of the collectible. To find the square-root of 16, use "Math.sqrt(16)".

Movement
If you have not already done so, you might want to consider the movements as a separate event from the key presses. That is, have the key presses set values indicating the desired movement. Another function can then implement the movement, first checking to make sure it can work. Having the movement in a different function means that you can check for things like collisions first, and reverse the direction if one is detected. Of course, the character might not be able to move. That is, if the character is in the upper-left corner, it should not move either left or up from this position.