Hi I have the following class which Updates and Draws a projectile:
public class TierOneProjectile : IProjectile
{
private AnimatedTexture animation;
private Vector2 screenPosition, framesPerSecond, origin;
private float rotation, scale, depth;
private int velocity;
public TierOneProjectile(Vector2 _screenPosition,int _velocity,AnimatedTexture _animation)
{
screenPosition = _screenPosition;
animation = _animation;
velocity = _velocity;
}
public void Update(float elapsedGameTime)
{
animation.UpdateFrame(elapsedGameTime);
screenPosition.X -= velocity;
}
public void Draw(SpriteBatch spriteBatch)
{
animation.DrawFrame(spriteBatch,screenPosition);
}
public Rectangle getBoundingBox()
{
return new Rectangle((int)screenPosition.X, (int)screenPosition.Y, (int)animation.GetTextureWH().X, (int)animation.GetTextureWH().Y);
}
}
Currently the projectile alway flies to the left. Little did I know when I created this class. Now I want to pass a direction to the constructor so every projectile could fly into a different direction. What would be the smartest solution for this? I do not want you to write the code for me. But maybe you could give me a hint how this could be done.