]> Dogcows Code - chaz/carfire/blobdiff - CarFire/CarFire/CarFire/HUD.cs
Basic HUD... Feel free to completely redo it. Not sure how it'll work
[chaz/carfire] / CarFire / CarFire / CarFire / HUD.cs
diff --git a/CarFire/CarFire/CarFire/HUD.cs b/CarFire/CarFire/CarFire/HUD.cs
new file mode 100644 (file)
index 0000000..5b7ffec
--- /dev/null
@@ -0,0 +1,47 @@
+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
This page took 0.022829 seconds and 4 git commands to generate.