-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathos_func.c
64 lines (55 loc) · 1.12 KB
/
os_func.c
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
#include "sna.h"
#include <conio.h>
#include <windows.h>
void os_clean()
{
int x, y;
HANDLE hout = GetStdHandle(STD_OUTPUT_HANDLE);
x = y = 0;
static HANDLE hConsole = 0;
static int InstanceCount = 0;
COORD coord;
if (!InstanceCount) {
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
InstanceCount = 1;
}
coord.X = x, coord.Y = y;
SetConsoleCursorPosition(hConsole, coord);
CONSOLE_CURSOR_INFO cursor_info = { 1,0 };
SetConsoleCursorInfo(hout, &cursor_info);
}
void gotoxy(int xpos, int ypos)
{
COORD scrn;
HANDLE hOuput = GetStdHandle(STD_OUTPUT_HANDLE);
scrn.X = xpos; scrn.Y = ypos;
SetConsoleCursorPosition(hOuput,scrn);
}
int os_keyboard()
{
static int n = UP;
if (_kbhit())
{
_getch();
switch (_getch())
{
case UP:
n = UP;
break;
case DOWN:
n = DOWN;
break;
case LEFT:
n = LEFT;
break;
case RIGHT:
n = RIGHT;
break;
}
}
return n;
}
void os_sleep(int n)
{
Sleep(n);
}