Ejemplo n.º 1
0
        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            {
                if ((e.KeyData == Keys.A) || (e.KeyData == Keys.Left)) //Влево
                {
                    cGame.EDirection enDirection = cGame.EDirection.Left;
                    pGame.Turn(enDirection);
                    n = 4;
                }
                if (e.KeyData == Keys.W) //Вверх
                {
                    cGame.EDirection enDirection = cGame.EDirection.Up;
                    pGame.Turn(enDirection);
                    n = 8;
                }
                if (e.KeyData == Keys.S) // Вниз
                {
                    cGame.EDirection enDirection = cGame.EDirection.Down;
                    pGame.Turn(enDirection);
                    n = 2;
                }

                if (e.KeyData == Keys.D) //Вправо
                {
                    cGame.EDirection enDirection = cGame.EDirection.Right;
                    pGame.Turn(enDirection);
                    n = 6;
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Старт игры
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void pictureBox4_MouseClick(object sender, MouseEventArgs e)
        {
            pictureBox6.Visible = true;
            pictureBox1.Visible = true;
            pictureBox2.Visible = true;
            pictureBox5.Visible = true;
            label5.Visible      = true;
            pictureBox7.Visible = false;

            string[] arFiles = Directory.GetFiles(@"Data\", "*.csv");
            foreach (var sFilename in arFiles)
            {
                pGame.CreateField(sFilename);
            }

            pGame.NewGame();
            cGame.EDirection enDirection = cGame.EDirection.Left;
            pGame.Turn(enDirection);
            n = 4;


            Game_Refresh();
            Snake_Refresh();
            Apple_Refresh();
            Life_Refreh();

            System.Threading.Thread.Sleep(300);
            m_pRefreshTimer.Start();

            pGame.Start();


            pictureBox4.Visible = false;
        }