X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=CarFire%2FCarFire%2FCarFire%2FDisplay.cs;h=c6ae062c2ad93fa57cbedcb031d0647c7e2952d0;hb=594f1f722dc8e405dff12baad8c2ef5481fa3fa7;hp=c65075f3fb3a2209d6364ab00d69ad7bbc656214;hpb=8e3efc188caf3e6c4132e9291fcc2ba1e9213293;p=chaz%2Fcarfire diff --git a/CarFire/CarFire/CarFire/Display.cs b/CarFire/CarFire/CarFire/Display.cs index c65075f..c6ae062 100644 --- a/CarFire/CarFire/CarFire/Display.cs +++ b/CarFire/CarFire/CarFire/Display.cs @@ -1,4 +1,10 @@ -using System; +#undef SINGLE_TEST + +// Define INGAME_ZOOM to allow zooming in and out with +// the PageUp and PageDown keys. +#define INGAME_ZOOM + +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -9,13 +15,22 @@ using Microsoft.Xna.Framework.Input; namespace CarFire { + /// + /// This class is responsible for controlling what draws to the screen when the game is running. + /// public class Display { - List mProjectiles = new List(); - List mCharacters = new List(); - Map mMap; - public Display() + Texture2D everything; + Texture2D projectile1; + Game mGame; + GameLogic mGameLogic; +#if SINGLE_TEST + List mLastPressedKeys = new List(); +#endif + public Display(Game game) { + mGame = game; + mGameLogic = new GameLogic(game); /* mMap = aMap; mCharacters = characters; @@ -28,13 +43,8 @@ namespace CarFire /// public void LoadContent(ContentManager contentManager) { - Texture2D everything = contentManager.Load("cs"); - mMap = contentManager.Load("Maps/stable"); - Map.DefaultTile = contentManager.Load("default"); - mMap.CenterCell = new Vector2(5,5); - //List entities = mMap.GetAllEntities(); - mProjectiles.Add(new Projectile(mMap, everything, new Vector2(5,5), 10, 10, 300, 300)); - // TODO: use this.Content to load your game content here + everything = contentManager.Load("cs"); + projectile1 = contentManager.Load("projectile"); } /// @@ -51,48 +61,41 @@ namespace CarFire /// checking for collisions, gathering input, and playing audio. /// /// Provides a snapshot of timing values. - public void Update(TimeSpan timespan) + public void Update(TimeSpan timeSpan,int thisPlayer) { - - foreach (Projectile projectile in mProjectiles) - { - projectile.Update(timespan); - } - //Check for collisons - foreach (Character character in mCharacters) - { - foreach (Projectile projectile in mProjectiles) - { - if (projectile.GridX == character.GridX && projectile.GridY == character.GridY) - { - //Debug - not sure if you can remove while doing for each - //Alternative - while loop, and decrement projectile counter if projectile is removed. - mProjectiles.Remove(projectile); - character.Health -= projectile.Damage; - } - } - } + mGameLogic.Update(timeSpan, thisPlayer); + +#if INGAME_ZOOM + if (Keyboard.GetState().IsKeyDown(Keys.PageUp)) mGame.State.Map.Zoom = mGame.State.Map.Zoom + 0.5f; + if (Keyboard.GetState().IsKeyDown(Keys.PageDown)) mGame.State.Map.Zoom = mGame.State.Map.Zoom - 0.5f; +#endif } /// /// This is called when the game should draw itself. /// - /// Provides a snapshot of timing values. + /// Used to draw with public void Draw(SpriteBatch spriteBatch) { - mMap.Draw(spriteBatch); - foreach(Projectile projectile in mProjectiles) + mGame.State.Map.Draw(spriteBatch); + mGame.State.Entities.ForEach(delegate(IEntity e) { e.Draw(spriteBatch); }); + + foreach(Projectile projectile in mGame.State.mProjectiles) { projectile.Draw(spriteBatch); - } - foreach(Character character in mCharacters) + for(int i = 0; i < mGame.State.NumberOfPlayers; i++)//IPlayer character in mCharacters) { - character.Draw(spriteBatch); - } + if (mGame.State.mCharacters[i] != null) + { + mGame.State.mCharacters[i].Draw(spriteBatch); + + } + } } + } }