This code is in the player class called "SnowMan"
This code is in the TowerShot class
I want to make it so that the TowerShot will fire in the direction the player is facing and not in the same direction (up) all the time!
Any help or advice would be greatly appreciated!
public void timer()
{
if (shotTimer > 0)
{
shotTimer--;
}
else if (Greenfoot.isKeyDown("enter"))
{
getWorld().addObject(new TowerShot(this),getX(),getY());
{
shotTimer = 200;
}
}
}public class TowerShot extends Actor
{
/**
* Act - do whatever the TowerShot wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
int ypos = getY();
ypos = ypos -5;
setLocation(getX(),ypos);
if (isAtEdge())
{
getWorld().removeObject(this);
}
}
private SnowMan myTurret;
public TowerShot(SnowMan myTurret)
{
this.myTurret = myTurret;
}
}
