The MonoGame.Extended.Collisions library contains a 2D grid-based collision system.
MonoGame.Extended.Collisions is distributed via a NuGet package. You can add the NuGet package to your C# project through your IDE of choice (Visual Studio, Xamarin Studio, Rider, etc) or through the Command Line Interface (CLI) using the dotnet command.
In this example, we will make a simple sandbox where shapes can move and collide with each other.
We start by defining an
IEntity interface that inherits
ICollisionActor, so we can insert the entities into our
Next, we define our entity classes
OnCollision method and the Bounds property come from the
ICollisionActor interface. These will be called by the
Setting up the game
First, we define our properties and fields
Then we Initialize our game by creating entities and adding them to the
Updating the game
Update method, we update all entities and the