Example #1
0
        /*-------------------------------------------------------------------------*/
        #region Constructor + Load methods

        private HUD()
        {
            //Set window properties
            windowWidth = Game1.SCREEN_WIDTH;
            windowHeight = Game1.SCREEN_HEIGHT;

            hudComponents = new List<SpriteComponent>();
            hudDrawComponents = new List<DrawComponent>();
            //Components
            bannerComponent = new SpriteComponent(new Vector2(windowWidth / 2, windowHeight - 20), new Vector2(800, 45));
            healthBarComponent = new SpriteComponent(new Vector2(bannerComponent.getPosition().X-280, bannerComponent.getPosition().Y), new Vector2(580, 12));
            healthBarComponent.setOriginLeft();
            healthBarContainerComponent = new SpriteComponent(new Vector2(bannerComponent.getPosition().X + -284, bannerComponent.getPosition().Y + 10), new Vector2(590, 19));
            healthBarContainerComponent.setOriginBottomLeft();
            //superFlashIconComponent = new SpriteComponent(new Vector2((bannerComponent.getPosition().X - bannerComponent.getSize().X/2) - 25, bannerComponent.getPosition().Y-2), new Vector2(45.0f, 45.0f));
            powerUpIcon = new PowerUpIcon(new Vector2(100, 50), 0f, false);
            superFlashIcon = new DrawOscillate(SpriteDatabase.GetAnimation("superFlashIcon"), new Vector2(100,150), 0f,true);
            hudDrawComponents.Add(superFlashIcon);
            
            
            
            //Score Positions
            positionScore = new Vector2(bannerComponent.getPosition().X - (bannerComponent.getSize().X / 2) + 10, bannerComponent.getPosition().Y + 4);

            
            
            
            //Initialize current score
            //currentScore = 0;
            scoreScale = 1;
            maxScoreScale = 4.0f;
            scoreIncrement = 10;

            //Set up Timers
            timer = 0;
            timerInterval = 500;

            //Set up current health
            health = 100;
            //healthActual = (int)health;

            //Animate timer 
            timeSoFar = 0;
            TimeToAnimate = 0.4f;
            animationSpeed = 0.005f;

            //Game over initializations 
            isGameOver = false; 
            gameOverTextPosition = new Vector2(windowWidth / 2, windowHeight / 2);
            gameOverTextScale = 5.0f;
            gameOverTextSize = new Rectangle(0, 0, 556, 126);
            gameOverCurrentTime = 0.0f; 

            //Fade To Black initialization 
            fadeToBlackAlpha = 0.0f;
            fadeToBlackDesiredAlpha = 0.8f;
            fadeToBlackPosition = new Vector2(0.0f, 0.0f);
            fadeToBlackCurrentTime = 0.0f;

            playGameOverMusic = true;

            particleBar = new ParticleSpewer(
                healthBarComponent.getPosition().X + health / 100f * healthBarComponent.getSize().X - 1, healthBarComponent.getPosition().Y,
                50, 20, MathHelper.ToRadians(-90), MathHelper.ToRadians(90),
                50, 200, 2, 200, 90, 90, 0.5f, 1, 1, 1, true, 0.75f);
            particleBar.Absolute = true;

            newHighScore = false;

            //Test for a font component
            replayText = new FontComponent(new Vector2(gameOverTextPosition.X-250, gameOverTextPosition.Y + 40), new Vector2(100, 100));
            timerText = new FontComponent(new Vector2(bannerComponent.getPosition().X + 355, bannerComponent.getPosition().Y - 12), new Vector2(100, 100));

            //Button Initializations
            replayButton = new Button(replayText.getPosition(), replayText.getSize());
            replayText.setAlpha(0.0f);

            mainMenuText = new FontComponent(new Vector2(gameOverTextPosition.X + 100, gameOverTextPosition.Y + 40), new Vector2(100, 100));
            mainMenuText.alpha = 0.0f;
            mainMenuButton = new Button(mainMenuText.getPosition(), mainMenuText.getSize());


            scoreDisplayText = new FontComponent(new Vector2(windowWidth / 2-150, windowHeight / 2 + 100), new Vector2(300, 100));
            scoreDisplayText.setFontScale(2.0f);
            scoreDisplayText.alpha = 0.0f;
            scoreDisplayText.setOriginCenter();

            highScoreText = new FontComponent(new Vector2(windowWidth/2-150, windowHeight/2 - 300), new Vector2(300, 300));
            highScoreText.setFontScale(6.0f);
            highScoreText.setOriginCenter();
        }
Example #2
0
 public Menu()
 {
     menuBackground = new SpriteComponent(new Vector2(0.0f, 0.0f), new Vector2(Game1.SCREEN_WIDTH, Game1.SCREEN_HEIGHT));
     menuBackground.setOriginTopLeft();
     playButton = new Button(new Vector2(508.0f, 903.0f), new Vector2(240.0f, 75.0f));
 }