-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTexture.h
74 lines (66 loc) · 2.86 KB
/
Texture.h
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
63
64
65
66
67
68
69
70
71
72
73
74
//-----------------------------------------------------------------//
// Texture.h //
// The base class for all textures to be rendered on screen //
// Can load full textures, or clipped textures from a spritesheet //
// or convert a string into a texture to be rendered //
// //
// By: Ather Omar //
//-----------------------------------------------------------------//
#ifndef _TEXTURE_H
#define _TEXTURE_H
//---------------------------------------------------------------
#include "GameEntity.h"
#include "AssetManager.h"
//---------------------------------------------------------------
// QuickSDL
//---------------------------------------------------------------
namespace QuickSDL {
//-----------------------------------------------------------
// Texture : public GameEntity
//-----------------------------------------------------------
class Texture : public GameEntity {
protected:
//The SDL_Texture to be rendered
SDL_Texture* mTex;
//Used to render the texture
Graphics* mGraphics;
//Width of the texture
int mWidth;
//Height of the texture
int mHeight;
//True if the texture is loaded from a spritesheet
bool mClipped;
//Is used to render the texture on the screen
SDL_Rect mRenderRect;
//Is used to clip the texture from a spritesheet
SDL_Rect mClipRect;
public:
//--------------------------------------------------------------
//Loads a whole texture from a file (relative to the exe path)
//Note: For spritesheets use the other contructor
//--------------------------------------------------------------
Texture(std::string filename);
//-------------------------------------------------------------
//Loads a texture from from file (relative to the exe path)
//Supports spritesheets
//x - Starting pixel's X on the spritesheet
//y - Starting pixel's Y on the spritesheet
//w - The width of the clipped sprite
//h - The height of the clipped sprite
//-------------------------------------------------------------
Texture(std::string filename, int x, int y, int w, int h);
//------------------------------------------------------------
//Converts the given text into a texture to be rendered
//Note: fontpath is relative to the exe path
//size - The size of the text to be rendered
//color - The color of the text to be rendered
//------------------------------------------------------------
Texture(std::string text, std::string fontpath, int size, SDL_Color color);
~Texture();
//----------------------------------------------
//Called to render the texture to the screen
//----------------------------------------------
virtual void Render();
};
}
#endif