4 * Created on: Aug 5, 2012
8 #ifndef GRAPHICS_SPRITE_H_
9 #define GRAPHICS_SPRITE_H_
11 #include "../geometry/Vector.h"
20 Sprite() : surface(0), size(64, 64), offset() { }
21 Sprite(SDL_Surface *s, int width, int height, int xOffset = 0, int yOffset = 0)
22 : surface(s), size(width, height), offset(xOffset, yOffset) { }
25 int Width() const { return size.X(); }
26 int Height() const { return size.Y(); }
27 const geometry::Vector<int> &Size() const { return size; }
28 void Draw(SDL_Surface *dest, const geometry::Vector<int> &position, int col = 0, int row = 0) const;
29 void DrawTopRight(SDL_Surface *dest, const geometry::Vector<int> &position, int col = 0, int row = 0) const {
30 geometry::Vector<int> offset(-Width(), 0);
31 Draw(dest, position + offset, col, row);
33 void DrawCenter(SDL_Surface *dest, const geometry::Vector<int> &position, int col = 0, int row = 0) const {
34 Draw(dest, position - (Size() / 2), col, row);
36 void DrawCenterBottom(SDL_Surface *dest, const geometry::Vector<int> &position, int col = 0, int row = 0) const {
37 geometry::Vector<int> offset(-Width() / 2, -Height());
38 Draw(dest, position + offset, col, row);
42 void SetSurface(SDL_Surface *s) { surface = s; }
43 void SetSize(const geometry::Vector<int> &s) { size = s; }
44 void SetOffset(const geometry::Vector<int> &o) { offset = o; }
46 static void CreateTypeDescription();
47 static void Construct(void *);
51 geometry::Vector<int> size;
52 geometry::Vector<int> offset;
58 #endif /* GRAPHICS_SPRITE_H_ */