]> git.localhorst.tv Git - l2e.git/blob - src/graphics/Sprite.h
merged Point into Vector
[l2e.git] / src / graphics / Sprite.h
1 /*
2  * Sprite.h
3  *
4  *  Created on: Aug 5, 2012
5  *      Author: holy
6  */
7
8 #ifndef GRAPHICS_SPRITE_H_
9 #define GRAPHICS_SPRITE_H_
10
11 #include "../geometry/Vector.h"
12
13 #include <SDL.h>
14
15 namespace graphics {
16
17 class Sprite {
18
19 public:
20         Sprite(SDL_Surface *s, int width, int height, int xOffset = 0, int yOffset = 0)
21         : surface(s), width(width), height(height), xOffset(xOffset), yOffset(yOffset) { }
22
23 public:
24         int Width() const { return width; }
25         int Height() const { return height; }
26         void Draw(SDL_Surface *dest, const geometry::Vector<int> &position, int col = 0, int row = 0) const;
27         void DrawTopRight(SDL_Surface *dest, const geometry::Vector<int> &position, int col = 0, int row = 0) const {
28                 geometry::Vector<int> offset(-Width(), 0);
29                 Draw(dest, position + offset, col, row);
30         }
31         void DrawCenter(SDL_Surface *dest, const geometry::Vector<int> &position, int col = 0, int row = 0) const {
32                 geometry::Vector<int> offset(-Width() / 2, -Height() / 2);
33                 Draw(dest, position + offset, col, row);
34         }
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);
38         }
39
40 private:
41         SDL_Surface *surface;
42         int width;
43         int height;
44         int xOffset;
45         int yOffset;
46
47 };
48
49 }
50
51 #endif /* GRAPHICS_SPRITE_H_ */