-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.h
71 lines (59 loc) · 1.47 KB
/
functions.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#ifndef AL_FUNCTIONS_H
#define AL_FUNCTIONS_H
#include <windows.h>
#include <chrono>
#include <random>
#include "classes.h"
static unsigned short font_color=7;
static unsigned short back_color=0;
static COORD buffer_size;
static COORD point;
std::default_random_engine raneng;
void static gotoxy(int x,int y)
{
if ((x>0)|(x<81)|(y>0)|(y<26))
{
point.X=x-1,point.Y=y-1;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),point);
}else{exit(3);}
}
void static cls()
{
system("cls");
}
void static textcolor(short color)
{
if (color>-1 && color<16){SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),(font_color=color) | back_color);}else{exit(2);}
}
void static textbackground(short color)
{
if (color>-1 && color<16){SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),(back_color=color*16) | font_color);}else{exit(2);}
}
void hidecursor()
{
HANDLE consoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO info;
info.dwSize = 25;
info.bVisible = FALSE;
SetConsoleCursorInfo(consoleHandle, &info);
}
void static randomize()
{
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
raneng.seed(seed);
}
int static rrand(int lower,int upper)
{
double tmp;
tmp=raneng()%(upper-lower+1)+lower;
return ((int)tmp);
}
bool static is_number(char input)
{
return ((input>='0')&&(input<='9'));
}
bool static is_dir(char input)
{
return ((input>='0')&&(input<='7'));
}
#endif