-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwin_manager.h
56 lines (50 loc) · 1.59 KB
/
win_manager.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
// A windows terminal manager
#ifndef FLAPPYBIRD_WIN_MANAGER_H_
#define FLAPPYBIRD_WIN_MANAGER_H_
#include <windows.h>
#include <map>
// A windows manager.
class WinManager{
public:
// WinManager(...):
// Create a manager with the block [left, right) * [top, bottom).
WinManager(int top, int bottom, int left, int right);
~WinManager();
// getHeight() and getWidth(): return the height/width of the block.
int getHeight();
int getWidth();
// WriteCharacter(...):
// Write a character c on the position (x, y).
// Note that (x, y) is relatively position to (left_, right_).
void WriteCharacter(int x, int y, char c);
// WriteLine/WriteColumn(...):
// Write a string filled by c from (x1, y) to (x2, y) (/ from (x, y1) to (x, y2))
// x2/y2 can be -1, then it will be the width/height
void WriteLine(int x1, int x2, int y, char c);
void WriteColumn(int x, int y1, int y2, char c);
// WriteString(...):
// Write a string s from (x, y) to (x + strlen(s) - 1, y).
// x can be -1, means that write in middle.
void WriteString(int x, int y, const char *s);
// UpdateScreen():
// Update the map onto the screen.
void UpdateScreen();
// Clear():
// Clear all contents in the block
void Clear();
private:
int left_, right_, top_, bottom_;
char **map_;
std::map<std::pair<int, int>, char> changes_;
HANDLE out_handle_;
};
// Hide the cursor.
void HideCursor();
// Wait for a key
int WaitKey();
//
// If a key is perssed then returns the key; or returns -1 otherwise
int GetKey();
// Wait until a time
void WaitUntil(double end);
#endif // FLAPPYBIRD_WINMANAGE_H_