]> Dogcows Code - chaz/carfire/blob - CarFire/CarFire/CarFire/Display.cs
Seperated GameLogic from the Display
[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 #if SINGLE_TEST
28 List<Keys> mLastPressedKeys = new List<Keys>();
29 #endif
30 public Display(Game game)
31 {
32 mGame = game;
33 mGameLogic = new GameLogic(game);
34 /*
35 mMap = aMap;
36 mCharacters = characters;
37 */
38 }
39
40 /// <summary>
41 /// LoadContent will be called once per game and is the place to load
42 /// all of your content.
43 /// </summary>
44 public void LoadContent(ContentManager contentManager)
45 {
46 everything = contentManager.Load<Texture2D>("cs");
47 projectile1 = contentManager.Load<Texture2D>("projectile");
48 }
49
50 /// <summary>
51 /// UnloadContent will be called once per game and is the place to unload
52 /// all content.
53 /// </summary>
54 public void UnloadContent()
55 {
56 // TODO: Unload any non ContentManager content here
57 }
58
59 /// <summary>
60 /// Allows the game to run logic such as updating the world,
61 /// checking for collisions, gathering input, and playing audio.
62 /// </summary>
63 /// <param name="gameTime">Provides a snapshot of timing values.</param>
64 public void Update(TimeSpan timeSpan,int thisPlayer)
65 {
66 mGameLogic.Update(timeSpan, thisPlayer);
67
68 #if INGAME_ZOOM
69 if (Keyboard.GetState().IsKeyDown(Keys.PageUp)) mGame.State.Map.Zoom = mGame.State.Map.Zoom + 0.5f;
70 if (Keyboard.GetState().IsKeyDown(Keys.PageDown)) mGame.State.Map.Zoom = mGame.State.Map.Zoom - 0.5f;
71 #endif
72 }
73
74 /// <summary>
75 /// This is called when the game should draw itself.
76 /// </summary>
77 /// <param name="spriteBatch">Used to draw with</param>
78 public void Draw(SpriteBatch spriteBatch)
79 {
80 mGame.State.Map.Draw(spriteBatch);
81 mGame.State.Entities.ForEach(delegate(IEntity e) { e.Draw(spriteBatch); });
82
83 foreach(Projectile projectile in mGame.State.mProjectiles)
84 {
85 projectile.Draw(spriteBatch);
86 }
87 for(int i = 0; i < mGame.State.NumberOfPlayers; i++)//IPlayer character in mCharacters)
88 {
89
90 if (mGame.State.mCharacters[i] != null)
91 {
92 mGame.State.mCharacters[i].Draw(spriteBatch);
93
94 }
95 }
96
97 }
98
99 }
100 }
101
This page took 0.032386 seconds and 4 git commands to generate.