Пример #1
0
        public void newgame()
        {
            player1 = new Ship();
            player1.p = new Point(100, (this.ClientSize.Height - ship.Height) / 2);
            player1.h = 5;
            player1.lastshot = 0;
            player1.ammo = 12;
            keys[0] = keys[1] = false;

            player2 = new Ship();
            player2.p = new Point(this.Width - ship.Width - 100, (this.ClientSize.Height - ship.Height) / 2);
            player2.h = 5;
            player2.lastshot = 0;
            player2.ammo = 12;
            keys[2] = keys[3] = false;

            bullets = new List<Bullet>();
            cows = new List<Cow>();
            msgs = new List<Msg>();
            r = new Random();

            t = 0;
            timer1.Enabled = true;
        }
Пример #2
0
        private void fire(Ship player, float velx)
        {
            if (t - player.lastshot < 4) return;
            if (player.ammo == 0) return;

            Bullet b = new Bullet();
            b.p = player.p;
            b.p.X += ship.Width * Math.Sign(velx);
            b.p.Y += ship.Height / 2;
            b.v = new PointF(velx, 0);
            b.h = 1;
            b.s = player;
            bullets.Add(b);

            player.lastshot = t;
            player.ammo--;
        }