-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
79 lines (63 loc) · 1.41 KB
/
Copy pathmain.c
File metadata and controls
79 lines (63 loc) · 1.41 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
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
78
79
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <windows.h>
#include <conio.h>
#define RIGHT_LIMIT 78
#define LEFT_LIMIT 1
#include "main_functions.h"
#include "Player.h"
/*
KEYS:
Esc = 0x1B
Enter = 0x0D
Up = 0x26 - W = 0x57
Down = 0x28 - S = 0x53
Left = 0x25 - A = 0x41
Right = 0x27 - D = 0x44
PLAYER:
0
-+- 0
| /X\
*/
int main()
{
PLAYER Player; // <-- Aim at the PLAYER's belly.
Player.X = 37;
Player.Y = 16;
Player.crouched = false;
drawMap();
while (!GetAsyncKeyState(0x1B) && !GetAsyncKeyState(0x0D)) { // "Esc" key and "Enter" key.
if (kbhit()) {
if (GetAsyncKeyState(0x26) || GetAsyncKeyState(0x57)) { // Up (jump)
if (!Player.crouched) {
jump(&Player);
} else {
stand_up(&Player);
}
} else if (GetAsyncKeyState(0x28) || GetAsyncKeyState(0x53)) { // Down (crouch)
if (!Player.crouched) {
crouch(&Player);
}
} else if (GetAsyncKeyState(0x25) || GetAsyncKeyState(0x41)) { // Left
if (!Player.crouched && Player.X > LEFT_LIMIT) {
left(&Player);
} else {
stand_up(&Player);
}
} else if (GetAsyncKeyState(0x27) || GetAsyncKeyState(0x44)) { // Right
if (!Player.crouched && Player.X < RIGHT_LIMIT) {
right(&Player);
} else {
stand_up(&Player);
}
}
}
conpos(0, 22);
Sleep(100);
}
conpos(0, 22);
printf("+++ Thanks for using my program! :D +++\n\n");
Sleep(1000);
return 0;
}