public override void Update(FrameEvent evt) { Animate(evt); remove = isCollidingWith("Player"); if (remove) { score.Increase(increase); } // Collision detection with the player goes here // (ignore until week 8) ... }
public bool IsCollidingWith(string objName) { bool isColliding = false; foreach (Contacts c in physObj.CollisionList) { if (c.colliderObj.ID == objName || c.collidingObj.ID == objName) { isColliding = true; score.Increase(increase); Dispose(); break; } } return(isColliding); }
public void Update(FrameEvent evt) { Animate(evt); remove = isCollidingWith("CannonBall"); if (!remove) { remove = isCollidingWith("Bomb"); } if (remove) { score.Increase(increase); } touchesPlayer = isCollidingWith("Player"); if (touchesPlayer) { if (shield.Value > 0) { shield.Decrease(35); } else { health.Decrease(30); } score.Decrease(35); } if (health.Value <= 0) { lives.Decrease(1); if (lives.Value > 0) { health.Reset(); } } // Collision detection with the player goes here // (ignore until week 8) ... }