How meet-patel-2112/gravity-simulation works
Gravity Simulation is an interactive 2D gravity sandbox. The user launches the app, then the main loop dispatches keyboard and mouse input, updates object motion and collisions when unpaused, and renders the objects through OpenGL. The README also describes mass adjustment, launch vectors, attraction, and live mouse coordinates; the sampled input code only shows spawning and pause/exit handling, so those details are treated as documented capabilities rather than verified implementation flows.
Main entry points: main.cpp Main Loop · Renderer.cpp Renderer · InputHandler.cpp Input Handler · PhysicsEngine.cpp Physics Engine
Components 9
Application Runtime
- Main Loop
src/main.cpp
User Input
- Input Handler
src/input/InputHandler.cpp
Simulation
- Simulation Objects
src/simulation/Object.cpp - Physics Engine
src/simulation/PhysicsEngine.cpp
Rendering
- Renderer
src/rendering/Renderer.cpp - Camera
src/rendering/Camera.cpp - Circle Mesh
src/rendering/Mesh.cpp - Shader Program
src/rendering/Shader.cpp
Other components
- User
Connections 10
- User → Main Loop: launches
README.md - Main Loop → Input Handler: dispatches input
src/main.cpp - Input Handler → Simulation Objects: spawns
src/input/InputHandler.cpp - Main Loop → Physics Engine: updates and checks
src/main.cpp - Physics Engine → Simulation Objects: updates and collides
src/simulation/PhysicsEngine.cpp - Main Loop → Shader Program: uses program
src/main.cpp - Main Loop → Renderer: renders objects
src/main.cpp - Renderer → Camera: gets view matrix
src/rendering/Renderer.cpp - Renderer → Circle Mesh: draws circles
src/rendering/Renderer.cpp - Renderer → Shader Program: sets uniforms
src/rendering/Renderer.cpp