Time for action – interacting with zombies
In the
Update()
method of theLevelManager
module, replace theFor Each
loop that updates the_enemies
list entries with the following loop:For x As Integer = _enemies.Count - 1 To 0 Step - 1 _enemies(x).Update(gameTime) If Not _enemies(x).Dead Then If _player.CollisionRectangle.Intersects( _enemies(x).CollisionRectangle) Then If _player.WorldCenter.Y < _enemies(x).WorldLocation.Y Then _player.Jump() _player.Score += 5 _enemies(x).PlayAnimation("die") _enemies(x).Dead = true Else _player.Kill() End If End If Else If Not _enemies(x).Enabled Then _enemies.RemoveAt(x) End If End If Next
In the
Player
class, add a property to hold the lives the player has remaining:Public Property LivesRemaining As Integer = 3
Add the
Kill()
method to thePlayer...