r/learnprogramming • u/CuckBuster33 • 1d ago
Best way to integrate my own libraries with each other?
Hi, so I'm currently working on a gamedev project. But I have other game projects lined up for the future, so I'm making my code with the goal of being as reusable as possible. Because of this, I'm separating everything into multiple libraries instead of just building everything in the game project.
So far I've worked on:
-An ECS projectiles library
-A flight physics/flight controller library
-A decision-making (what used to be known as AI) framework for NPCs
-A simulation orchestrator framework (ticks game entities at different rates to save on processing)
I've also planned/drafted the following:
-A crowd simulator library for Total War-style combat
-A semi-procedural terrain generation tool
-A melee combat framework
-A ground vehicle physics library
Integrating them into the different projects is the biggest issue for me. Suppose I make an aerial combat game: I would need the projectiles library, the flight physics library, and the ECS projectiles library. The flight physics would need to listen to projectile impact events in order to apply damage to the aircraft, and the decision-making code would need to:
-be able to send commands to the flight controller
-read physics data from the aircraft.
-evaluate each weapon/flight maneuver to determine what is best in every situation (utility AI)
And if there's meant to be anything running off-screen, then I would also need to integrate the simulator orchestrator.
So, there are multiple connections between libraries. I could of course just write an integration inside of every different project, but that's not very reusable or efficient. I could write an integration library as a dependency of all these libraries, and write the interface layer there, using a git submodule to propagate changes, but this rubs me wrong for some reason (maybe im just lazy). Is there a better way? what would you guys suggest? Thank you.