Hi, I would like to know how you would go about building a simple animation system in C with SDL. I don’t want you to do the job for me, what I badly need is high level guidance and to see how experienced people think about this because frankly i’m kind of lost. I’ve only half baked “solutions”, and looking back at what I did clearly showed me the main problem is i’m not sure about what I should build and why.
What may help you to know how to help me is clarifying my goals and my needs:
First, this is for simple 2D frame-based animated games, I plan to have a fair amount of low resolution sprites (nes-snes range resolution) in the whole game (say between 20 and 50) and a few (10 or 15 maybe) small 16*16 pixels tilesets. So what I want to get to is : the loading pattern of
my games would be load everything at the beginning, free everything before terminating the program.
I Would like to have a system (a module) to be able to say : draw this frame of this animation at this position and then the system figures out which part of which texture to copy to the screen at the position specified. I would like the caller code to be freed form thinking about these details (texture pointers, source and destination rectangles and so on). Something like draw_animation(int animation, int frame, int x, int y) - Edit: I’m using the renderer api / graphics card.
I’m also confused about how to define an animation. Should I define them by hand with handmade global tables (table of animations referencing tables of frames)?
Should I define them in disk files that are read by my code to populate tables that start empty / uninitialized ? Should I have functions that I call to add a texture, add an animation, add a frame and
use them at the initialization phase of my program ?.
Also, I’m confused about how to name things so that I could tell to some draw_animation function I write which one I’m talking about ? Enums are nice to use but incompatibles with a system that builds animations based on descriptions in text files on disk for example because the enum is a compile time
thing and the loading happens at run time.
I sometimes think the old programmers (those who pioneered video games), and the dos-era ones etc would have a way more efficient, simple and clever way to think about all of this. Even on the old consoles (It seems like at this time, memory was laid out manually - we cannot do that anymore I know -
but also lots of things were done in a manual and clever way youngster like me ignore. I know we can’t use exactly the same techniques, but the simple, pragmatic spririt… I’m feeling like young people like me (especially if you want to be autonomous and useful) should learn to think like that, and that I’m overcomplicating stuff because I’m missing things that are important and lack knowledge.
I already have books like Game Programming Architecture or the Doom Black Book which are wonderful, helped me a ton for other things, are full of insights but I’m struggling to use them in that case. I see cools useful things and concepts (like resource IDs/handles to be able to move around stuff without breaking things that reference what you move, ways to make sure stuff is not loaded more than one time etc). But I don’t really understand how to think globally about things like resource definition and management for example. Also, these books are about big ass games, and I feel like I need to build my skills with simpler games and that when you are doing simpler things, alone, the nature of the job changes and lots of things don’t apply.
Thank you very much for reading this, if you need any information about what I tried to guide me, just ask. I just figured it would help more to describe what I want because as I said, I’m not sure I actually understand what I should build to get where I want (what I have “works” but is half assed and incoherent).
PS: Also, the more I spend time with SDL, the more I realize how well its made, and how its designed to enable you to think about what you do without standing in your way or making decisions for you (like a framework for example). I would like to help maintain it when I’ll have the skills to do so. You know, give back what was given to me. Not necessarily the place to say it, but I wanted to say it for a long time, so there you go.