예제 #1
0
        private Image RotateImage(eSnakePostion newPosstion, Image img)
        {
            Image flipImage = img;

            switch (newPosstion)
            {
            case eSnakePostion.Left:
                flipImage.RotateFlip(RotateFlipType.Rotate180FlipY);

                break;

            case eSnakePostion.Right:
                break;

            case eSnakePostion.Up:
                flipImage.RotateFlip(RotateFlipType.Rotate90FlipXY);

                break;

            case eSnakePostion.Down:
                flipImage.RotateFlip(RotateFlipType.Rotate270FlipY);

                break;
            }
            return(flipImage);
        }
예제 #2
0
        private void MoveHandler(object sender, KeyPressEventArgs e)
        {
            if (!m_IsPlayGame)
            {
                return;
            }

            if ((e.KeyChar == 'D' || e.KeyChar == 'd') && (m_CurrentPosttion != eSnakePostion.Left))
            {
                MoveRight(m_IsPlayGame);
                m_CurrentPosttion = eSnakePostion.Right;
            }
            if ((e.KeyChar == 'A' || e.KeyChar == 'a') && (m_CurrentPosttion != eSnakePostion.Right))
            {
                MoveLeft(m_IsPlayGame);
                m_CurrentPosttion = eSnakePostion.Left;
            }
            if ((e.KeyChar == 'W' || e.KeyChar == 'w') && (m_CurrentPosttion != eSnakePostion.Down))
            {
                MoveUp(m_IsPlayGame);
                m_CurrentPosttion = eSnakePostion.Up;
            }
            if ((e.KeyChar == 'X' || e.KeyChar == 'x') && (m_CurrentPosttion != eSnakePostion.Up))
            {
                MoveDown(m_IsPlayGame);
                m_CurrentPosttion = eSnakePostion.Down;
            }

            // ======= START GAME ========
            if (m_StartTime == default) // defualt == Date time null
            {
                m_StartTime = DateTime.Now;
                m_KeepMoveTimer.Start();
                m_SetAppleOnBoardTimer.Start();
            }
        }