Welcome to the forum, Nick2017.
Nick2017 wrote:I would like to know how are the objects (kid, guards, spikes, etc.) of the game animated.
The first thing to keep in mind is that MININIM uses the
Allegro low-level game programing library. It's really the only non-trivial dependency of MININIM. Allegro (and the standard C library, of course) is the interface MININIM uses to interact with almost anything in the system. Therefore, the way that library is designed determines to a reasonable extent how MININIM handles its tasks, specially the low level ones. Fortunately, it's a well designed library.
Said that, the core module you are looking for is the animation module "anim.c". It handles several tasks related to animation, but its main (primordial) function is play_anim.
Code: Select all
void play_anim (void (*draw_callback) (void), void (*compute_callback) (void))
Within that function you'll find the application main event processing loop. The parameters of that function are generic callbacks for drawing and computing whatever is needed. Callers should provide both routines (or pass NULL, in case one isn't needed), and play_anim takes care of when and how to call them. The function play_anim is a generic routine; it's used for both cutscene and in-level animations. The first thing you have to ask yourself is which of them are you primarily interested in. They have similarities, but many differences too. For in-level animations, play_anim is called by play_level (level.c). Studying its provided callbacks along with play_anim is a good starting point.
Nick2017 wrote:Is there some kind of timer that count's CPU cycles so that when certain amount of cycles passed the next frame of the animation is displayed?
MININIM uses
Allegro timers for that. The main timer which determines the game's so called "time cycles" is pointed by the global variable timer of the anim.c module. However, Allegro timers are a concept that pretty much only the animation module knows about. The flow of time for the rest of the game (character actions, level physical events, ...) is governed by the global variable anim_cycle (uint64_t), which is incremented at each tick of the animation timer.
Nick2017 wrote:also, how are the frames and objects loaded into memory? using arrays? linked-lists?
For each character action there is a "struct frameset" array in its respective module (basically one module per action), that holds the bitmaps of each frame of animation and their "standard" relative offsets.
Almost all MININIM types are defined in the types.h header. Look there for exactly what a "struct frameset" is, and then look into an action module, like "kid/kid-run.c" (which governs the kid's running animation and logic), for a practical understanding of how they are used.
Good luck with your MININIM source code study! Let me know any further questions you might have.
PS 0: Let's take this in homeopathic doses. I could go on and on, rambling about things...
I'll just give you some initial pointers and thoughts (cause time won't allow me to write too much in one take). You can look things yourself based on what I've told you and/or ask specific questions about what you want to know. I know initially, while you are trying to get started and wrapping your head around it, it's difficult to formulate specific questions. However, keep always in mind that the more specific the better (for everybody).
It's very hard to understand and to make yourself understood speaking in an abstract manner. The devil in the details.
PS 1: Debugging MININIM with
GDB is a very good way to learn how MININIM works from the inside out.