Learn Create Your Own Split Screen

Next Page

You might think an easy way to code the actual obstacle code would be something like:

      If the hero is touching an obstacle, don't let the hero move

But this logic contains a fatal flaw.

The problem is that once the hero first touches an obstacle, that logic would mean it can never move away from the obstacle.

D'oh!

Maybe we need some logic like:

      If the hero is touching an obstacle, don't let the hero move unless that move would let it move away from the obstacle

But that sounds really hard.