コード例 #1
0
        public void Update(IPhysicsEngineContext world, TimeSpan elapsedTime)
        {
            _collisionEngine.Move(world, elapsedTime);

            foreach (var movableObject in world.GetMovableObjects())
            {
                movableObject.Position = CoordinateSystem.Normalize(movableObject.Position);
            }

            foreach (var movableObject in world.GetMovableObjects())
            {
                _collisionEngine.DetectTouchedBlocks(world, movableObject);
            }

            foreach (var movableObject in world.GetMovableObjects())
            {
                ResetVelocityInBlockedDirections(movableObject);
            }

            foreach (var movableObject in world.GetMovableObjects())
            {
                ApplyGravityIfNotBlocked(movableObject, world.Gravity, elapsedTime);
                ApplyDrag(movableObject, elapsedTime);
            }
        }
コード例 #2
0
 public void Initialize(IPhysicsEngineContext world)
 {
     foreach (var entity in world.GetMovableObjects())
     {
         _collisionEngine.DetectTouchedBlocks(world, entity);
     }
 }