- Kotlin 100%
|
|
||
|---|---|---|
| .idea | ||
| diagrams | ||
| src | ||
| .gitignore | ||
| LICENSE | ||
| pom.xml | ||
| README.md | ||
Fhysics
This project is a physics engine implemented in Kotlin. It provides functionality for movement, rotation and collision detection of rigid-bodies in a 2D environment. The engine is designed to be customizable at runtime through the provided user interface.
Table of Contents
Status
This project is completed. The engine is fully functional and can be used to simulate physics in a 2D environment.
Future updates may include additional features, optimizations and bug fixes.
Features
- Object collisions considering friction, rotation, and elasticity
- Border collisions considering friction, rotation, and elasticity
- Gravity (directional or towards a point)
- Various shapes (circle, rectangle, convex and concave polygons)
- QuadTree data structure for efficient collision detection
- Real-time simulation and visualization
- Customizable physics parameters (e.g., gravity strength/direction; collision elasticity & friction coefficients ( per object); ...)
- User interface for easier interactions and visual elements
- Debug visuals for debugging and deeper insights of the inner workings of the engine
- Camera controls for panning and zooming
Why the Name?
As a big Star Wars fan, I initially wanted to call it "Force-Physics," but that felt too lengthy. Inspired by NVIDIA's "PhysX" engine, I decided to shorten it while maintaining the phonetic sound of "physics." Hence, "Fhysics" was born.
Controls
Mouse
LeftClick: Spawn circle/rectangle (when in circle/rectangle creation mode)LeftClick: Add vertex to polygon (when in polygon creation mode)LeftClick + Drag: Create rectangle from start point to release point (when in rectangle creation mode)LeftClick + Drag (on object): Drag the object with the mouseLeftClick (on object): Select objectRightClick: Reset polygon creationRightClick + Drag: Pan cameraScroll: Zoom camera
Keyboard
P: Toggle simulation pause/playEnter: Step the simulation forward (when paused)S: Print selected object detailsDelete: Remove selected objectZ: Reset camera zoom and positionH: Decrease QuadTree capacity by 1J: Decrease QuadTree capacity by 5K: Increase QuadTree capacity by 5L: Increase QuadTree capacity by 1Q: Print QuadTree structure
Screenshots
![]() |
![]() |
![]() |
![]() |
Special Thanks
- Chris Hecker for his amazing articles on rigid-body dynamics
- Two-Bit Coding for guidance with his series when I was stuck
License
This project is licensed under the terms of the MIT license. See the LICENSE file for the full information.



