Esempio n. 1
0
        private void button1_KeyPress(object sender, KeyPressEventArgs e)
        {
            is_win = 1;
            Graphics g = this.CreateGraphics();

            switch (e.KeyChar)
            {
            case 'w':
            case 'W':
                flag = m.Can_W();
                if (flag != 0)
                {
                    g.FillRectangle(new SolidBrush(Color.White), m.y * 30, (m.x - 2) * 30, 30, 90);
                    m.W_Move(flag);
                    Paints_W();
                }
                break;

            case 's':
            case 'S':
                flag = m.Can_S();
                if (flag != 0)
                {
                    g.FillRectangle(new SolidBrush(Color.White), m.y * 30, m.x * 30, 30, 90);
                    m.S_Move(flag);
                    Paints_S();
                }
                break;

            case 'a':
            case 'A':
                flag = m.Can_A();
                if (flag != 0)
                {
                    g.FillRectangle(new SolidBrush(Color.White), (m.y - 2) * 30, m.x * 30, 90, 30);
                    m.A_Move(flag);
                    Paints_A();
                }
                break;

            case 'd':
            case 'D':
                flag = m.Can_D();
                if (flag != 0)
                {
                    g.FillRectangle(new SolidBrush(Color.White), m.y * 30, m.x * 30, 90, 30);
                    m.D_Move(flag);
                    Paints_D();
                }
                break;
            }
            for (int i = 0; i < m.li.Count; i++)
            {
                if (m.map[m.li[i].X, m.li[i].Y] != 5)
                {
                    is_win = 0;
                }
            }
            if (is_win == 1)
            {
                MessageBox.Show("You Win!!!", "congratulate");
            }
        }