i'm trying to create a shooter game, that involves a tank that shoots bullets. I have the code the get the bullet actor to spawn and move. Right now I have the bullet actor set to move in a certain direction based on the key pressed. The issue that I'm having is that when the tank changes direction so do the bullets. What code would help me achieve the goal of the keeping the bullet moving in one direction despite a direction change of the tank?
Any suggestions
~Thanks.
bullet actor
Tank Actor
int bSpeed = 10;
move(bSpeed);
if (Greenfoot.isKeyDown("up"))
{
setRotation(270);
}
if (Greenfoot.isKeyDown("down"))
{
setRotation(90);
}
if (Greenfoot.isKeyDown("right"))
{
setRotation(0);
}
if (Greenfoot.isKeyDown("left"))
{
setRotation(180);
}
if (isAtEdge())
{
getWorld().removeObject(this);
}if(Greenfoot.isKeyDown("Space"))
{
World w = getWorld();
int x = (int)(this.getX());
int y = (int)(this.getY());
w.addObject(new Bullet(),x,y);
}
