/*************************************** * animation.vc * * author: vecna * * a quick utility library to simplify * * using an 'animation-strip' style * * image in animations. * ***************************************/ /**************************** data ****************************/ #define MAX_ANIMATIONS 16 // Tweak this to your liking! #define NO_INDEX 65535 // This is just a sentinel. struct anim_t { int sizex, sizey; // the width andh height of a single frame of this animation. int numframes; // the total framecount of this animation int active; // the status of this animation (0 means the slot is free for plundering!) int image; // the reference to the base image data. int bufimage; // a new image one frame in size that is a copy of the current frame. int bufferedframe; //.the index of the presently buffered frame. 65535 is a sentinel. }; // Loads an animation from a 'filmstrip'-style file. // it auto-calculates how many frames there are based on the overall image size // and the specific frame size you specify. This does not allow for whitespace // in the base image. // // returns an anims[] index to be used in other functions in this library. int LoadAnimation(string filename, int sizex, int sizey) // Takes an anims[] index. // // frees that slot of the anims[] array, releasing it's data back into the // wild. void FreeAnimation(int index) // Blits the specified frame of the specified animation to (x,y) of Dest. // // This function buffers the frame the first time it blits a new frame for an // image, and continues to blit that buffered image as long as the frame // doesn't change. // // Fatally errors if you attempt to render from an inactive animation. // quietly does nothing if the frame index was invalid for this animation void BlitFrame(int x, int y, int anim, int frame, int dest) // TBlits the specified frame of the specified animation to (x,y) of Dest. // // This function buffers the frame the first time it blits a new frame for an // image, and continues to blit that buffered image as long as the frame // doesn't change. // // Fatally errors if you attempt to render from an inactive animation. // quietly does nothing if the frame index was invalid for this animation void TBlitFrame(int x, int y, int anim, int frame, int dest) // Transparently draws frame #'frame of animation 'anim' onto 'dest' with the frame centered on (x,y) // 'dest' must be a valid v3 image reference. // 'anim' must be a valid animation index, does nothing if invalid. // // Fatally errors if you attempt to render from an inactive animation. // quietly does nothing if the frame index was invalid for this animation void BlitFrameAt(int x, int y, int anim, int frame, int dest) // Transparently draws 'img' onto 'dest' with 'img' centered on (x,y) // 'img' and 'dest' must be valid v3 image references. void BlitAt(int x, int y, int img, int dest)