Ejemplo n.º 1
0
        private void Retry()
        {
            p1_HP = 100;
            p2_HP = 100;

            pb_p1HP.Value = p1_HP;
            pb_p2HP.Value = p2_HP;

            p1_MovingL      = false; p1_MovingR = false;
            p2_MovingL      = false; p2_MovingR = false;
            p1_ActiveBullet = false; p2_ActiveBullet = false;
            p1_DIR          = SHOOTDIR.RIGHT; p2_DIR = SHOOTDIR.LEFT;

            p1.Location        = new Point(11, 705);
            p2.Location        = new Point(962, 706);
            p1_Bullet.Location = new Point(-50, -50);
            p2_Bullet.Location = new Point(pnl_Screen.Width + 50, pnl_Screen.Width - 50);

            tick_game.Enabled = true;
        }
Ejemplo n.º 2
0
        private void frm_main_Load(object sender, EventArgs e)
        {
            DoubleBuffered = true;

            tick_game.Enabled  = true;
            tick_game.Interval = 1;

            p1_Bullet.Location = new Point(-50, -50);
            p2_Bullet.Location = new Point(pnl_Screen.Width + 50, pnl_Screen.Width - 50);

            p1_DIR = SHOOTDIR.RIGHT; p2_DIR = SHOOTDIR.LEFT;

            foreach (Control item in pnl_Screen.Controls)
            {
                if (item.Tag == "obj")
                {
                    AllObj.Add((PictureBox)item);
                }
            }
        }
Ejemplo n.º 3
0
        private void frm_main_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Escape)
            {
                frm_mainmenu frm_mainmenu = new frm_mainmenu();
                frm_mainmenu.Show();
                Close();
            }

            if (e.KeyCode == Keys.A)
            {
                p1_MovingL = true;

                if (p1_ActiveBullet == false)
                {
                    p1_DIR = SHOOTDIR.LEFT;
                }
            }
            else if (e.KeyCode == Keys.D)
            {
                p1_MovingR = true;

                if (p1_ActiveBullet == false)
                {
                    p1_DIR = SHOOTDIR.RIGHT;
                }
            }
            else if (e.KeyCode == Keys.W)
            {
                p1_Jump    = true;
                p1_Collide = false;
            }
            else if (e.KeyCode == Keys.G && p1_ActiveBullet == false)
            {
                if (p1_DIR == SHOOTDIR.LEFT)
                {
                    p1_Bullet.Location = new Point(p1.Location.X - p1_Bullet.Width, p1.Location.Y + (p1.Height / 2));
                }
                else if (p1_DIR == SHOOTDIR.RIGHT)
                {
                    p1_Bullet.Location = new Point(p1.Location.X + p1.Width, p1.Location.Y + (p1.Height / 2));
                }

                p1_ActiveBullet = true;
            }

            if (e.KeyCode == Keys.Left)
            {
                p2_MovingL = true;

                if (p2_ActiveBullet == false)
                {
                    p2_DIR = SHOOTDIR.LEFT;
                }
            }
            else if (e.KeyCode == Keys.Right)
            {
                p2_MovingR = true;

                if (p2_ActiveBullet == false)
                {
                    p2_DIR = SHOOTDIR.RIGHT;
                }
            }
            else if (e.KeyCode == Keys.Up)
            {
                p2_Jump    = true;
                p2_Collide = false;
            }
            else if (e.KeyCode == Keys.P && p2_ActiveBullet == false)
            {
                if (p2_DIR == SHOOTDIR.LEFT)
                {
                    p2_Bullet.Location = new Point(p2.Location.X - p2_Bullet.Width, p2.Location.Y + (p2.Height / 2));
                }
                else if (p2_DIR == SHOOTDIR.RIGHT)
                {
                    p2_Bullet.Location = new Point(p2.Location.X + p2.Width, p2.Location.Y + (p2.Height / 2));
                }

                p2_ActiveBullet = true;
            }
        }