示例#1
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            spriteBatch.Begin();
            spriteBatch.Draw(background, AssetManager.Get().GameSceneViewport.Bounds, Color.White);

            if (collisionDetectionSystem.CollisionOccured)
            {
                // GraphicsDevice.Clear(Color.Red);
                if (count >= 0)
                {
                    var message = "GAME OVER \nyou came to close!";
                    var height  = AssetManager.Get().GameSceneViewport.Height;
                    var width   = AssetManager.Get().GameSceneViewport.Width;

                    spriteBatch.DrawString(font, message, new Vector2((width - font.MeasureString(message).X) * 0.5f, (height - font.MeasureString(message).Y) * 0.5f), Color.White);
                }
            }
            else
            {
                GraphicsDevice.Clear(Color.CornflowerBlue);
            }

            spriteBatch.End();

            // TODO: Entity Component Systems
            renderingSystem.Draw(gameTime, spriteBatch);
            textSystem.Draw(gameTime, spriteBatch);
            base.Draw(gameTime);
        }
示例#2
0
        protected override void Draw(GameTime gameTime)
        {
            if (gameTime.TotalGameTime.Seconds > _lastTime)
            {
                _lastTime    = gameTime.TotalGameTime.Seconds;
                frame        = frameCounter;
                frameCounter = 0;
            }
            frameCounter++;


            if (!GameContent.IsLoaded)
            {
                GraphicsDevice.Clear(Color.CornflowerBlue);
                if (GameContent.IsBaseLoaded)
                {
                    var size = GameContent.Font.hudFont.MeasureString("Click on game area to start it!");

                    spriteBatch.Begin();

                    if (!GameContent.IsLoaded)
                    {
                        spriteBatch.DrawString(GameContent.Font.hudFont,
                                               "Zelda is loading: " + GameContent.Counter + " / " + GameContent.Max,
                                               new Vector2(20, 440 - size.Y - 10),
                                               Color.White,
                                               0f,
                                               Vector2.Zero,
                                               .5f,
                                               SpriteEffects.None,
                                               1f);
                        //spriteBatch.Draw(GameContent.Texture.Pixel, new Rectangle(20, 440, (int)(760 * (GameContent.Counter / (float)GameContent.Max)), 20), Color.White);
                    }

                    spriteBatch.End();
                }

                base.Draw(gameTime);
                return;
            }

            GraphicsDevice.Clear(Color.IndianRed);

            spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend, SamplerState.PointClamp);

            SpriteSystem.Draw(spriteBatch);   // Draw all Sprite components
            ColliderSystem.Draw(spriteBatch); // Draw all Collider debug boxes
            TextSystem.Draw(spriteBatch);     // Draw all Text components

            if (LevelManager.showFPS)
            {
                DrawShadowedString(GameContent.Font.hudFont, "FPS: " + frame, new Vector2(440f, 20f), Color.Yellow);
            }

            spriteBatch.End();

            base.Draw(gameTime);
        }