The collision detection in this game is much more complex than the previous two. For this reason, the code will be quite heavily commented. Sometimes the comments will explain things in a bit more detail or in a slightly different way.
However, that doesn't mean it needs to be hard work. What we need to do is take a moment to consider a strategy that will work for us.
Hopefully, this approach will mean that by the end of the chapter, our collision detection solutions will appear straightforward.
What we are trying to achieve can be put into the following two categories: