diff --git a/Shared/Player.cs b/Shared/Player.cs index e9881ab..5092649 100644 --- a/Shared/Player.cs +++ b/Shared/Player.cs @@ -36,8 +36,13 @@ namespace SemiColinGames { private double jumpTime = 0; public Player() { + Health = MaxHealth; } + public int MaxHealth { get; private set; } = 5; + + public int Health { get; private set; } + public int Facing { get; private set; } = 1; public Point Position { get { return position; } } diff --git a/Shared/Scene.cs b/Shared/Scene.cs index 53a8227..65f2670 100644 --- a/Shared/Scene.cs +++ b/Shared/Scene.cs @@ -95,15 +95,23 @@ namespace SemiColinGames { Debug.Draw(graphics, basicEffect); // Draw in-world UI on top of everything. - if (paused) { - spriteBatch.Begin( - SpriteSortMode.Deferred, null, SamplerState.PointClamp, null, null, null, null); + spriteBatch.Begin( + SpriteSortMode.Deferred, null, SamplerState.PointClamp, null, null, null, null); + for (int i = 0; i < player.MaxHealth; i++) { + Vector2 pos = new Vector2(16 + 16 * i, 8); + if (player.Health > i) { + spriteBatch.Draw(Textures.Heart.Get, pos, new Rectangle(0, 0, 16, 16), Color.White); + } else { + spriteBatch.Draw(Textures.Heart.Get, pos, new Rectangle(16, 0, 16, 16), Color.White); + } + } + if (paused) { string text = "Paused"; Vector2 position = Textures.BannerFont.CenteredOn(text, camera.HalfSize); Text.DrawOutlined(spriteBatch, Textures.BannerFont, text, position, Color.White); - spriteBatch.End(); } + spriteBatch.End(); // Get ready to draw sceneTarget to screen. graphics.SetRenderTarget(null); @@ -124,7 +132,7 @@ namespace SemiColinGames { } // Actually draw to screen. - spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, + spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.Default, RasterizerState.CullNone); spriteBatch.Draw(sceneTarget, drawRect, Color.White); diff --git a/Shared/Textures.cs b/Shared/Textures.cs index d23b3cf..9fc4f42 100644 --- a/Shared/Textures.cs +++ b/Shared/Textures.cs @@ -34,6 +34,7 @@ namespace SemiColinGames { public static SpriteFont BannerFont; public static TextureRef Player = new TextureRef("sprites/ccg/ninja_female"); + public static TextureRef Heart = new TextureRef("sprites/semicolin/heart"); // Backgrounds are indexed by draw order; the first element should be drawn furthest back. public static TextureRef[] Backgrounds = new TextureRef[] {