Is there any C SDL2 Cookbook, explaining useful things as handling game textures (and other assets) dynamically, game engine multi threading, collision detection with hitboxes, window management, UI and things like that?
I don’t have any problem in write my own tools, but I get myselfm very oftenm writing some tool, then later changing the way things work just because I think it should be better handled in other way.
For example, I think is too verbose to create a texture, then I have created a struct (and some helper functions) to do it for me. Later I noticed I needed also make reference to the
renderer in some texture calls, with that in mind I made my
struct myTexture with a member that points to an associated
SDL_Renderer. AFter that I notice I needed a “textureManager”, then I created a data structure that contains a reference to loaded textures, added “names” and Ids to each texture and also contains a
refCount to each texture. Be able to get a texture by name or by iD (not only with a pointer is the next feature). But now I’m thinking in add the
refCount to texture itself. With that I would be able to have different “textureManagers”, let’s say, one for characters, other to the stage, other to the UI, and I will be able to flush the managers individually, control how much memory each group is using, and other nice features.
In fact, most of time I find myself refactoring data structures once I find new problems to deal with.
Using a cookbook/recipes I could (at least) have a point to start and be a reference, written by someone that already faced larger problems.
I write code only in C, but most of time I’m able to convert C++ code/classes to native C with little effort.