]> Dogcows Code - chaz/carfire/commitdiff
Fixed a bug with projectiles - they would go through walls sometimes.
authorKyle <Kyle@92bb83a3-7c8f-8a45-bc97-515c4e399668>
Mon, 19 Apr 2010 04:04:22 +0000 (04:04 +0000)
committerKyle <Kyle@92bb83a3-7c8f-8a45-bc97-515c4e399668>
Mon, 19 Apr 2010 04:04:22 +0000 (04:04 +0000)
git-svn-id: https://bd85.net/svn/cs3505_group@104 92bb83a3-7c8f-8a45-bc97-515c4e399668

CarFire/CarFire/CarFire/Display.cs

index d40c7e80c87d928b29394791d8b46c1bcacd5ffe..ee694fa5a19d7c1f6834393ea499626a30c306c2 100644 (file)
@@ -107,16 +107,20 @@ namespace CarFire
             mMap.CenterCell = new Vector2(mCharacters[0].GridX, mCharacters[0].GridY);\r
 #endif\r
             \r
-            \r
+            //Handle projectiles - update and check for wall collisions\r
             for (int i = 0; i < mProjectiles.Count; i++ )\r
             {\r
-                mProjectiles[i].Update(timespan);\r
+                bool removed = false;\r
                 if (!mMap.IsCellOpen(new Point(mProjectiles[i].GridX, mProjectiles[i].GridY)))\r
                 {\r
                \r
                     mProjectiles.RemoveAt(i);\r
+                    removed = true;\r
                     i--;\r
                 }\r
+                if(!removed)\r
+                mProjectiles[i].Update(timespan);\r
+                \r
             }\r
             //Check for collisons\r
             for (int j = 0; j < mCharacters.Length; j++) \r
@@ -153,6 +157,17 @@ namespace CarFire
                     mMap.CenterCell = new Vector2(mCharacters[0].GridX, mCharacters[0].GridY);\r
                 }\r
             }\r
+            //Handle wall collisions of projectiles again...\r
+            for (int i = 0; i < mProjectiles.Count; i++)\r
+            {\r
+                if (!mMap.IsCellOpen(new Point(mProjectiles[i].GridX, mProjectiles[i].GridY)))\r
+                {\r
+\r
+                    mProjectiles.RemoveAt(i);\r
+                    i--;\r
+                }          \r
+\r
+            }\r
         }\r
 \r
         /// <summary>\r
This page took 0.028492 seconds and 4 git commands to generate.