Managing Collisions Using Operators and Observables
Learn to emit values through the takeWhile operator.
We'll cover the following...
We'll cover the following...
When a shot hits an enemy, we want both the shot and the enemy to disappear. Let’s define a helper function to detect whether two targets have collided or not:
Now, let’s modify the helper function paintHeroShots to check whether each shot hits an enemy or not. For cases where a hit occurs, we’ll set a property isDead to true on the enemy that has been hit, and we’ll set the coordinates of the shot ...