From 8e3efc188caf3e6c4132e9291fcc2ba1e9213293 Mon Sep 17 00:00:00 2001 From: Kyle Date: Thu, 15 Apr 2010 03:36:52 +0000 Subject: [PATCH] Partially working display git-svn-id: https://bd85.net/svn/cs3505_group@81 92bb83a3-7c8f-8a45-bc97-515c4e399668 --- CarFire/CarFire/CarFire/Display.cs | 98 ++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 CarFire/CarFire/CarFire/Display.cs diff --git a/CarFire/CarFire/CarFire/Display.cs b/CarFire/CarFire/CarFire/Display.cs new file mode 100644 index 0000000..c65075f --- /dev/null +++ b/CarFire/CarFire/CarFire/Display.cs @@ -0,0 +1,98 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Content; +using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework.Input; + +namespace CarFire +{ + public class Display + { + List mProjectiles = new List(); + List mCharacters = new List(); + Map mMap; + public Display() + { + /* + mMap = aMap; + mCharacters = characters; + */ + } + + /// + /// LoadContent will be called once per game and is the place to load + /// all of your content. + /// + 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 + } + + /// + /// UnloadContent will be called once per game and is the place to unload + /// all content. + /// + public void UnloadContent() + { + // TODO: Unload any non ContentManager content here + } + + /// + /// Allows the game to run logic such as updating the world, + /// checking for collisions, gathering input, and playing audio. + /// + /// Provides a snapshot of timing values. + public void Update(TimeSpan timespan) + { + + 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; + } + } + } + } + + /// + /// This is called when the game should draw itself. + /// + /// Provides a snapshot of timing values. + public void Draw(SpriteBatch spriteBatch) + { + mMap.Draw(spriteBatch); + foreach(Projectile projectile in mProjectiles) + { + projectile.Draw(spriteBatch); + + } + foreach(Character character in mCharacters) + { + character.Draw(spriteBatch); + } + + + } + } +} + -- 2.43.0