示例#1
0
        private void NewGame_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Escape)
            {
                simpleSound.Stop();
                this.Close();
            }


            if (Keys.Left == e.KeyCode)
            {
                HeroPlane.ChangeDirection(MainHeroPlane.DIRECTION.left);
            }

            if (Keys.Right == e.KeyCode)
            {
                HeroPlane.ChangeDirection(MainHeroPlane.DIRECTION.right);
            }

            if (Keys.Up == e.KeyCode)
            {
                HeroPlane.ChangeDirection(MainHeroPlane.DIRECTION.up);
            }

            if (Keys.Down == e.KeyCode)
            {
                HeroPlane.ChangeDirection(MainHeroPlane.DIRECTION.down);
            }

            HeroPlane.Move(this.ClientSize.Width, this.ClientSize.Height);

            if (e.KeyCode == Keys.P)
            {
                if (isStarted)
                {
                    isStarted = false;
                }
                else
                {
                    isStarted = true;
                }

                if (isStarted)
                {
                    timer1.Stop();
                }
                else
                {
                    timer1.Start();
                }
            }
        }
示例#2
0
        private void NewGame_Paint(object sender, PaintEventArgs e)
        {
            HeroPlane.Draw(e.Graphics);

            foreach (Enemies en in enemies)
            {
                en.Draw(e.Graphics);
            }

            foreach (Clouds c in clouds)
            {
                c.Draw(e.Graphics);
            }
        }