-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlotterTetris.cpp
77 lines (61 loc) · 1.94 KB
/
PlotterTetris.cpp
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
#include "PlotterTetris.h"
#define _WIN32_WINNT 0x0501
void PlotterTetris::plot(char object)
{
cout << object;
cout.flush();
}
void PlotterTetris::move(int x, int y)
{
coordScreen.X = x;
coordScreen.Y = y;
SetConsoleTextAttribute(hConsoleOutput, color);
SetConsoleCursorPosition( hConsoleOutput, coordScreen );
}
void PlotterTetris::clear()
{
cls( hConsoleOutput );
}
void PlotterTetris::setColor(ink i)
{
color = i;
SetConsoleTextAttribute(hConsoleOutput, color);
}
PlotterTetris::PlotterTetris()
{
//Sets struct that deals with cursor on screen to zero and base color white
color = white;
coordScreen.X = 0;
coordScreen.Y = 0;
//Set screen dimensions
lpConsoleWindow = new SMALL_RECT;
/*lpConsoleWindow->Bottom = 0;
lpConsoleWindow->Left = 0;
lpConsoleWindow->Right = 0;
lpConsoleWindow->Top = 0;*/
cout << "lpConsoleWindow->Top = " << lpConsoleWindow->Top<< endl;
cout << "THE ADRESS OF lpConsoleWindow: " <<hex << lpConsoleWindow << endl;
lpConsoleWindow->Right = 60;
lpConsoleWindow->Top = 10;
hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hConsoleOutput, color);
if(!SetConsoleWindowInfo(hConsoleOutput,false,lpConsoleWindow))
cout << "ERROR";
//SEtup font
// SetCurrentConsoleFontEx(hConsoleOutput, TRUE, FF_DECORATIVE);
system("pause");
}
void PlotterTetris::cls( HANDLE hConsole )
{
COORD coordScreen = { 0, 0 };
DWORD cCharsWritten;
CONSOLE_SCREEN_BUFFER_INFO csbi;
DWORD dwConSize;
GetConsoleScreenBufferInfo( hConsole, &csbi );
dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
FillConsoleOutputCharacter( hConsole, (TCHAR) ' ', dwConSize, coordScreen, &cCharsWritten );
GetConsoleScreenBufferInfo( hConsole, &csbi );
FillConsoleOutputAttribute( hConsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten );
SetConsoleCursorPosition( hConsole, coordScreen );
return;
}