]> Dogcows Code - chaz/carfire/blob - CarFire/CarFire/CarFire/Display.cs
git-svn-id: https://bd85.net/svn/cs3505_group@163 92bb83a3-7c8f-8a45-bc97-515c4e399668
[chaz/carfire] / CarFire / CarFire / CarFire / Display.cs
1 #undef SINGLE_TEST
2
3 // Define INGAME_ZOOM to allow zooming in and out with
4 // the PageUp and PageDown keys.
5 #define INGAME_ZOOM
6
7 using System;
8 using System.Collections.Generic;
9 using System.Linq;
10 using System.Text;
11 using Microsoft.Xna.Framework;
12 using Microsoft.Xna.Framework.Content;
13 using Microsoft.Xna.Framework.Graphics;
14 using Microsoft.Xna.Framework.Input;
15
16 namespace CarFire
17 {
18 /// <summary>
19 /// This class is responsible for controlling what draws to the screen when the game is running.
20 /// </summary>
21 public class Display
22 {
23 Texture2D everything;
24 Texture2D projectile1;
25 Game mGame;
26 GameLogic mGameLogic;
27 HUD theHUD;
28 #if SINGLE_TEST
29 List<Keys> mLastPressedKeys = new List<Keys>();
30 #endif
31 public Display(Game game)
32 {
33 mGame = game;
34 mGameLogic = new GameLogic(game);
35 theHUD = new HUD(game);
36 /*
37 mMap = aMap;
38 mCharacters = characters;
39 */
40 }
41
42 /// <summary>
43 /// LoadContent will be called once per game and is the place to load
44 /// all of your content.
45 /// </summary>
46 public void LoadContent(ContentManager contentManager)
47 {
48 everything = contentManager.Load<Texture2D>("cs");
49 projectile1 = contentManager.Load<Texture2D>("projectile");
50 theHUD.LoadContent(contentManager);
51 }
52
53 /// <summary>
54 /// UnloadContent will be called once per game and is the place to unload
55 /// all content.
56 /// </summary>
57 public void UnloadContent()
58 {
59 // TODO: Unload any non ContentManager content here
60 }
61
62 /// <summary>
63 /// Allows the game to run logic such as updating the world,
64 /// checking for collisions, gathering input, and playing audio.
65 /// </summary>
66 /// <param name="gameTime">Provides a snapshot of timing values.</param>
67 public void Update(TimeSpan timeSpan,int thisPlayer)
68 {
69 mGameLogic.Update(timeSpan, thisPlayer);
70
71 #if INGAME_ZOOM
72 if (Keyboard.GetState().IsKeyDown(Keys.PageUp)) mGame.State.Map.Zoom = mGame.State.Map.Zoom + 0.5f;
73 if (Keyboard.GetState().IsKeyDown(Keys.PageDown)) mGame.State.Map.Zoom = mGame.State.Map.Zoom - 0.5f;
74 #endif
75 }
76
77 /// <summary>
78 /// This is called when the game should draw itself.
79 /// </summary>
80 /// <param name="spriteBatch">Used to draw with</param>
81 public void Draw(SpriteBatch spriteBatch)
82 {
83 mGame.State.Map.Draw(spriteBatch);
84 mGame.State.Entities.ForEach(delegate(IEntity e) { e.Draw(spriteBatch); });
85
86 foreach(Projectile projectile in mGame.State.mProjectiles)
87 {
88 projectile.Draw(spriteBatch);
89 }
90 for(int i = 0; i < mGame.State.NumberOfPlayers; i++)//IPlayer character in mCharacters)
91 {
92
93 if (mGame.State.mCharacters[i] != null)
94 {
95 mGame.State.mCharacters[i].Draw(spriteBatch);
96
97 }
98 }
99 theHUD.Draw(spriteBatch);
100
101
102 }
103
104 }
105 }
106
This page took 0.034708 seconds and 4 git commands to generate.