You will be implementing a video game with predators and prey. If the
predator catches the prey, it eats it. There will eventually be smart
monsters and user controlled prey.
Choose a preditor and prey (sharks and fish, cats and mice, jen and
helpless student, etc)
Write a class for preditor and prey. Include an Image as a member
variable
Find 50 pixel by 50 pixel pictures of your creatures. Be creative
Make x,y coordinates member variables of your classes
Write getter functions for all of your member variables
Write movement functions. There should be an up, down, left, and right
function that properly adjusts the x,y coordinates of your player. If they
get to the edge of the board, either wrap them around to the other side
(like pacman) or have them stop at the wall.
Write an applet in a separate class that has a predator and a prey.
Draw them on the screen in the grid by using the accessor functions
(getX, getY, getPicture)
Create 4 buttons in your applet. Label them "up", "down", "left", and
"right". Create a handler class for each button that has a constructor and
an actionPerformed function. Alternately, create one button handler class that can tell which button was
clicked.
In action performed, you should be able to do
applet.steve.up();
where steve is the object in the applet, and up is a member function of
the Steve class.
Remember that steve won't necessarily move, but you should be able to
execute the function
In the actionPerformed function, after moving the player, call
repaint();