remove some magic values from scoreRenderer
parent
17bed9c60b
commit
670ac8e247
|
@ -43,7 +43,10 @@ namespace PongFE
|
||||||
WhitePixel = new Texture2D(GraphicsDevice, 1, 1);
|
WhitePixel = new Texture2D(GraphicsDevice, 1, 1);
|
||||||
WhitePixel.SetData(new Color[] { Color.White });
|
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 InputEngine());
|
||||||
WorldBuilder.AddEngine(new PaddleMovementEngine());
|
WorldBuilder.AddEngine(new PaddleMovementEngine());
|
||||||
|
|
|
@ -11,6 +11,8 @@ namespace PongFE.Renderers
|
||||||
{
|
{
|
||||||
public SpriteBatch SpriteBatch { get; }
|
public SpriteBatch SpriteBatch { get; }
|
||||||
public DynamicSpriteFont Font { get; }
|
public DynamicSpriteFont Font { get; }
|
||||||
|
public int SpacingFromCenter { get; } = 240;
|
||||||
|
public int SpacingFromTop { get; } = 20;
|
||||||
|
|
||||||
public ScoreRenderer(SpriteBatch spriteBatch, DynamicSpriteFont font)
|
public ScoreRenderer(SpriteBatch spriteBatch, DynamicSpriteFont font)
|
||||||
{
|
{
|
||||||
|
@ -43,7 +45,7 @@ namespace PongFE.Renderers
|
||||||
SpriteBatch.DrawString(
|
SpriteBatch.DrawString(
|
||||||
Font,
|
Font,
|
||||||
playerOneScore.Value.ToString(),
|
playerOneScore.Value.ToString(),
|
||||||
new Vector2(400, 20),
|
new Vector2(640 - SpacingFromCenter, SpacingFromTop),
|
||||||
Color.White
|
Color.White
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -53,7 +55,7 @@ namespace PongFE.Renderers
|
||||||
SpriteBatch.DrawString(
|
SpriteBatch.DrawString(
|
||||||
Font,
|
Font,
|
||||||
playerTwoScore.Value.ToString(),
|
playerTwoScore.Value.ToString(),
|
||||||
new Vector2(880 - 64, 20),
|
new Vector2(640 + SpacingFromCenter - (Font.Size / 2), SpacingFromTop),
|
||||||
Color.White
|
Color.White
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue