Code-Only Velcro Projects
Last updated
Last updated
The Velcro (formerly Farseer) Physics Engine is a .NET library which can be used to add more advanced physics beyond what is offered by FlatRedBall's shapes (such as Circle or Rectangle). Note that the Github page for Velcro states that sponsorship is required to use Velcro Physics in a commercial project, so consider this if you plan on selling your game.
In general, the following must be done to use Velcro Physics:
Instantiate a World object
Call the World instance's Step function every frame
Create one or more Body instances - A Body is created through Velcro's Factory classes. The Body must be added to the World.
Set properties on the Body instances - You can set properties such as size, orientation, velocity, and how the bodies respond to collisions (inertia, elasticity, friction).
This demo will create two Body instances which will perform the physics simulation. It also creates a FlatRedBall Circle and Polygon to display the visuals of the Velcro bodies.
To add Velcro to your project:
Expand your game project's Dependencies
Right-click on Packages and select Manage NuGet Packages...
Check the Include prerelease option
Search for GenBox.VelcroPhysics.MonoGame
Add the Genbox.VelcroPhysics.MonoGame package to your project.
Once you have added Velcro to your project, you can begin using the classes to perform physics simulations. The following is example code which could be added to a GameScreen to create a simple Velcro simulation: