-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGeneralFunc.cpp
More file actions
44 lines (40 loc) · 1.62 KB
/
GeneralFunc.cpp
File metadata and controls
44 lines (40 loc) · 1.62 KB
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
#include "GeneralFunc.h"
using namespace std;
#ifndef WINDOWS
void gotoxy(int x, int y) {}
int _getch(void) { return 0; }
int _kbhit(void) { return 0; }
void Sleep(unsigned long) {}
void setTextColor(Color color) {}
void hideCursor() {}
void clear_screen() {}
#else
/*------------------------------------------------------------------------------------------------------------------------------------------------------------*/
//This function moves the cursor to a specific coordinate.
void gotoxy(int x, int y)
{
HANDLE hConsoleOutput;
COORD dwCursorPosition;
cout << flush;
dwCursorPosition.X = x;
dwCursorPosition.Y = y;
hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(hConsoleOutput, dwCursorPosition);
}
/*------------------------------------------------------------------------------------------------------------------------------------------------------------*/
//This function allows the game to use colors.
void setTextColor(Color colorToSet) {
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), (int)colorToSet);
}
/*------------------------------------------------------------------------------------------------------------------------------------------------------------*/
//This function hides the corsur.
void hideCursor()
{
HANDLE myconsole = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO CURSOR;
CURSOR.dwSize = 1;
CURSOR.bVisible = FALSE;
SetConsoleCursorInfo(myconsole, &CURSOR);//second argument need pointer
}
/*------------------------------------------------------------------------------------------------------------------------------------------------------------*/
#endif