-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgraphics.h
102 lines (85 loc) · 1.58 KB
/
graphics.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#ifndef GRAPHICS_H
#define GRAPHICS_H
#include <string>
#include <vector>
#include "allegro_lib.h"
#include "color.h"
#include "entity.h"
using namespace std;
class Graphics
{
public:
static Graphics& Instance()
{
static Graphics instance;
return instance;
}
~Graphics()
{
};
enum Sprite
{
SPRITE_NONE,
SPRITE_ICON,
SPRITE_BACKGROUND1,
SPRITE_BACKGROUND2,
SPRITE_BACKGROUND3,
SPRITE_NET,
SPRITE_PLAYER1,
SPRITE_PLAYER2,
SPRITE_PUPIL,
SPRITE_OPPONENT1,
SPRITE_OPPONENT2,
SPRITE_OPPONENT3,
SPRITE_POINT,
SPRITE_POINT_P1,
SPRITE_POINT_P2,
SPRITE_POINT_O1,
SPRITE_POINT_O2,
SPRITE_POINT_O3,
SPRITE_BALL,
SPRITE_LENGTH
};
enum Align
{
ALIGN_LEFT,
ALIGN_CENTER,
ALIGN_RIGHT
};
void LoadFonts();
void LoadSpriteCache();
void UnLoadFonts();
void UnLoadSpriteCache();
void ExecuteDraws();
void ClearScreen();
void SetBackground(Sprite sprite);
void DrawBackground();
void DrawBitmap(Sprite sprite, float dx, float dy, float cx = 0, float cy = 0);
void DrawString(std::string str, float dx, float dy, Color c, Align align);
private:
typedef struct Txt
{
std::string str;
float dx;
float dy;
Color c;
Graphics::Align align;
} Txt;
AllegroLib* al;
ALLEGRO_FONT* font;
std::vector<Txt> txt_overlay;
std::vector<ALLEGRO_BITMAP*> sprites;
Sprite background;
Graphics() :
al(&AllegroLib::Instance()),
background(SPRITE_BACKGROUND1)
{
};
Graphics(Graphics const&)
{
};
void operator=(Graphics const&)
{
};
};
#endif