4 * Created on: Aug 5, 2012
8 #ifndef GRAPHICS_SPRITE_H_
9 #define GRAPHICS_SPRITE_H_
11 #include "../geometry/Vector.h"
20 static const int TYPE_ID = 409;
23 Sprite() : surface(0), size(64, 64), offset() { }
24 Sprite(SDL_Surface *s, int width, int height, int xOffset = 0, int yOffset = 0)
25 : surface(s), size(width, height), offset(xOffset, yOffset) { }
28 int Width() const { return size.X(); }
29 int Height() const { return size.Y(); }
30 const geometry::Vector<int> &Size() const { return size; }
31 void Draw(SDL_Surface *dest, const geometry::Vector<int> &position, int col = 0, int row = 0) const;
32 void DrawTopRight(SDL_Surface *dest, const geometry::Vector<int> &position, int col = 0, int row = 0) const {
33 geometry::Vector<int> offset(-Width(), 0);
34 Draw(dest, position + offset, col, row);
36 void DrawCenter(SDL_Surface *dest, const geometry::Vector<int> &position, int col = 0, int row = 0) const {
37 Draw(dest, position - (Size() / 2), col, row);
39 void DrawCenterBottom(SDL_Surface *dest, const geometry::Vector<int> &position, int col = 0, int row = 0) const {
40 geometry::Vector<int> offset(-Width() / 2, -Height());
41 Draw(dest, position + offset, col, row);
45 void SetSurface(SDL_Surface *s) { surface = s; }
46 void SetSize(const geometry::Vector<int> &s) { size = s; }
47 void SetOffset(const geometry::Vector<int> &o) { offset = o; }
49 static void CreateTypeDescription();
50 static void Construct(void *);
54 geometry::Vector<int> size;
55 geometry::Vector<int> offset;
61 #endif /* GRAPHICS_SPRITE_H_ */