I am working on an animation system and have an animation format and everything made. I am storing the animation database in an array (unsigned char). There are two ways I just can't choose between.
Frame return_frame(unsigned int animation_number, unsigned char frame_number) {
Frame out;
// Array here (unsigned char) containing animation database.
// Code here that applies rotations to the variable, "out," from the frame, "frame_number," of the animation, "animation_number."
return(out); }
I would have to call the above function each time I wanted to draw a frame. There are no global variables being used here as the database is declared each time the function is called.
The other method was to have a variable type, "Animation," which has a Frame variable in it named "frame." All animations would be declared globally and part of the program would loop through the database and fill them.
Which is more effective? Should I go with using a function each time that returns a frame or should I have all animations and their frames already loaded in memory? Either way, I am going to be using a function that combines different parts of different frames and returns a frame, if that information is useful.
Also, should I have an animation table that points to the start of each animation relative to the start of the animation database so the return_frame function does not have to go through and look for the "End Animation" command however many times in order to get to the animation that it is looking for or what? Should the same be done for frames? Does it matter?
Thank you! :)