-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDisplay.hpp
70 lines (45 loc) · 1.74 KB
/
Display.hpp
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
#ifndef DISPLAY_HPP_INCLUDED
#define DISPLAY_HPP_INCLUDED
#include <windows.h>
#include "Transparency.hpp"
namespace Game {
class Display {
friend class Texture;
private:
int width, height;
// a "2d" array of character pixels
CHAR_INFO* display;
// the output console that we will be rendering to
HANDLE window;
HANDLE input;
// the current render color
WORD color = 0x0F;
Transparency transparency = TRANSPARENT_NO;
// write area for the render function
SMALL_RECT writeArea;
WORD getDrawColor(unsigned int x, unsigned int y);
INPUT_RECORD inputBuff[128];
DWORD inputCount = 0;
int currentInput = 0;
public:
Display(HANDLE window = GetStdHandle(STD_OUTPUT_HANDLE),
HANDLE input = GetStdHandle(STD_INPUT_HANDLE));
void render();
// fill the entire screen with one character
void clear(char c);
void setColor(WORD color) { this->color = color; }
WORD getColor() { return color; }
void setTransparency(Transparency transparency) { this->transparency = transparency; }
Transparency getTransparency() { return transparency; }
// use unsigned so no negative values are allowed
void setChar(char c, unsigned int x, unsigned int y);
void writeString(const char* s, int x, int y);
void drawLine(char c, int x1, int y1, int y2, int x2);
int getWidth() { return width; }
void setWidth(int width) { this->width = width; }
int getHeight() { return height; }
void setHeight() { this->height = height; }
bool pollEvent(INPUT_RECORD* event);
};
}
#endif // DISPLAY_HPP_INCLUDED