| 1 | |
| 2 | /** |
| 3 | * |
| 4 | * @file anim.h |
| 5 | * |
| 6 | * Part of the OpenJazz project |
| 7 | * |
| 8 | * @par History: |
| 9 | * - 23rd August 2005: Created OpenJazz.h |
| 10 | * - 31st January 2006: Created level.h from parts of OpenJazz.h |
| 11 | * - 19th March 2009: Created sprite.h from parts of level.h |
| 12 | * - 26th July 2009: Created anim.h from parts of sprite.h |
| 13 | * |
| 14 | * @par Licence: |
| 15 | * Copyright (c) 2005-2013 AJ Thomson |
| 16 | * |
| 17 | * OpenJazz is distributed under the terms of |
| 18 | * the GNU General Public License, version 2.0 |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | |
| 23 | #ifndef _ANIM_H |
| 24 | #define _ANIM_H |
| 25 | |
| 26 | |
| 27 | #include "OpenJazz.h" |
| 28 | |
| 29 | // Classes |
| 30 | |
| 31 | class Sprite; |
| 32 | struct SDL_Color; |
| 33 | |
| 34 | /// Animation |
| 35 | class Anim { |
| 36 | |
| 37 | private: |
| 38 | Sprite** sprites; ///< Sprite images |
| 39 | signed char* xOffsets; ///< Horizontal offsets for each frame |
| 40 | signed char* yOffsets; ///< Vertical offsets for each frame |
| 41 | signed char shootX; ///< Bullet generation x-coordinate |
| 42 | signed char shootY; ///< Bullet generation y-coordinate |
| 43 | signed char accessoryX; ///< Accessory animation x-coordinate |
| 44 | signed char accessoryY; ///< Accessory animation y-coordinate |
| 45 | signed char yOffset; ///< Vertical offset |
| 46 | unsigned char frames; ///< Number of frames |
| 47 | unsigned char frame; ///< Current frame |
| 48 | unsigned char accessory; ///< Number of an animation that is an accessory to this animation |
| 49 | ///< Most of the time accessories are used with guardians. |
| 50 | |
| 51 | Anim(const Anim&); // non construction-copyable |
| 52 | Anim& operator=(const Anim&); // non copyable |
| 53 | |
| 54 | public: |
| 55 | Anim (); |
| 56 | ~Anim (); |
| 57 | |
| 58 | void setData (int length, signed char sX, signed char sY, signed char aX, signed char aY, unsigned char a, signed char y); |
| 59 | void setFrame (int nextFrame, bool looping); |
| 60 | void setFrameData (Sprite *frameSprite, signed char x, signed char y); |
| 61 | int getWidth (); |
| 62 | int getHeight (); |
| 63 | int getLength (); |
| 64 | fixed getShootX (); |
| 65 | fixed getShootY (); |
| 66 | fixed getAccessoryShootX (); |
| 67 | fixed getAccessoryShootY (); |
| 68 | fixed getOffset (); |
| 69 | fixed getXOffset (); |
| 70 | fixed getYOffset (); |
| 71 | void draw (fixed x, fixed y, int accessories = 7); |
| 72 | void drawScaled (fixed x, fixed y, fixed scale); |
| 73 | void setPalette (SDL_Color *palette, int start, int amount); |
| 74 | void flashPalette (int index); |
| 75 | void restorePalette (); |
| 76 | |
| 77 | }; |
| 78 | |
| 79 | #endif |
| 80 |