From 5a6b712e26f19a5e55aeb5f2efac1125a209f4a5 Mon Sep 17 00:00:00 2001 From: timotei Date: Thu, 15 Sep 2011 21:33:46 +0300 Subject: [PATCH] Remove projectile when it hit something --- egp_story/Player.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/egp_story/Player.cs b/egp_story/Player.cs index cfb9fff..b69c1e4 100644 --- a/egp_story/Player.cs +++ b/egp_story/Player.cs @@ -191,13 +191,19 @@ public void Update( LevelMap levelMap, GameTime gameTime ) for ( int i = 0; i < tmpArray.Length; ++i ) { Projectile projectile = tmpArray[i]; projectile.Animation.Update( gameTime ); - projectile.Position += projectile.Velocity * 5; + Rectangle projectileBox = projectile.Animation.FrameBoundingBox; + projectileBox.Offset( ( int ) projectile.Position.X, ( int ) projectile.Position.Y ); + if ( !levelMap.Mask.Bounds.Contains( ref projectile.Position ) ) { // remove this _projectilesShot.Dequeue( ); } + else if ( !levelMap.CheckRectangleBounds( projectileBox ) ) { + //TODO: add hit animation + _projectilesShot.Dequeue( ); + } } }