Skip to content

Box2D simulation for Newton's law of universal gravitation

License

Notifications You must be signed in to change notification settings

mdoradom/Box2D-Gravity

Repository files navigation

Box2D-Gravity

This project is a Box2D simulation that implements Newton's law of universal gravitation to simulate gravitational forces between dynamic bodies. It is developed as a project for the Physics 2 class at CITM University.

Overview

The main goal of this project, created for the Physics 2 class at CITM University, is to showcase the behavior of gravitational forces using Box2D's physics engine. The simulation involves creating a 2D environment where dynamic bodies interact with each other based on the gravitational pull they exert on one another.

Example

Box2D Gravity Simulation

Caption: Example of the Box2D Gravity Simulation in action.

Features

  • Simulation of Gravitational Forces: Bodies within the simulation interact with each other according to Newton's law of universal gravitation.
  • Box2D Integration: Utilizes Box2D, a popular 2D physics engine, for handling the physics simulation.
  • Visualization: Provides visualization of bodies and their interactions within the simulation.

Setup

To run this project locally:

  1. Dependencies: Ensure you have the necessary dependencies installed.
  2. Build: Build the project using the provided build system or IDE.
  3. Run: Execute the simulation to observe the gravitational interactions between bodies.

Usage

  • F1: Activate / Deactivate debug mode
  • 1: Spawn planet on mouse position
  • 2: Spawn crate (debug purpouses)
  • 3: Spawn chain (debug purpouses)
  • Left Click: drag bodies (only if debug mode is ON)

References

Additional Resources

Download

You can download the source code and executable from the Releases section.

Contributing

Contributions are welcome! Feel free to fork the project, make improvements, and submit pull requests.

License

This project is licensed under the MIT License.