С# Проблема с перемещением новых созданных объектов в таймере. Как обращаться к ним всем сразу?

Я новичок в C#. Мой код создавал объекты по нажатию клавиши клавиатуры, а таймер перемещал их вверх. Но это работает совсем не так, как я хотел. Только одна пуля начинает двигаться, и только когда она попадает за экран формы, другая начинает движение. Ниже мой код, но пикчербокс корабля и таймер я создавал в самой форме.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Ship
{

    public partial class Form1 : Form
    {
//управление кораблем
        System.Drawing.Point b ;
        public Form1()
        {
            KeyDown += new KeyEventHandler(Bullet);
            InitializeComponent();
            KeyDown += new KeyEventHandler(move);
        }
        private void move(object sender, KeyEventArgs e)
        {

            if (e.KeyCode == Keys.Left)
            {
                Point p = new Point(pictureBox1.Location.X - 10, pictureBox1.Location.Y);
                pictureBox1.Location = p;
            }
            if (e.KeyCode == Keys.Right)
            {
                Point p = new Point(pictureBox1.Location.X + 10, pictureBox1.Location.Y);
                pictureBox1.Location = p;
            }
            if (e.KeyCode == Keys.Up)
            {
                Point p = new Point(pictureBox1.Location.X, pictureBox1.Location.Y - 10);
                pictureBox1.Location = p;
            }
            if (e.KeyCode == Keys.Down)
            {
                Point p = new Point(pictureBox1.Location.X, pictureBox1.Location.Y + 10);
                pictureBox1.Location = p;
            }
            if (e.KeyCode == Keys.Left && e.KeyCode == Keys.Up)
            {
                Point p = new Point(pictureBox1.Location.X - 5, pictureBox1.Location.Y - 5);
                pictureBox1.Location = p;
            }
            if (e.KeyCode == Keys.Right && e.KeyCode == Keys.Up)
            {
                Point p = new Point(pictureBox1.Location.X + 5, pictureBox1.Location.Y - 5);
                pictureBox1.Location = p;
            }
            if (e.KeyCode == Keys.Left && e.KeyCode == Keys.Down)
            {
                Point p = new Point(pictureBox1.Location.X - 5, pictureBox1.Location.Y + 5);
                pictureBox1.Location = p;
            }
            if (e.KeyCode == Keys.Right && e.KeyCode == Keys.Down)
            {
                Point p = new Point(pictureBox1.Location.X + 5, pictureBox1.Location.Y - 5);
                pictureBox1.Location = p;
            }
        }
//спавн и управление пулями
            int i = 0;


            private void Bullet(object sender, KeyEventArgs e)
            {
                if (e.KeyCode == Keys.F)
                {
                    PictureBox bullet = new PictureBox
                    {
                        Name = Convert.ToString(i),
                        SizeMode = PictureBoxSizeMode.StretchImage,
                        Location = new Point(pictureBox1.Location.X+46, pictureBox1.Location.Y-5),
                        Visible = true,
                        Image = Image.FromFile(@"Bullet2.png"),
                        ClientSize = new Size(4, 40),
                    };
                    i++;
                    this.Controls.Add(bullet);
                    bullet.Show();
                    bullet.Invalidate();
                    bullet.Paint += new PaintEventHandler(timer1_Tick_1);
                }
            }
        private void timer1_Tick_1(object sender, EventArgs e)
        {
            PictureBox bullet = sender as PictureBox;
            bullet.Location = new Point(bullet.Location.X, bullet.Location.Y - 5);
            bullet.Invalidate();
        }
    }
}

Тут в уже скрины запущенной формы. Если просто нажимать F то пули работают нормально, но если зажать f и отодвинуть корабль происходит какое то дерьмо. Пули создались в одном месте и летят вверх поочередно, пока не закончатся.

enter image description here

enter image description here

По этому же принципу я пытался создать метеориты, так же как пули, только в низ летящие, но из за этой же проблемы метеориты спавняться, но падает всего лишь 1 из них, и когда улетит вниз за форму, начинает падать другой.

Как в таймере1 обращаться сразу ко всем созданным метеоритам и двигать их вниз?

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace BulletTest1
{
    public partial class Form1 : Form
    {
        int i = 0;
        public Form1()
        {
            InitializeComponent();
        }


        private void Form1_Load(object sender, EventArgs e)
        {

        }

        void timer1_Tick(object sender, EventArgs e)
        {
            PictureBox bullet = sender as PictureBox;
            bullet.Location = new Point(bullet.Location.X, bullet.Location.Y + 1);
            bullet.Invalidate();
        }

        private void timer2_Tick(object sender, EventArgs e)
        {
            PictureBox bullet = new PictureBox
            {
                Name = Convert.ToString(i),
                SizeMode = PictureBoxSizeMode.StretchImage,
                Location = new Point(r.Next(1000), 0),
                Visible = true,
                Image = Image.FromFile(@"Bullet2.png"),
                ClientSize = new Size(30, 30),
            };
            i++;
            this.Controls.Add(bullet);
            bullet.Show();
            bullet.Paint += new PaintEventHandler(timer1_Tick);
            bullet.Location = new Point(bullet.Location.X, bullet.Location.Y + 1);
        }
    }
}

Ответы (0 шт):