-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.cpp
More file actions
40 lines (35 loc) · 887 Bytes
/
util.cpp
File metadata and controls
40 lines (35 loc) · 887 Bytes
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
#include "util.h"
void gotoxy(int x, int y) {
HANDLE consolhandel = GetStdHandle(STD_OUTPUT_HANDLE);
COORD pos;
pos.X = x;
pos.Y = y;
SetConsoleCursorPosition(consolhandel, pos);
};
void init() {
system("mode con cols=56 lines=20 | title Chess Game");
HANDLE consoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO ConsoleCursor;
ConsoleCursor.bVisible = 0;
ConsoleCursor.dwSize = 1;
SetConsoleCursorInfo(consoleHandle, &ConsoleCursor);
}
void setColor(int forground, int background)
{
HANDLE consoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
int code = forground + background * 16;
SetConsoleTextAttribute(consoleHandle, code);
}
int keyControl() {
int i = _getch();
if (i == 224) {
i = _getch();
switch (i) {
case 72: return UP;
case 80: return DOWN;
case 75: return LEFT;
case 77: return RIGHT;
}
}
else if (i == ' ') return SUBMIT;
}