-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSprite.h
More file actions
62 lines (54 loc) · 1.98 KB
/
Copy pathSprite.h
File metadata and controls
62 lines (54 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "ImageCache.h"
#include <SDL2/SDL.h> // Todo: maybe this can be removed? I think imagecache has sdl2/sdl.h
#include <string>
#ifndef SPRITE_H
#define SPRITE_H
/**
* A temporary object used by the Renderer to draw an image onto the screen.
* Sprites render using their positions as their centers.
*/
class Sprite
{
public: // make private
/// Horizontal position of the Sprite's center in the world.
int x;
/// Vertical position of the Sprite's center in the world.
int y;
/// Width of the Sprite
int width;
/// Height of the Sprite
int height;
/// The name of the image file that will be rendered from.
std::string bmpAddress;
/// The pointer of the texture used to render the Sprite.
SDL_Texture *texture;
/// The rect within the image to render to the screen. Must be smaller than or equal to the image dimensions.
SDL_Rect frameRect;
public:
// Phase this one out
Sprite(int _x, int _y, int _width, int _height, std::string bmpAddress, ImageCache *images);
/**
* Construct a new Sprite object.
*
* @param x_ x position in the world
* @param y_ y position in the world
* @param width_ width of the sprite in the world
* @param height_ height of the sprite in the world
* @param frameSize size of the frame within the image file
* @param frameOffset offset of the frame from the top left of the image file
* @param bmpAddress_ name of the image file
* @param images the ImageCache that manages image files
*/
Sprite(int x_, int y_, int width_, int height_, std::pair<int, int> frameSize, std::pair<int, int> frameOffset, std::string bmpAddress_, ImageCache *images);
/// Sprite destructor.
~Sprite();
/**
* Get the SDL_Texture of the Sprite.
*
* @param sdlRenderer the SDL_Renderer that the Sprite will be renderered on
* @param images the ImageCache that manages image files
* @return pointer to the SDL_Texture of the Sprite
*/
SDL_Texture *getTexture(SDL_Renderer *sdlRenderer, ImageCache *images);
};
#endif