]> Dogcows Code - chaz/carfire/blob - 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
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using Microsoft.Xna.Framework;
6 using Microsoft.Xna.Framework.Content;
7 using Microsoft.Xna.Framework.Graphics;
8 using Microsoft.Xna.Framework.Input;
9
10 namespace CarFire
11 {
12 class HUD
13 {
14 Game mGame;
15 SpriteFont HUDfont;
16 public HUD(Game game)
17 {
18 mGame = game;
19 }
20 public void LoadContent(ContentManager contentManager)
21 {
22 HUDfont = contentManager.Load<SpriteFont>("menuFont");
23 }
24 /// <summary>
25 /// This is called when the game should draw itself.
26 /// </summary>
27 /// <param name="spriteBatch">Used to draw with</param>
28 public void Draw(SpriteBatch spriteBatch)
29 {
30 Color[] playerColors = new Color[4];
31 playerColors[0] = Color.Red;
32 playerColors[1] = Color.PowderBlue;
33 playerColors[2] = Color.Peru;
34 playerColors[3] = Color.Wheat;
35 spriteBatch.GraphicsDevice.RenderState.AlphaBlendEnable = true;
36 spriteBatch.GraphicsDevice.RenderState.SourceBlend = Blend.One;
37 spriteBatch.GraphicsDevice.RenderState.DestinationBlend = Blend.One;
38 for (int i = 0; i < mGame.State.mCharacters.Length; i++ )
39 {
40 Player player = mGame.State.mCharacters[i];
41 spriteBatch.DrawString(HUDfont, "Player" + (i+1), new Vector2(640, 10 + 80*i), playerColors[i]);
42 spriteBatch.DrawString(HUDfont, "Health: " + player.Health, new Vector2(640, 30 + 80 * i), playerColors[i]);
43 spriteBatch.DrawString(HUDfont, "Score: " + player.Score, new Vector2(640, 50 + 80 * i), playerColors[i]);
44 }
45 }
46 }
47 }
This page took 0.032392 seconds and 4 git commands to generate.