protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); // TODO: use this.Content to load your game content here gaussianBlurShader = Shaders.gaussianBlur(Content); Fonts.arial = Content.Load <SpriteFont>("BaseFont"); Fonts.timer = Content.Load <SpriteFont>("TimerFont"); }
protected override void Draw(GameTime gameTime) { if (uiScreen != null) { uiScreen.render(this, spriteBatch); return; } GraphicsDevice.SetRenderTarget(renderTarget); GraphicsDevice.Clear(Color.CornflowerBlue); spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.PointClamp); map.render(camera, spriteBatch, 0); renderEntities(entities[0]); renderParticles(particles[0]); map.render(camera, spriteBatch, 1); renderEntities(entities[1]); renderParticles(particles[1]); map.render(camera, spriteBatch, 2); renderEntities(entities[2]); renderParticles(particles[2]); if (editMode) { wiringEditor?.render(camera, spriteBatch); } spriteBatch.End(); GraphicsDevice.SetRenderTarget(null); // POST-PROCESSING Effect shader = shouldBlur() ? gaussianBlurShader : null; if (shouldBlur()) { Shaders.setGaussianOffsets(2 * Util.sinSmooth(pauseTimer, pauseTransitionTime)); } spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.PointClamp, null, null, shader, null); spriteBatch.Draw(renderTarget, new Rectangle(0, 0, 1920, 1080), Color.White); spriteBatch.End(); // Rendering UI spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.PointClamp, null, null, null, null); foreach (var element in uiElements) { element.render(spriteBatch); } // Timer SpriteFont font = Fonts.timer; string timerStr = attemptTime.ToString("F"); spriteBatch.DrawString(font, timerStr, new Vector2(1920 - 50 - font.MeasureString(timerStr).X, 50), Color.White); spriteBatch.End(); base.Draw(gameTime); }