Add player health & a heart sprite.
GitOrigin-RevId: 3389f46044a3fbb48af8533370c0318982c9ad83
This commit is contained in:
parent
c213009134
commit
c189cfcc09
@ -36,8 +36,13 @@ namespace SemiColinGames {
|
|||||||
private double jumpTime = 0;
|
private double jumpTime = 0;
|
||||||
|
|
||||||
public Player() {
|
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 int Facing { get; private set; } = 1;
|
||||||
|
|
||||||
public Point Position { get { return position; } }
|
public Point Position { get { return position; } }
|
||||||
|
@ -95,15 +95,23 @@ namespace SemiColinGames {
|
|||||||
Debug.Draw(graphics, basicEffect);
|
Debug.Draw(graphics, basicEffect);
|
||||||
|
|
||||||
// Draw in-world UI on top of everything.
|
// Draw in-world UI on top of everything.
|
||||||
if (paused) {
|
|
||||||
spriteBatch.Begin(
|
spriteBatch.Begin(
|
||||||
SpriteSortMode.Deferred, null, SamplerState.PointClamp, null, null, null, null);
|
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";
|
string text = "Paused";
|
||||||
Vector2 position = Textures.BannerFont.CenteredOn(text, camera.HalfSize);
|
Vector2 position = Textures.BannerFont.CenteredOn(text, camera.HalfSize);
|
||||||
Text.DrawOutlined(spriteBatch, Textures.BannerFont, text, position, Color.White);
|
Text.DrawOutlined(spriteBatch, Textures.BannerFont, text, position, Color.White);
|
||||||
spriteBatch.End();
|
|
||||||
}
|
}
|
||||||
|
spriteBatch.End();
|
||||||
|
|
||||||
// Get ready to draw sceneTarget to screen.
|
// Get ready to draw sceneTarget to screen.
|
||||||
graphics.SetRenderTarget(null);
|
graphics.SetRenderTarget(null);
|
||||||
@ -124,7 +132,7 @@ namespace SemiColinGames {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Actually draw to screen.
|
// Actually draw to screen.
|
||||||
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend,
|
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend,
|
||||||
SamplerState.PointClamp, DepthStencilState.Default,
|
SamplerState.PointClamp, DepthStencilState.Default,
|
||||||
RasterizerState.CullNone);
|
RasterizerState.CullNone);
|
||||||
spriteBatch.Draw(sceneTarget, drawRect, Color.White);
|
spriteBatch.Draw(sceneTarget, drawRect, Color.White);
|
||||||
|
@ -34,6 +34,7 @@ namespace SemiColinGames {
|
|||||||
public static SpriteFont BannerFont;
|
public static SpriteFont BannerFont;
|
||||||
|
|
||||||
public static TextureRef Player = new TextureRef("sprites/ccg/ninja_female");
|
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.
|
// Backgrounds are indexed by draw order; the first element should be drawn furthest back.
|
||||||
public static TextureRef[] Backgrounds = new TextureRef[] {
|
public static TextureRef[] Backgrounds = new TextureRef[] {
|
||||||
|
Loading…
Reference in New Issue
Block a user