How ktitaro/pico-physics works
Main Components
• Library Core (src): This is the heart of the library and can be subdivided further:
• Helpers (src/helpers): Utility modules such as mathematical functions (vec2.lua, math.lua), conversion helpers (conv.lua), and SAT (separating axis theorem) specific methods (sat2.lua). These modules provide the low-level math and conversions needed for physics calculations.
• Physics (src/physics): Contains core physics components including handling of physics "bodies" (body.lua) and possibly the definition of areas or regions affected by physics (area.lua).
• Demo (demo): Provides example code demonstrating how to use the physics library in practice. This includes files for a demo game (demo.p8, game.lua, player.lua, things.lua) that likely instantiate and interact with the physics system.
• Assets (assets): Contains supplementary images (logo.png, demo.gif) that clarify the branding and provide visual confirmation of how the library should look and behave.
Relationships and Interactions
• The Toolbox (debug) is used to monitor or update the physics simulation during runtime, perhaps even within the demo environment.
• The Assets give visual cues and identity to the library, reinforcing the branding (e.g., logo and demo animation).
Highlighting Architectural Patterns and Design Principles
• Separation of Concerns: The demo code is kept separate from the library code ensuring clarity between using and implementing the physics simulation.
• Reusability: The helpers and toolbox providing cross-cutting functionality suggest utility functions are designed to be reused across various parts of the system.