In this tutorial series, we are going to discuss two different methods of collision detection used in 2D games. These methods are
- Axis-Aligned Bounding Box
- Circle Collision
As we discuss each of these methods, we're going to create an implementation of them in a new MonoGame 3.8 game project.
The following are the prerequisites if you plan to follow along with this tutorial in code.
- MonoGame 3.8
- The code has not been tested against MonoGame 3.7.1. It should still function the same, however no guarantees are given.
- A new game project
- This tutorial starts with a fresh MonoGame Cross-Platform Desktop Application (OpenGL) project.
Due to the size of this tutorial, I have opted to break it down into smaller pages. At the bottom of each page in this tutorial, you'll find a button to click which will take you to the next page in the series, or the previous page if you wish to go back one.
Users using a desktop or larger screen device can use the side bar on the left to jump to different pages within the tutorial. There is also a table of contents on the left of each page if you wish to jump to a difference section in a page.
users using a mobile device can use the side bar that would normally be on the left by clicking the menu button positioned in the bottom right corner of your screen. Due to the limited screen real estate of a mobile device, no table of contents for each page will appear.
You can find the completed version of the project created with this demo at https://github.com/manbeardgames/monogame-collision-detection-demo
All code written in this Collision Detection tutorial series, unless otherwise stated, is licensed under The Unlicense. This license extends to only the code written, not the tutorial documentation. The license text is as follows:
With all of that out of the way, let's jump to the next page in the tutorial.