Траектория движения пули c# winforms
Необходимо реализовать движение пули во всех направлениях: вверх, вниз, врпаво, влево. Вправо и влево все работает, а вот при выстреливании вверх и вниз пуля остается на месте. Никак не могу разобраться, в чем ошибка. Код прилагаю ниже.
class Bullet
{
public string direction;
public int bulletLeft;
public int bulletTop;
private int speed = 20;
private PictureBox bullet = new PictureBox();
public Timer bulletTimer = new Timer();
public void MakeBullet(Form form)
{
bullet.BackColor = Color.White;
bullet.Size = new Size(5, 5);
bullet.Tag = "bullet";
bullet.Left = bulletLeft;
bullet.Top = bulletTop;
bullet.BringToFront();
form.Controls.Add(bullet);
bulletTimer.Interval = speed;
bulletTimer.Tick += new EventHandler(BulletTimerEvent);
bulletTimer.Start();
}
private void BulletTimerEvent(object sender, EventArgs e)
{
//bullet movement
if (direction == "left")
{
bullet.Left -= speed;
}
if (direction == "right")
{
bullet.Left += speed;
}
if (direction == "top")
{
bullet.Top -= speed;
}
if (direction == "down")
{
bullet.Top += speed;
}
//dispose bullet
if (bullet.Left < 10 || bullet.Left > 860 || bullet.Top < 10 || bullet.Top > 900)
{
bulletTimer.Stop();
bulletTimer.Dispose();
bullet.Dispose();
bulletTimer = null;
bullet = null;
}
}
}