1 #ifndef GRAPHICS_SPRITE_H_
2 #define GRAPHICS_SPRITE_H_
4 #include "../math/Vector.h"
13 static const int TYPE_ID = 409;
16 Sprite() : surface(0), size(64, 64), offset() { }
17 Sprite(SDL_Surface *s, int width, int height, int xOffset = 0, int yOffset = 0)
18 : surface(s), size(width, height), offset(xOffset, yOffset) { }
21 int Width() const { return size.X(); }
22 int Height() const { return size.Y(); }
23 const math::Vector<int> &Size() const { return size; }
24 void Draw(SDL_Surface *dest, const math::Vector<int> &position, int col = 0, int row = 0) const;
25 void DrawTopRight(SDL_Surface *dest, const math::Vector<int> &position, int col = 0, int row = 0) const {
26 math::Vector<int> offset(-Width(), 0);
27 Draw(dest, position + offset, col, row);
29 void DrawCenter(SDL_Surface *dest, const math::Vector<int> &position, int col = 0, int row = 0) const {
30 Draw(dest, position - (Size() / 2), col, row);
32 void DrawCenterBottom(SDL_Surface *dest, const math::Vector<int> &position, int col = 0, int row = 0) const {
33 math::Vector<int> offset(-Width() / 2, -Height());
34 Draw(dest, position + offset, col, row);
38 void SetSurface(SDL_Surface *s) { surface = s; }
39 void SetSize(const math::Vector<int> &s) { size = s; }
40 void SetOffset(const math::Vector<int> &o) { offset = o; }
42 static void CreateTypeDescription();
43 static void Construct(void *);
47 math::Vector<int> size;
48 math::Vector<int> offset;