From 28083981691edbfba1d85f0fa6711f70a4e97ed0 Mon Sep 17 00:00:00 2001 From: Kyle Date: Mon, 19 Apr 2010 04:04:22 +0000 Subject: [PATCH] Fixed a bug with projectiles - they would go through walls sometimes. git-svn-id: https://bd85.net/svn/cs3505_group@104 92bb83a3-7c8f-8a45-bc97-515c4e399668 --- CarFire/CarFire/CarFire/Display.cs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/CarFire/CarFire/CarFire/Display.cs b/CarFire/CarFire/CarFire/Display.cs index d40c7e8..ee694fa 100644 --- a/CarFire/CarFire/CarFire/Display.cs +++ b/CarFire/CarFire/CarFire/Display.cs @@ -107,16 +107,20 @@ namespace CarFire mMap.CenterCell = new Vector2(mCharacters[0].GridX, mCharacters[0].GridY); #endif - + //Handle projectiles - update and check for wall collisions for (int i = 0; i < mProjectiles.Count; i++ ) { - mProjectiles[i].Update(timespan); + bool removed = false; if (!mMap.IsCellOpen(new Point(mProjectiles[i].GridX, mProjectiles[i].GridY))) { mProjectiles.RemoveAt(i); + removed = true; i--; } + if(!removed) + mProjectiles[i].Update(timespan); + } //Check for collisons for (int j = 0; j < mCharacters.Length; j++) @@ -153,6 +157,17 @@ namespace CarFire mMap.CenterCell = new Vector2(mCharacters[0].GridX, mCharacters[0].GridY); } } + //Handle wall collisions of projectiles again... + for (int i = 0; i < mProjectiles.Count; i++) + { + if (!mMap.IsCellOpen(new Point(mProjectiles[i].GridX, mProjectiles[i].GridY))) + { + + mProjectiles.RemoveAt(i); + i--; + } + + } } /// -- 2.45.2