AI Sprite Change

Screenshot

It’s just a simulation for a school project where there are 2 teams. Basicly what happens is that an “Actor” finds the closest “Actor” to him and starts going to that location or runs away, depending on what race they are. Thing is, I’m not really sure how to change the sprite image based on there direction. Any ideas?

P.S, There will be an up, down, left, and right image

public void move (Actor aTargetActor)
{
	double xDirection, yDirection, radian;
	double dX, dY = 0;
	
	if(!actorCollision(this, aTargetActor)){
 	xDirection = aTargetActor.p2dLocation.getX() - this.p2dLocation.getX();
 	yDirection = aTargetActor.p2dLocation.getY() - this.p2dLocation.getY();	 	
 	
 	radian = Math.atan2(yDirection, xDirection);
 	    	
	dY = (this.p2dLocation.getY()-(Math.sin(radian)/100)*this.getSpeed());
 	dX = (this.p2dLocation.getX()-(Math.cos(radian)/100)*this.getSpeed());

	this.p2dLocation.setLocation(dX, dY);
    }
}


public boolean actorCollision(Actor a, Actor b)
{
double xD, yD;

xD = Math.abs(a.getLocation().getX() - b.getLocation().getX());
yD = Math.abs(a.getLocation().getY() - b.getLocation().getY());

if (xD > 20.0)
{
   if (yD > 20.0)
	return true;
}
return false;
}

}

Create a static final int for each direction with values from 0-3.
Create an array of images that match up with the direction variables.
Add a direction variable to the actor class.
Set the direction variable based on the dx and dy in the actors move method.
Draw the image from the image array using the direction variable as the index.