|
|
3 сар өмнө | |
|---|---|---|
| .. | ||
| .config | 3 сар өмнө | |
| .vscode | 3 сар өмнө | |
| Core | 3 сар өмнө | |
| Platforms | 3 сар өмнө | |
| PerPixelCollisionSample.sln | 3 сар өмнө | |
| README.md | 3 сар өмнө | |
This is a MonoGame sample that demonstrates per-pixel collision detection between sprites. The game features a person character that can be moved around the screen while blocks fall from the top. When the person touches a block, a collision is detected using per-pixel accuracy rather than simple bounding box collision.
PerPixelCollisionSample/
│
├── Core/
│ ├── Game1.cs
│ ├── Content/
│ ├── GameThumbnail.png
│ └── PerPixelCollisionSample.Core.csproj
│
├── Platforms/
│ ├── Windows/
│ │ ├── PerPixelCollisionSample.Windows.csproj
│ │ └── app.manifest
│ ├── Desktop/
│ │ └── PerPixelCollisionSample.DesktopGL.csproj
│ ├── Android/
│ │ ├── PerPixelCollisionSample.Android.csproj
│ │ ├── Program.cs
│ │ ├── AndroidManifest.xml
│ │ └── Resources/
│ └── iOS/
│ ├── PerPixelCollisionSample.iOS.csproj
│ ├── Program.cs
│ └── Info.plist
│
├── PerPixelCollisionSample.sln
├── README.md
└── .vscode/
Platforms:
Platforms/Windows/PerPixelCollisionSample.Windows.csproj) - Uses MonoGame.Framework.WindowsDXPlatforms/Desktop/PerPixelCollisionSample.DesktopGL.csproj) - Cross-platform OpenGL versionPlatforms/iOS/PerPixelCollisionSample.iOS.csproj) - iOS version targeting net8.0-iosPlatforms/Android/PerPixelCollisionSample.Android.csproj) - Android version targeting net8.0-androiddotnet build Platforms/Windows/PerPixelCollisionSample.Windows.csproj
dotnet run --project Platforms/Windows/PerPixelCollisionSample.Windows.csproj
dotnet build Platforms/Desktop/PerPixelCollisionSample.DesktopGL.csproj
dotnet run --project Platforms/Desktop/PerPixelCollisionSample.DesktopGL.csproj
dotnet build Platforms/Android/PerPixelCollisionSample.Android.csproj
dotnet build Platforms/iOS/PerPixelCollisionSample.iOS.csproj
Open PerPixelCollisionSample.sln in Visual Studio and build/run the desired platform target.
This project includes VS Code configuration files:
Build Tasks: Use Ctrl+Shift+P → "Tasks: Run Task" and select:
build-windows - Build Windows versionbuild-desktopgl - Build DesktopGL versionbuild-android - Build Android versionbuild-ios - Build iOS versionRun/Debug: Use F5 or the Debug panel to run:
The sample demonstrates how to implement per-pixel collision detection by:
The project uses pre-built .xnb content files located in the Content/ folder:
Block.xnb - The falling block texturePerson.xnb - The player character textureThese files are automatically copied to the output directory and loaded at runtime.
Platforms/iOS/Platforms/Android/All platforms use MonoGame 3.8.* NuGet packages:
MonoGame.Framework.WindowsDXMonoGame.Framework.DesktopGLMonoGame.Framework.iOSMonoGame.Framework.Android