mirror of
https://github.com/AlexMacocian/MonoGame.Extended.git
synced 2026-07-26 00:45:20 +00:00
* Created unit test project for collisions. * Started on tests * Created unit test project for collisions. * Started on tests * Update collision test * CollisionInfo docs * More docs for CollisionGrid and Cell * Fix obsolete warning for RectangleF.Intersect * Summary for CollisionGrid and CollisionGridCell * QuadTree collision implemented - Ported from C++ from Game Physics Cookbook chapter 6, 2D Optimizations * Small refactor for QuadTree naming * First tests for QuadTree * Fix test * COde Cleanup * Added DefaultMaxObjectsPerNode * Add missed Query code * Insert Tests and bugfix * Fix bug with QuadTree.Shake * Fix namespaces * Query tests and fix * Additional test for Query * Initial QuadTreeCollision Component * Basic collision demo working * Spikey ball colliding with walls * Improved the collision demo * Update QuadTree * Added comment for CollisionComponent * Ignore test that needs fixed * Rename QuadTree to Quadtree * Fix penetration vector * Update to 2.0 and xUnit
39 lines
1.3 KiB
C#
39 lines
1.3 KiB
C#
using System;
|
|
using Microsoft.Xna.Framework;
|
|
using Xunit;
|
|
|
|
namespace MonoGame.Extended.Collisions.Tests
|
|
{
|
|
/// <summary>
|
|
/// Simple usage tests showing how to use this library.
|
|
/// </summary>
|
|
public class UsageTests
|
|
{
|
|
/// <summary>
|
|
/// This is a basic test to make sure two actors collide in a <see cref="CollisionWorld"/>
|
|
/// </summary>
|
|
[Fact(Skip = "This test currently fails and needs fixed.")]
|
|
public void BasicUsageTest()
|
|
{
|
|
var world = new CollisionWorld(Vector2.Zero);
|
|
var boundingBox = new RectangleF(2, 2, 10, 10);
|
|
|
|
// The two actors are exactly overlapping, so they should collide.
|
|
var actor1 = new BasicActor {BoundingBox = boundingBox};
|
|
var actor2 = new BasicActor {BoundingBox = boundingBox};
|
|
|
|
world.CreateActor(actor1);
|
|
world.CreateActor(actor2);
|
|
|
|
var data = new[] {1, 1};
|
|
world.CreateGrid(data, 2, 1, 10, 10);
|
|
|
|
world.Update(new GameTime(TimeSpan.FromSeconds(0.2), TimeSpan.FromSeconds(0.2)));
|
|
|
|
|
|
// The two actors should have collided.
|
|
Assert.Equal(actor1.CollisionCount, actor2.CollisionCount);
|
|
Assert.Equal(1, actor1.CollisionCount);
|
|
}
|
|
}
|
|
} |