I was just curious what fellow programmers have been doing for structuring their code. I’m always looking for ideas for better coding in C. I’ve grown up on C++ and other object oriented languages, as I’m sure others have here, so my use of plain C could probably use some guidance. I’m hoping others will find these chats to be useful, and be able contribute their own ideas or questions to help make everyone’s code better.
Anyway to start, how are others setting up their ‘objects’? And by objects, I mean general interactive entities such as coins, items, enemies, characters, etc.
Currently I have a chunk of memory space I carve out at the start of the cart RAM (0x06000000) and setup an array of ‘objects’ (structs containing things like location, health, sprite information, etc.) To manage these objects I plan to use two lists to keep track of them. One being a ‘in-use list’, which those objects get processed for updates. While the other list is an ‘unused list’. Any objects instantiated will take the next free object from the unused list, while any active ones that get deactivated will return to this unused list. I haven’t made the lists yet, but I plan to use a singly linked list with pointers to the objects inside.
So far it works nicely. I have a camera, a player, and a stationary object setup. But I’m unsure if it’s a good path to be going down.
What do you guys think of this? Any recommendations?