Esempio n. 1
0
        public override void Draw(GameTime gameTime)
        {
            ScreenManager.GraphicsDevice.Clear(Color.LightSlateGray);
            // TODO: Add your drawing code here
            var spriteBatch = ScreenManager.SpriteBatch;

            spriteBatch.Begin();
            foreach (var food in foods)
            {
                food.Draw(gameTime, spriteBatch);
            }
            //exit?
            spriteBatch.End();

            spriteBatch.Begin();
            slime.Draw(gameTime, spriteBatch);
            spriteBatch.End();

            _spriteBatch.Begin();
            switch (slime.foodEaten)
            {
            case 0:
                _spriteBatch.DrawString(spriteFont, "I want pizza!\nPress Spacebar with a direction to jump forward.", new Vector2(2, 2), Color.Green);
                break;

            case 1:
                _spriteBatch.DrawString(spriteFont, "I'm so hungry...", new Vector2(2, 2), Color.Green);
                break;

            case 2:
                _spriteBatch.DrawString(spriteFont, "Om Nom Nom", new Vector2(2, 2), Color.Green);
                break;

            case 3:
                _spriteBatch.DrawString(spriteFont, "More! MORE!", new Vector2(2, 2), Color.Green);
                break;

            case 4:
                _spriteBatch.DrawString(spriteFont, "PIZZA!!!", new Vector2(2, 2), Color.Green);
                break;

            case 5:
                _spriteBatch.DrawString(spriteFont, "I can see my house from here.", new Vector2(2, 2), Color.Green);
                break;

            case 6:
                _spriteBatch.DrawString(spriteFont, "All Full! Time for a nap.", new Vector2(2, 2), Color.Green);
                break;
            }
            if (slime.foodEaten < 6 && _timerGoing)
            {
                gameTimer = gameTime.TotalGameTime.TotalSeconds;
            }
            _spriteBatch.DrawString(spriteFont, $"{gameTimer:f}", new Vector2(ScreenManager.GraphicsDevice.Viewport.Width - 200, 2), Color.White);
            _spriteBatch.End();
        }
Esempio n. 2
0
        public override void Draw(GameTime gameTime)
        {
            // This game has a blue background. Why? Because!
            ScreenManager.GraphicsDevice.Clear(ClearOptions.Target, Color.CornflowerBlue, 0, 0);

            // Our player and enemy are both actually just text strings.
            var spriteBatch = ScreenManager.SpriteBatch;

            spriteBatch.Begin();

            foreach (var coin in coinsList)
            {
                coin.Draw(gameTime, spriteBatch);
            }

            slimeSprite.Draw(gameTime, spriteBatch);
            //spriteBatch.DrawString(_gameFont, gameTime, new Vector2() )
            spriteBatch.DrawString(_gameFont, $"Coin Count: {coinsCount}", new Vector2(2, 2), Color.Gold, 0, Vector2.Zero, 0.5f, SpriteEffects.None, 0);
            //spriteBatch.DrawString(_gameFont,  gameTime.ElapsedGameTime.TotalSeconds.ToString(), new Vector2(300, 2), Color.Gold, 0, Vector2.Zero, 0.5f, SpriteEffects.None, 0);
            if (coinsCount < 4)
            {
                spriteBatch.DrawString(_gameFont, $"Collect 10 Coins to Win", new Vector2(500, 2), Color.Gold, 0, Vector2.Zero, 0.5f, SpriteEffects.None, 0);
            }
            if (coinsCount > 9)
            {
                spriteBatch.DrawString(_gameFont, $"Congrats you won", new Vector2(300, 2), Color.Gold, 0, Vector2.Zero, 0.5f, SpriteEffects.None, 0);
            }
            spriteBatch.End();

            // If the game is transitioning on or off, fade it out to black.
            if (TransitionPosition > 0 || _pauseAlpha > 0)
            {
                float alpha = MathHelper.Lerp(1f - TransitionAlpha, 1f, _pauseAlpha / 2);

                ScreenManager.FadeBackBufferToBlack(alpha);
            }
        }