Texture2D projectile1;\r
Game mGame;\r
GameLogic mGameLogic;\r
+ HUD theHUD;\r
#if SINGLE_TEST\r
List<Keys> mLastPressedKeys = new List<Keys>();\r
#endif\r
{\r
mGame = game;\r
mGameLogic = new GameLogic(game);\r
+ theHUD = new HUD(game);\r
/*\r
mMap = aMap;\r
mCharacters = characters;\r
{\r
everything = contentManager.Load<Texture2D>("cs");\r
projectile1 = contentManager.Load<Texture2D>("projectile");\r
+ theHUD.LoadContent(contentManager);\r
}\r
\r
/// <summary>\r
\r
}\r
}\r
+ theHUD.Draw(spriteBatch);\r
+\r
\r
}\r
\r
--- /dev/null
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using Microsoft.Xna.Framework;\r
+using Microsoft.Xna.Framework.Content;\r
+using Microsoft.Xna.Framework.Graphics;\r
+using Microsoft.Xna.Framework.Input;\r
+\r
+namespace CarFire\r
+{\r
+ class HUD\r
+ {\r
+ Game mGame;\r
+ SpriteFont HUDfont;\r
+ public HUD(Game game)\r
+ {\r
+ mGame = game;\r
+ }\r
+ public void LoadContent(ContentManager contentManager)\r
+ {\r
+ HUDfont = contentManager.Load<SpriteFont>("menuFont");\r
+ }\r
+ /// <summary>\r
+ /// This is called when the game should draw itself.\r
+ /// </summary>\r
+ /// <param name="spriteBatch">Used to draw with</param>\r
+ public void Draw(SpriteBatch spriteBatch)\r
+ {\r
+ Color[] playerColors = new Color[4];\r
+ playerColors[0] = Color.Red;\r
+ playerColors[1] = Color.PowderBlue;\r
+ playerColors[2] = Color.Peru;\r
+ playerColors[3] = Color.Wheat;\r
+ spriteBatch.GraphicsDevice.RenderState.AlphaBlendEnable = true;\r
+ spriteBatch.GraphicsDevice.RenderState.SourceBlend = Blend.One;\r
+ spriteBatch.GraphicsDevice.RenderState.DestinationBlend = Blend.One;\r
+ for (int i = 0; i < mGame.State.mCharacters.Length; i++ )\r
+ {\r
+ Player player = mGame.State.mCharacters[i];\r
+ spriteBatch.DrawString(HUDfont, "Player" + (i+1), new Vector2(640, 10 + 80*i), playerColors[i]);\r
+ spriteBatch.DrawString(HUDfont, "Health: " + player.Health, new Vector2(640, 30 + 80 * i), playerColors[i]);\r
+ spriteBatch.DrawString(HUDfont, "Score: " + player.Score, new Vector2(640, 50 + 80 * i), playerColors[i]);\r
+ }\r
+ }\r
+ }\r
+}\r