| 1 | |
| 2 | /** |
| 3 | * |
| 4 | * @file sprite.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 _SPRITE_H |
| 24 | #define _SPRITE_H |
| 25 | |
| 26 | #include "OpenJazz.h" |
| 27 | |
| 28 | // Class |
| 29 | |
| 30 | struct SDL_Surface; |
| 31 | struct SDL_Color; |
| 32 | |
| 33 | /// Sprite |
| 34 | class Sprite { |
| 35 | |
| 36 | private: |
| 37 | SDL_Surface* pixels; ///< Sprite image |
| 38 | short int xOffset; ///< Horizontal offset |
| 39 | short int yOffset; ///< Vertical offset |
| 40 | |
| 41 | public: |
| 42 | Sprite (); |
| 43 | ~Sprite (); |
| 44 | |
| 45 | void clearPixels (); |
| 46 | void setOffset (short int x, short int y); |
| 47 | void setPixels (unsigned char* data, int width, int height, unsigned char key); |
| 48 | int getWidth (); |
| 49 | int getHeight (); |
| 50 | int getXOffset (); |
| 51 | int getYOffset (); |
| 52 | void draw (int x, int y, bool includeOffsets = true); |
| 53 | void drawScaled (int x, int y, fixed scale); |
| 54 | void setPalette (SDL_Color* palette, int start, int amount); |
| 55 | void flashPalette (int index); |
| 56 | void restorePalette (); |
| 57 | |
| 58 | }; |
| 59 | |
| 60 | #endif |
| 61 |