Ejemplo n.º 1
0
        private void PictureBoxPaint(object sender, PaintEventArgs e)
        {
            Graphics graphics = e.Graphics;

            _background.Display(graphics);
            _ground.Display(graphics);
            foreach (Pipes pipe in _pipes)
            {
                pipe.Display(graphics);
            }
            foreach (Coin coin in _coins)
            {
                coin.Display(graphics);
            }

            if (!_gameStarted)
            {
                const float LOGO_SCREEN_HEIGHT_PERCENTAGE_FOR_POSITION_Y = 0.03f;
                int         logoPositionY = (int)(_pictureBox.Height * LOGO_SCREEN_HEIGHT_PERCENTAGE_FOR_POSITION_Y);
                DisplayImage(graphics, Properties.Resources.logo, logoPositionY);
                const int GET_READY_POSITION_Y_OFFSET = 30;
                DisplayImage(graphics, Properties.Resources.get_ready,
                             logoPositionY + Properties.Resources.logo.Height + GET_READY_POSITION_Y_OFFSET);

                DisplayInstructions(graphics);
            }
            else
            {
                if (!_gameOver)
                {
                    const float SCREEN_TOP_SCORE_SCREEN_WIDTH_PERCENTAGE_FOR_POSITION_X = 0.04f;
                    const int   GAME_OVER_FONT_SIZE = 20;
                    DrawString(graphics, _score.ToString(), GAME_OVER_FONT_SIZE, Color.White,
                               (int)(_pictureBox.Width * SCREEN_TOP_SCORE_SCREEN_WIDTH_PERCENTAGE_FOR_POSITION_X));
                }
            }

            const int BIRD_ROTATE_ANGLE = 45;

            RotateBirdAtAngle(graphics, BIRD_ROTATE_ANGLE);
            _bird.Display(graphics);
            graphics.ResetTransform();

            if (_gameOver)
            {
                int gameOverImagePosiyionY = (int)(_pictureBox.Height * GAME_OVER_SCREEN_HEIGHT_PERCENTAGE_FOR_POSITION_Y);
                DisplayImage(graphics, Properties.Resources.game_over, gameOverImagePosiyionY);
                DisplayGameOverScore(graphics, gameOverImagePosiyionY);
            }
        }