tanis
I noticed that in Handmade Hero the entities code (just to pick one as an example) resides in the gameplay DLL.
I've been thinking about the architecture of my own engine and I'd rather have all the entity management system in the core or the engine so that in the end I can reuse that for a new game and just write the game specific parts in the DLL.
If I opt to do something like that I guess I'll have to expose the core entity management functions to the game code DLL in a way similar to how the platform API is exposed and that would force to create as many typedefs as the functions that I want to let the game code DLL call. Is this the only way to achieve something like that?
Cheers!
ratchetfreak
Problem with that is that most of the code concerning entities will depend on the size of the entity struct. So any time you change the entity struct you will need to recompile the platform layer as well.
ratchetfreak
The platform layer is meant to be a thin shim between the kernel and the game. The reason for them to be separate binaries is to assist in live code editing. There is no real reason to pull the entity code out of the game dll.
If you want to reuse the code in future projects then you only need to make sure the code to be reused is grouped in a logical set of files.
tanisratchetfreak
Problem with that is that most of the code concerning entities will depend on the size of the entity struct. So any time you change the entity struct you will need to recompile the platform layer as well.
True, but my entity is just going to be an id (integer). The system is going to hold an array (or hashmap) that holds a connection between the id and the pointer to the actual structure of the entity. But the structure is going to be defined in the game code DLL but allocated through the platform Memory object still.
The rest of the system is just functions to iterate over the entities or manipulate them (like get the components or stuff like that).
Of course if the struct of the entity changes, hot reloading won't help as all the pre-existing entities would be invalid. But that would happen even if all the entity stuff lived in the game code DLL.
tanis
ratchetfreak
The platform layer is meant to be a thin shim between the kernel and the game. The reason for them to be separate binaries is to assist in live code editing. There is no real reason to pull the entity code out of the game dll.
If you want to reuse the code in future projects then you only need to make sure the code to be reused is grouped in a logical set of files.
While I can agree to some extent about the reuse (even though I'd rather have common code in a library instead of copy & pasting it around), I am more concerned about the time it takes to recompile a project that isn't just a couple of files. Once the game code base grows, recompiling on the fly is going to take more and more time until it's like recompiling everything from scratch and it sort of defeats one part of the purpose of hot reloading which si making the iteration times quick, wouldn't it?
ratchetfreak
HMH only took a second to compile (if that) even at the very end. That was a full from scratch compile. And the entity system really isn't that large to begin with.
tanis
So, let's say that I keep all the entity related code, along with all the other systems together in the game code DLL. If you're right then compile time isn't going to be an issue, so let's rule that out.
Let's go back to structs instead. What happens if the struct of an entity changes? Those that have been created before the change would need to be invalidated and/or the whole executable should reload and start from scratch, or at the very least call some initialization function to recreate the current level or whatever the main environment of the game is.
Would there be any better way to manage this kind of changes?
pragmatic_hero
This is why I gravitate towards TCC, as with it I can recompile/hotswap everything at >30FPS.
And the compile times are increasing very, very slowly.
pragmatic_hero
This is fairly easy to do in Dlang and modern pascal dialects (both have fairly fast compilers)
pragmatic_hero
It would be really easy to do in JAI as it has fast compiler + metadata + compile time execution. I wouldn't be surprised if John had some sort of system in the works for his games which hotswaps everything (including datastructs) in way less than a second.
Hell, if he gets rid of the slow MS linker and puts on fast codegen I'm sure JAI could also do *interactive framerates* hotswapping. It would be really cool.