Exemple #1
0
        public void Update(TimeSpan t)
        {
            // Update state
            blinkTimer.Update(t);
            starField.Pan(0, StarField.StarSpeed, t);

            // Render title
            game.Screen.Clear(Palette.ClearFill);
            starField.Render(game.Screen);
            Fonts.HeavyData.Render("BLACK NECTAR", 100, 100, 72, Palette.Energy1, game.Screen);
            Fonts.HeavyData.Render("SECOND HALF", 230, 170, 36, Palette.Energy1, game.Screen);
            if (!blink)
            {
                Fonts.HeavyData.Render("CLICK OR PRESS KEY TO CONTINUE", 100, 390, 30, Palette.Energy1, game.Screen);
            }
            game.Screen.Invalidate();

            // Check for key presses and change to game
            KeyboardState keys = Keyboard.GetState();

            if ((keys.GetPressedKeys().Length > 0 || MouseFixed.LeftButton) && oldInputState == 0)
            {
                game.ChangeToInstructionScreen();
            }
            else
            {
                oldInputState  = keys.GetPressedKeys().Length > 0 ? 1 : 0;
                oldInputState += MouseFixed.LeftButton ? 1 : 0;
            }
        }
Exemple #2
0
        public void Update(TimeSpan t)
        {
            // Update timers
            blinkTimer.Update(t);
            energyTimer.Update(t);

            // Render instructions
            game.Screen.Clear(Palette.ClearFill);
            Fonts.HeavyData.Render("INSTRUCTIONS", 50, 30, 48, Palette.Energy1, game.Screen);
            Fonts.HeavyData.Render("MOVE LEFT AND RIGHT WITH ARROW KEYS", 60, 120, 30, Palette.Energy1, game.Screen);
            Fonts.HeavyData.Render("AVOID ASTEROIDS", 60, 170, 30, Palette.Energy1, game.Screen);
            game.Screen.FillRectangleFixed(300, 172, 300 + 30, 172 + 30, Palette.Asteroid);
            Fonts.HeavyData.Render("COLLECT ENERGY TO SURVIVE", 60, 220, 30, Palette.Energy1, game.Screen);
            game.Screen.FillRectangleFixed(450, 226, 450 + Energy.PelletSize, 226 + Energy.PelletSize, energyColor);
            if (!blink)
            {
                Fonts.HeavyData.Render("CLICK OR PRESS KEY TO PLAY", 120, 390, 30, Palette.Energy1, game.Screen);
            }
            game.Screen.Invalidate();

            // Check for key presses and change to game
            KeyboardState keys = Keyboard.GetState();

            if ((keys.GetPressedKeys().Length > 0 || MouseFixed.LeftButton) && oldInputState == 0)
            {
                game.ChangeToGameScreen();
            }
            else
            {
                oldInputState  = keys.GetPressedKeys().Length > 0 ? 1 : 0;
                oldInputState += MouseFixed.LeftButton ? 1 : 0;
            }
        }
        public void Update(TimeSpan t)
        {
            // Update timers
            blinkTimer.Update(t);

            // Render instructions
            game.Screen.Clear(Palette.ClearFill);
            Fonts.HeavyData.Render("GAME OVER", 180, 100, 60, Palette.Energy1, game.Screen);
            Fonts.HeavyData.Render(String.Format("SURVIVAL: {0:D2}:{1:D2}", survival.Minutes, survival.Seconds), 210, 200, 30, Palette.Energy1, game.Screen);
            if (!blink)
            {
                Fonts.HeavyData.Render("CLICK OR PRESS KEY TO CONTINUE", 100, 390, 30, Palette.Energy1, game.Screen);
            }
            game.Screen.Invalidate();

            // Check for key presses and change to game
            KeyboardState keys = Keyboard.GetState();

            if ((keys.GetPressedKeys().Length > 0 || MouseFixed.LeftButton) && oldInputState == 0)
            {
                game.ChangeToTitleScreen();
            }
            else
            {
                oldInputState  = keys.GetPressedKeys().Length > 0 ? 1 : 0;
                oldInputState += MouseFixed.LeftButton ? 1 : 0;
            }
        }
        public void Update(TimeSpan t)
        {
            // Update position from input
            KeyboardState keys = Keyboard.GetState();

            if (keys.IsKeyDown(Keys.Left) && keys.IsKeyUp(Keys.Right))
            {
                XVelocity = -PlayerSpeed;
            }
            else if (keys.IsKeyDown(Keys.Right) && keys.IsKeyUp(Keys.Left))
            {
                XVelocity = PlayerSpeed;
            }
            else
            {
                XVelocity = 0;
            }
            X += XVelocity * (float)t.TotalSeconds;

            // Warp around edges
            if (X < -PlayerWidth)
            {
                X = game.Width - 1;
            }
            else if (X > game.Width - 1)
            {
                X = -PlayerWidth + 1;
            }

            // Update energy
            Energy += EnergyDecay * (float)t.TotalSeconds;
            if (Energy <= 0)
            {
                Energy = 0;
            }

            // Update timers
            barBlinkTimer.Update(t);
        }