I'm new to programming and am trying to figure out how make a fishing game, so far i have fish that swim back and forth and a hook with keyboard controls to make left and right, and drop down.I'm trying to make it so that when the hook touches a fish, the fish turns upward and follows the location of the hook.
I'm trying to do this in the fish's code.
public class yellowFish extends animal
{
/**
* Act - do whatever the redlobster wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
//private int hookY = hook.class.getY();
//private int hookX = hook.class.getX();
public void act()
{
turnAtEdge();
move(4);
checkCollision();
}
public void turnAtEdge()
{
if ( atWorldEdge() )
{
turn(180);
}
}
private void checkCollision()
{
Actor actor = getOneIntersectingObject(null);
if(actor instanceof hook) {
setRotation(270);
getX();
getY();
//setLocation(hookX, hookY);
}
}
}
