# animatedsprite for SFML This is a (stupid) simple implementation of sprite animation for [SFML](https://www.sfml-dev.org/index.php). It contains two files: - animatedsprite.hpp - animatedsprite.cpp And those are all you need to get going. In the `test/` directory you find a super small program using the animatedsprite provided utlities. ## The Animation File Format Animation files are just simple ASCII text files. See `test/testanimations.txt` as an example. Below the structure of each animation definition is described. Comment lines in the file start with `#` which are ignored, along with empty lines. Each animation starts with: `animation MyAnimationName` Followed by a collection of definition lines: - `frame-origin x y` - Where `x` and `y` are unsigned integers. - Where is the first sprite frame located in the spritesheet. - `frame-size x y` - Where `x` and `y` are unsigned integers. - How big is the sprite frame. - `frame-step x y` - Where `x` and `y` are unsigned integers. - How much the frame needs to be translated every new frame. - Usually identical to your frame-size, but useful for example for skipping every other frame. - `frame-margin x y` - Where `x` and `y` are unsigned integers. - Represents the "empty space" between frames. A lot of spritesheets come with empty space between each sprite frame. This is to prevent frames bleeding into each other. - `frame-count n` - Where `n` is an unsigned integer. - `frame-time n` - Where `n` is an unsigned integer and represents milliseconds. - `reverse` - If present it reverse the animation. - `loop` - If present it loops the animation by going back to the first frame after the last frame has been reached. - `bounce` - If present it loops the animation by going in reverse whenever the last frame has been reached. The actual source code tells you most likely all you need to know: ```cpp unsigned const x = frameOrigin.x + (frameNumber * frameMargin.x) + (frameNumber * frameStep.x); unsigned const y = frameOrigin.y + (frameNumber * frameMargin.y) + (frameNumber * frameStep.y); ``` Where x and y are the topleft coordinates of the sprite frame.