Exercises
To help you test your knowledge of this chapter's content, here are a few exercises that you should work on. They are not imperative to the rest of the book, but working on them will help you assess your strengths and weaknesses in the material covered:
When calculating pathfinding, we currently do not allow diagonal movement. Update the algorithm so that this is now allowed. To get you started, when calculating the G cost, you'll need to determine whether we moved diagonally or straight.
Currently, the enemies will chase us throughout the entire level. Amend the function so that the enemy will only chase the player if they are within a certain distance.
Currently our enemies move at a fixed speed and don't take into account the speed variable that we generated in an earlier chapter. Incorporate the speed variable in the game so that the enemies move at their correct speeds.