コード例 #1
0
        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            try
            {
                if (e.KeyCode.ToString() == "Up")
                {
                    hero.Move(Width, Height, 0);
                }
                if (e.KeyCode.ToString() == "Right")
                {
                    hero.Move(Width, Height, 1);
                }
                if (e.KeyCode.ToString() == "Down")
                {
                    hero.Move(Width, Height, 2);
                }
                if (e.KeyCode.ToString() == "Left")
                {
                    hero.Move(Width, Height, 3);
                }
                if (e.KeyCode.ToString() == "Space")
                {
                    if (level1doc != null)
                    {
                        level1doc.Move(4);
                    }
                    else if (level2doc != null)
                    {
                        level2doc.Shoots = true;
                    }
                }
                if (level1doc != null)
                {
                    level1doc.Move(1);
                }
                if (level2doc != null)
                {
                    level2doc.Move();
                }
            }
            catch (Exception ec)
            { }

            Invalidate(true);
        }
コード例 #2
0
        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode.ToString() == "Up")
            {
                kiro.Move(width, height, 0);
            }
            if (e.KeyCode.ToString() == "Right")
            {
                kiro.Move(width, height, 1);
            }
            if (e.KeyCode.ToString() == "Down")
            {
                kiro.Move(width, height, 2);
            }
            if (e.KeyCode.ToString() == "Left")
            {
                kiro.Move(width, height, 3);
            }
            if (e.KeyCode.ToString() == "Space")
            {
                Shoots = true;
            }

            foreach (AmmoGift g in gifts)
            {
                if (g.isHit(kiro.Position))
                {
                    kiro.Ammo += 5;
                }
            }

            for (int i = gifts.Count - 1; i >= 0; i--)
            {
                if (!gifts[i].Alive)
                {
                    gifts.RemoveAt(i);
                }
            }
            Invalidate(true);
        }