remove some magic values from scoreRenderer

main
Evan Hemsley 2020-07-16 15:34:58 -07:00
parent 17bed9c60b
commit 670ac8e247
2 changed files with 8 additions and 3 deletions

View File

@ -43,7 +43,10 @@ namespace PongFE
WhitePixel = new Texture2D(GraphicsDevice, 1, 1);
WhitePixel.SetData(new Color[] { Color.White });
ScoreFont = DynamicSpriteFont.FromTtf(File.ReadAllBytes(@"Content/Fonts/SquaredDisplay.ttf"), 128);
ScoreFont = DynamicSpriteFont.FromTtf(
File.ReadAllBytes(@"Content/Fonts/SquaredDisplay.ttf"),
128
);
WorldBuilder.AddEngine(new InputEngine());
WorldBuilder.AddEngine(new PaddleMovementEngine());

View File

@ -11,6 +11,8 @@ namespace PongFE.Renderers
{
public SpriteBatch SpriteBatch { get; }
public DynamicSpriteFont Font { get; }
public int SpacingFromCenter { get; } = 240;
public int SpacingFromTop { get; } = 20;
public ScoreRenderer(SpriteBatch spriteBatch, DynamicSpriteFont font)
{
@ -43,7 +45,7 @@ namespace PongFE.Renderers
SpriteBatch.DrawString(
Font,
playerOneScore.Value.ToString(),
new Vector2(400, 20),
new Vector2(640 - SpacingFromCenter, SpacingFromTop),
Color.White
);
}
@ -53,7 +55,7 @@ namespace PongFE.Renderers
SpriteBatch.DrawString(
Font,
playerTwoScore.Value.ToString(),
new Vector2(880 - 64, 20),
new Vector2(640 + SpacingFromCenter - (Font.Size / 2), SpacingFromTop),
Color.White
);
}