Ejemplo n.º 1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            ship       = new MyShip();
            ship.pos.X = 100;
            ship.pos.Y = 300;

            MyEnemy enemy = new MyEnemy();

            enemy.pos.X = 200;
            enemy.pos.Y = 10;
            enemyList.AddLast(enemy);

            timer1.Start();
        }
Ejemplo n.º 2
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            ship.Move();

            foreach (MyBullet b in bulletList)
            {
                b.Move();
            }

            foreach (MyEnemy enemy in enemyList)
            {
                enemy.Move();
            }

            MyBullet hitBullet  = null;
            bool     hitBullett = false;

            foreach (MyBullet b in bulletList)
            {
                bool    hit    = false;
                MyEnemy hitted = null;

                foreach (MyEnemy enemy in enemyList)
                {
                    if (b.CheckInter(enemy))
                    {
                        hit    = true;
                        hitted = enemy;
                        break;
                    }
                }

                if (hit)
                {
                    hitBullett = true;
                    enemyList.Remove(hitted);
                    hitBullet = b;
                }
            }
            if (hitBullett)
            {
                bulletList.Remove(hitBullet);
            }

            Invalidate();
        }