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
|
#pragma once
#include <string>
#include <Windows.h>
#include <math.h>
#include <iostream>
//errors
#define _OK_ 0
#define _ERR_ 1
#define _ERR_COORDINATES_INVALID_ 2
#define _ERR_RENDER_BLOCKED_BY_CHILD_ 3
#define _COLLISION_ 255
//Colors
#define _COL_BLACK 0x00
#define _COL_BLUE 0x01
#define _COL_GREEN 0x02
#define _COL_YELLOW 0x0E
#define _COL_RED 0x04
#define _COL_WHITE 0x0F
#define _COL_DARK_WHITE 0x07
#define _COL_INTENSITY 0x08
#define _COL_DEFAULT 0xFF
using namespace std;
struct sPos
{
int x;
int y;
};
class cRender
{
public:
cRender(char _backound, WORD _color, int _sx, int _sy);
//Constructor
//sets cBackround[][] to _backround & wColor[][] to _color
//Resizes console window
~cRender();
//frees allocated memory
int drawPoint(char _c, sPos _pos, bool _overrideCollision, WORD _color);
//Draws _c @ _pos
//Returns _COLLOSION_ if _pos is already set to !cBackround && _overrideCollision isnt set
int drawLine(char _c, sPos _pos1, sPos _pos2, bool _overrideCollision, WORD _color);
//x Value of pos1 MUSTNT exceed the x value of pos2!
int drawText(string _s, sPos _pos, WORD _color);
//Draws Text _s @ _pos
//First char is @ _pos
int drawRectangle(char _border, char _fill, sPos _pos1, sPos _pos2, WORD _borderColor, WORD _fillColor);
//x Value of pos1 MUSTNT exceed the x value of pos2!
int render(void);
//Prints cScreen
int clear(void);
//clears cScreen + wColor
protected:
cRender(); //Empty Constructor for being inheritable
bool bBlockRender; //Used by children to block render function
char **cScreen; //Pixel Map
WORD **wColor; //Color Map
char cBackound; //Default backround
WORD wBackColor;
int sizeX, sizeY;
HANDLE hstdout;
CONSOLE_SCREEN_BUFFER_INFO csbi;
WORD wDefColor; //Default Color
private:
int SetConsoleWindowSize(int x, int y);
//Slightly adapted from: http://www.cplusplus.com/forum/windows/121444/
};
|