public override void Draw(GameTime gameTime) { Vector2 center = new Vector2(ScreenManager.Game.RenderWidth, ScreenManager.Game.RenderHeight) / 2f; SpriteBatch sb = ScreenManager.SpriteBatch; ScreenManager.Game.GraphicsDevice.Clear(new Color(75, 75, 75)); sb.Begin(SpriteSortMode.Deferred, null, SamplerState.PointClamp, null, null, null, camera.CameraMatrix); map.DrawLayer(sb, "bg", camera); map.DrawLayer(sb, "fg", camera); sb.End(); heroPool.Draw(sb, camera); rotBoxPool.Draw(sb, camera); particleController.Draw(ScreenManager.SpriteBatch, camera, 1); sb.Begin(SpriteSortMode.Deferred, null, null, null, null); sb.DrawString(ScreenManager.Font, "LD ENGINE", new Vector2(50, 20) + Vector2.One, Color.Black, 0f, ScreenManager.Font.MeasureString("LD ENGINE") / 2f, textScale, SpriteEffects.None, 1); sb.DrawString(ScreenManager.Font, "LD ENGINE", new Vector2(50, 20), Color.White, 0f, ScreenManager.Font.MeasureString("LD ENGINE") / 2f, textScale, SpriteEffects.None, 1); sb.End(); ScreenManager.FadeBackBufferToBlack(1f - TransitionAlpha); base.Draw(gameTime); }
public override void Draw(GameTime gameTime) { Vector2 center = new Vector2(ScreenManager.Game.RenderWidth, ScreenManager.Game.RenderHeight) / 2f; SpriteBatch sb = ScreenManager.SpriteBatch; sb.Begin(SpriteSortMode.Deferred, null, SamplerState.PointClamp, null, null, null, camera.CameraMatrix); map.DrawLayer(sb, "fg", camera); sb.End(); particleController.Draw(sb, camera, 1); sb.Begin(SpriteSortMode.Deferred, null, SamplerState.PointClamp, null, null); sb.End(); ScreenManager.FadeBackBufferToBlack(1f - TransitionAlpha); base.Draw(gameTime); }
/// <summary> /// Draws the gameplay screen. /// </summary> public override void Draw(GameTime gameTime) { // This game has a blue background. Why? Because! ScreenManager.GraphicsDevice.Clear(ClearOptions.Target, Color.Black, 0, 0); // Our player and enemy are both actually just text strings. SpriteBatch spriteBatch = ScreenManager.SpriteBatch; backgroundController.Draw(spriteBatch); particleController.Draw(spriteBatch); bulletController.Draw(spriteBatch); enemyController.Draw(spriteBatch); playerController.Draw(spriteBatch); DrawHUD(spriteBatch); // 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); } }
//private bool tradeFlash = false; public override void Draw(GameTime gameTime) { Vector2 center = new Vector2(ScreenManager.Game.RenderWidth, ScreenManager.Game.RenderHeight) / 2f; SpriteBatch sb = ScreenManager.SpriteBatch; ScreenManager.Game.GraphicsDevice.Clear(Color.Black); if (!_firstWave) { ScreenManager.Game.GraphicsDevice.Clear(new Color(37, 59, 89)); sb.Begin(SpriteSortMode.Deferred, null, SamplerState.PointClamp, null, null); sb.Draw(ScreenManager.blankTexture, new Rectangle(0, (int)waterLevel - ((int)camera.Position.Y - ScreenManager.Game.RenderHeight / 2), ScreenManager.Game.RenderWidth, ((map.TileHeight * map.Height) + 10) - (int)waterLevel), null, new Color(0, 16, 65)); sb.End(); underwaterBGParallax.Draw(sb, camera.Position.Y); skyBGParallax.Draw(sb, camera.Position.Y); waterParallax.Draw(sb, false, camera.Position.Y); rocksParallax.Draw(sb, false, camera.Position.Y); cloudsParallax.Draw(sb, true, camera.Position.Y); particleController.Draw(sb, camera, map, 0); sb.Begin(SpriteSortMode.Deferred, null, SamplerState.PointClamp, null, null, null, camera.CameraMatrix); map.DrawLayer(sb, "fg", camera); playerShip.Draw(sb, map, ScreenManager.Font); sb.End(); enemyController.Draw(sb, camera, map); particleController.Draw(sb, camera, map, 1); projectileController.Draw(sb, camera, map); powerupController.Draw(sb, camera, map); rocksParallax.Draw(sb, true, camera.Position.Y); cloudsParallax.Draw(sb, false, camera.Position.Y); sb.Begin(SpriteSortMode.Deferred, null, SamplerState.PointClamp, null, null); sb.Draw(ScreenManager.blankTexture, new Rectangle(0, (int)waterLevel - ((int)camera.Position.Y - ScreenManager.Game.RenderHeight / 2) - 5, ScreenManager.Game.RenderWidth, ((map.TileHeight * map.Height) + 10) - (int)waterLevel), null, Color.Black * 0.4f); sb.End(); //sb.Begin(SpriteSortMode.Deferred, null, SamplerState.PointClamp, null, null); //Enemy head = EnemyController.Instance.Enemies.FirstOrDefault(en => en is Boss && ((Boss)en).Head); //if (head != null) sb.DrawString(ScreenManager.Font, head.Position.ToString(), Vector2.One * 10, Color.White); //sb.End(); waterParallax.Draw(sb, true, camera.Position.Y); } if (_endOfWave) { sb.Begin(SpriteSortMode.Deferred, null, SamplerState.PointClamp, null, null); sb.Draw(ScreenManager.blankTexture, new Rectangle(0, 0, ScreenManager.Game.RenderWidth, ScreenManager.Game.RenderHeight), null, Color.White * _waveFade); if (_tradecost > 0 && !_trading && (Ship.Instance.PowerUpMeter > 0 || Ship.Instance.PowerUpLevel > 0)) { string tradetext = "Press fire to trade " + _tradecost + " power for health"; // sb.DrawString(ScreenManager.FontSmall, tradetext, center + new Vector2(0, -50) + Vector2.One, Color.Black * _waveFade, 0f, ScreenManager.FontSmall.MeasureString(tradetext) / 2,1f, SpriteEffects.None, 0); sb.DrawString(ScreenManager.FontSmall, tradetext, center + new Vector2(0, -50), Color.DarkRed * _waveFade, 0f, ScreenManager.FontSmall.MeasureString(tradetext) / 2, 1f, SpriteEffects.None, 0); } int numdigits = GameController.Wave.ToString().Length; int wavepos = -38 - 10 - (numdigits * 8); sb.Draw(text, center + new Vector2(wavepos, -16), new Rectangle(68, 66, 77, 32), Color.White * _waveFade); for (int i = 0; i < numdigits; i++) { sb.Draw(text, center + new Vector2(wavepos + 77 + 10 + (i * 16), -16), new Rectangle(Convert.ToInt32(GameController.Wave.ToString().Substring(i, 1)) * 32, 116, 32, 32), Color.White * _waveFade); } sb.End(); } if (_gameOver) { sb.Begin(SpriteSortMode.Deferred, null, SamplerState.PointClamp, null, null); sb.Draw(ScreenManager.blankTexture, new Rectangle(0, 0, ScreenManager.Game.RenderWidth, ScreenManager.Game.RenderHeight), null, Color.Black * 0.2f * _goFade); sb.Draw(text, center + new Vector2(-47, -32), new Rectangle(196, 0, 94, 65), Color.White * _goFade); sb.End(); } hud.Draw(sb, new Viewport(0, 0, ScreenManager.Game.RenderWidth, ScreenManager.Game.RenderHeight), camera, !_endOfWave, ScreenManager.Font, (map.Width * map.TileWidth)); //ScreenManager.FadeBackBufferToBlack(1f - TransitionAlpha); base.Draw(gameTime); }
/// <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) { RenderTarget2D gamePoleImg = new RenderTarget2D(GraphicsDevice, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight); GraphicsDevice.SetRenderTarget(gamePoleImg); GraphicsDevice.Clear(Color.Black); //smoothLightEffect.Parameters["screenSize"].SetValue(new Vector2(screenWidth, screenHeight)); //smoothLightEffect.Parameters["liteSource"].SetValue(new Vector4[] { new Vector4(ScreenCenter + new Vector2(playerTextureWidth, playerTextureHeight) * 0.5f, 1.0f, (player.Type == 1 ? 8 : 6) * 32f) }); //DrawTiles(lightSources); spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.NonPremultiplied, SamplerState.PointClamp, DepthStencilState.Default, RasterizerState.CullNone); currentLocation.Draw(gameRegistry, spriteBatch, player.Position - ScreenCenter, new Vector2(screenWidth, screenHeight)); //DrawChests(lightSources); DrawFireballs(); DrawSword(ScreenCenter + new Vector2(playerTextureWidth, playerTextureHeight) / 2f, player.SwordDirection, player.GetSwordLength(gameTime), player.SwordColor); //DrawSword(ScreenCenter + new Vector2(playerTextureWidth, playerTextureHeight) / 2, r, 48, Color.Blue); //DrawSword(ScreenCenter + new Vector2(playerTextureWidth, playerTextureHeight) / 2, r + Math.PI, 48, Color.Blue); //DrawSword(ScreenCenter + new Vector2(playerTextureWidth, playerTextureHeight) / 2, r + Math.PI * 1.5, 48, Color.Green); //DrawSword(ScreenCenter + new Vector2(playerTextureWidth, playerTextureHeight) / 2, r + Math.PI * 0.5, 48, Color.Green); //r += Math.PI / 20; DrawPlayer(); //spriteBatch.Draw(lightnessMap, Vector2.Zero, new Color(255, 255, 255, 127)); spriteBatch.End(); particleController.Draw(spriteBatch, player.Position - ScreenCenter - new Vector2(32, 32) / 2, new Vector2(screenWidth, screenHeight)); //GraphicsDevice.SetRenderTarget(null); if (enableSmoothLightning) { //smoothLightEffect.Parameters["screenSize"].SetValue(new Vector2(screenWidth, screenHeight)); Vector4[] lightSources_ = (from ls in lightSources select new Vector4(new Vector2(ls.Position.X, ls.Position.Y) - player.Position + ScreenCenter, ls.Strenght, ls.Max)).ToArray(); Texture2D lightMap = ConstructLightMap(lightSources_); smoothLightMapperEffect.Parameters["screenSize"].SetValue(new Vector2(screenWidth, screenHeight)); smoothLightMapperEffect.Parameters["lightMap"].SetValue(lightMap); spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.Default, RasterizerState.CullNone, smoothLightMapperEffect); } else { GraphicsDevice.SetRenderTarget(null); spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.Default, RasterizerState.CullNone); } GraphicsDevice.Clear(Color.Black); spriteBatch.Draw(gamePoleImg, Vector2.Zero, Color.White); spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.Default, RasterizerState.CullNone); //Draw Info Stuff DrawHealthbar(player.HP, player.MaxHP); DrawSkillUsePointBar(player.SkillUsePoint, player.MaxSkillUsePoint, player.BarColor); DrawBuffs(player); DrawInventory(player); if (debugInfo) { string dbgnfo = " Pos: \n " + player.Position.X + "\n " + player.Position.Y + "\n IsRunningSlowly: " + gameTime.IsRunningSlowly + "\n FPS: " + fps + "\n Fireballs: " + fireballs.Count + "\n Particles: " + particleController.ActiveParticles; Vector2 sz = font14.MeasureString(dbgnfo); spriteBatch.DrawString(font14, dbgnfo, new Vector2(0, screenHeight - sz.Y), Color.White); } spriteBatch.End(); gamePoleImg.Dispose(); fpsCounter++; base.Draw(gameTime); }