4 * Created on: Aug 5, 2012
8 #ifndef GRAPHICS_SPRITE_H_
9 #define GRAPHICS_SPRITE_H_
11 #include "../geometry/Vector.h"
20 Sprite(SDL_Surface *s, int width, int height, int xOffset = 0, int yOffset = 0)
21 : surface(s), size(width, height), offset(xOffset, yOffset) { }
24 int Width() const { return size.X(); }
25 int Height() const { return size.Y(); }
26 const geometry::Vector<int> &Size() const { return size; }
27 void Draw(SDL_Surface *dest, const geometry::Vector<int> &position, int col = 0, int row = 0) const;
28 void DrawTopRight(SDL_Surface *dest, const geometry::Vector<int> &position, int col = 0, int row = 0) const {
29 geometry::Vector<int> offset(-Width(), 0);
30 Draw(dest, position + offset, col, row);
32 void DrawCenter(SDL_Surface *dest, const geometry::Vector<int> &position, int col = 0, int row = 0) const {
33 Draw(dest, position - (Size() / 2), col, row);
35 void DrawCenterBottom(SDL_Surface *dest, const geometry::Vector<int> &position, int col = 0, int row = 0) const {
36 geometry::Vector<int> offset(-Width() / 2, -Height());
37 Draw(dest, position + offset, col, row);
42 geometry::Vector<int> size;
43 geometry::Vector<int> offset;
49 #endif /* GRAPHICS_SPRITE_H_ */