This is a MonoGame 3.8.* sample project that demonstrates rectangle collision detection. The game features a player character that must avoid falling blocks in a simple 2D environment.
The Rectangle Collision Sample showcases:
- Basic 2D sprite rendering
- Rectangle collision detection
- Player input handling (keyboard)
- Random block spawning
- Game state management (collision detection triggers)
The player controls a character that can move left and right using the keyboard. Blocks fall from the top of the screen, and the game detects when the player collides with any block.
✅ Windows - Building and running successfully
✅ DesktopGL - Building and running successfully
✅ Android - Building successfully (requires Android SDK to deploy)
- .NET 10.0 SDK or later
- For iOS: Xcode and Mac development environment
- For Android: Android SDK
RectangleCollisionSample/
│
├── Core/
│ ├── Game1.cs
│ ├── Program.Core.cs
│ ├── RectangleCollisionSample.Core.csproj
│ └── Content/
│ ├── Block.xnb
│ └── Person.xnb
│
├── Platforms/
│ ├── Windows/
│ │ ├── Program.cs
│ │ ├── RectangleCollisionSample.Windows.csproj
│ │ └── app.manifest
│ ├── Desktop/
│ │ ├── Program.cs
│ │ └── RectangleCollisionSample.DesktopGL.csproj
│ ├── Android/
│ │ ├── MainActivity.cs
│ │ ├── RectangleCollisionSample.Android.csproj
│ │ └── AndroidManifest.xml
│ └── iOS/
│ ├── Program.cs
│ ├── RectangleCollisionSample.iOS.csproj
│ └── Info.plist
│
├── .vscode/
│ ├── launch.json
│ └── tasks.json
│
├── RectangleCollisionSample.sln
└── README.md
- Open
RectangleCollisionSample.slnin Visual Studio - Select the desired project under
Platforms/(Windows, Desktop, Android, iOS) as startup project - Build and run (F5)
- Open the project folder in VS Code
- Use Ctrl+Shift+P to open command palette
- Run "Tasks: Run Task" and select:
build-windows,build-desktopgl, orbuild-androidto buildrun-windowsorrun-desktopglto run
- Or use F5 to debug with the configured launch profiles
# Build Windows version
dotnet build Platforms/Windows/RectangleCollisionSample.Windows.csproj
# Run Windows version
dotnet run --project Platforms/Windows/RectangleCollisionSample.Windows.csproj
# Build DesktopGL version
dotnet build Platforms/Desktop/RectangleCollisionSample.DesktopGL.csproj
# Run DesktopGL version
dotnet run --project Platforms/Desktop/RectangleCollisionSample.DesktopGL.csproj
# Build Android version
dotnet build Platforms/Android/RectangleCollisionSample.Android.csproj
# Build iOS version (on Mac)
dotnet build Platforms/iOS/RectangleCollisionSample.iOS.csproj- Left Arrow / A: Move player left
- Right Arrow / D: Move player right
- Escape: Exit game
The project uses pre-built XNB content files located in the Content/ folder:
Person.xnb- Player character spriteBlock.xnb- Falling block sprite
These files are automatically copied to the output directory during build.
- Uses MonoGame 3.8.* NuGet packages instead of source references
- Modern SDK-style project files for all platforms
- Shared source code across all platforms
- Platform-specific configurations and manifests where needed
- No Content Pipeline (.mgcb) file - uses pre-built XNB files directly
- MonoGame.Framework.Windows 3.8.*
- MonoGame.Framework.DesktopGL 3.8.*
- MonoGame.Framework.iOS 3.8.*
- MonoGame.Framework.Android 3.8.*
- MonoGame.Content.Builder.Task 3.8.*