]> Dogcows Code - chaz/carfire/commitdiff
Partially working display
authorKyle <Kyle@92bb83a3-7c8f-8a45-bc97-515c4e399668>
Thu, 15 Apr 2010 03:36:52 +0000 (03:36 +0000)
committerKyle <Kyle@92bb83a3-7c8f-8a45-bc97-515c4e399668>
Thu, 15 Apr 2010 03:36:52 +0000 (03:36 +0000)
git-svn-id: https://bd85.net/svn/cs3505_group@81 92bb83a3-7c8f-8a45-bc97-515c4e399668

CarFire/CarFire/CarFire/Display.cs [new file with mode: 0644]

diff --git a/CarFire/CarFire/CarFire/Display.cs b/CarFire/CarFire/CarFire/Display.cs
new file mode 100644 (file)
index 0000000..c65075f
--- /dev/null
@@ -0,0 +1,98 @@
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using Microsoft.Xna.Framework;\r
+using Microsoft.Xna.Framework.Content;\r
+using Microsoft.Xna.Framework.Graphics;\r
+using Microsoft.Xna.Framework.Input;\r
+\r
+namespace CarFire\r
+{\r
+    public class Display\r
+    {\r
+        List<Projectile> mProjectiles = new List<Projectile>();\r
+        List<Character> mCharacters = new List<Character>();\r
+        Map mMap;\r
+        public Display()\r
+        {\r
+            /*\r
+            mMap = aMap;\r
+            mCharacters = characters;\r
+             */\r
+        }\r
+\r
+        /// <summary>\r
+        /// LoadContent will be called once per game and is the place to load\r
+        /// all of your content.\r
+        /// </summary>\r
+        public void LoadContent(ContentManager contentManager)\r
+        {\r
+            Texture2D everything = contentManager.Load<Texture2D>("cs");\r
+            mMap = contentManager.Load<Map>("Maps/stable");\r
+            Map.DefaultTile = contentManager.Load<Texture2D>("default");\r
+            mMap.CenterCell = new Vector2(5,5);\r
+            //List<object> entities = mMap.GetAllEntities();\r
+            mProjectiles.Add(new Projectile(mMap, everything, new Vector2(5,5), 10, 10, 300, 300));\r
+            // TODO: use this.Content to load your game content here\r
+        }\r
+\r
+        /// <summary>\r
+        /// UnloadContent will be called once per game and is the place to unload\r
+        /// all content.\r
+        /// </summary>\r
+        public void UnloadContent()\r
+        {\r
+            // TODO: Unload any non ContentManager content here\r
+        }\r
+\r
+        /// <summary>\r
+        /// Allows the game to run logic such as updating the world,\r
+        /// checking for collisions, gathering input, and playing audio.\r
+        /// </summary>\r
+        /// <param name="gameTime">Provides a snapshot of timing values.</param>\r
+        public void Update(TimeSpan timespan)\r
+        {\r
+           \r
+            foreach (Projectile projectile in mProjectiles)\r
+            {\r
+                projectile.Update(timespan);\r
+            }\r
+            //Check for collisons\r
+            foreach (Character character in mCharacters)\r
+            {\r
+                foreach (Projectile projectile in mProjectiles)\r
+                {\r
+                    if (projectile.GridX == character.GridX && projectile.GridY == character.GridY)\r
+                    {\r
+                        //Debug - not sure if you can remove while doing for each\r
+                        //Alternative - while loop, and decrement projectile counter if projectile is removed.\r
+                        mProjectiles.Remove(projectile);\r
+                        character.Health -= projectile.Damage;\r
+                    }\r
+                }\r
+            }\r
+        }\r
+\r
+        /// <summary>\r
+        /// This is called when the game should draw itself.\r
+        /// </summary>\r
+        /// <param name="gameTime">Provides a snapshot of timing values.</param>\r
+        public void Draw(SpriteBatch spriteBatch)\r
+        {\r
+            mMap.Draw(spriteBatch);\r
+            foreach(Projectile projectile in mProjectiles)\r
+            {\r
+                projectile.Draw(spriteBatch);\r
+                \r
+            }\r
+            foreach(Character character in mCharacters)\r
+            {\r
+                character.Draw(spriteBatch);\r
+            }\r
+\r
+            \r
+        }\r
+    }\r
+}\r
+\r
This page took 0.027216 seconds and 4 git commands to generate.