-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathplayer.h
executable file
·105 lines (99 loc) · 1.94 KB
/
player.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
//Player Handling Class for Close Viewmode
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <SDL2/SDL_ttf.h>
class Player {
public:
//Global Division = 1000 Blocks
int xGlobal = 15;
int yGlobal = 20;
//Local Division = 10 Blocks
int xRegion = 0; //73
int yRegion = 0; //30
//Local Division = 10
int xLocal = 0;
int yLocal = 0;
//Total Division = 10'000 (or 1 hour walktime, with .5)
int xTotal = 1000;
int yTotal = 1000;
void changePos(SDL_Event e);
};
void Player::changePos(SDL_Event e){
switch( e.key.keysym.sym){
case SDLK_DOWN:
if(yLocal < 9){
yLocal += 1;
}
else{
if(yRegion < 99){
yLocal = 0;
yRegion += 1;
}
else{
if(yGlobal < 99){
yLocal = 0;
yRegion = 0;
yGlobal += 1;
}
}
}
break;
case SDLK_UP:
if(yLocal > 0){
yLocal -= 1;
}
else{
if(yRegion > 0){
yLocal = 9;
yRegion -= 1;
}
else{
if(yGlobal > 0){
yLocal = 9;
yRegion = 99;
yGlobal -= 1;
}
}
}
break;
case SDLK_RIGHT:
if(xLocal > 0){
xLocal -= 1;
}
else{
if(xRegion > 0){
xLocal = 9;
xRegion -= 1;
}
else{
if(xGlobal > 0){
xLocal = 9;
xRegion = 99;
xGlobal -= 1;
}
}
}
break;
case SDLK_LEFT:
if(xLocal < 9){
xLocal += 1;
}
else{
if(xRegion < 99){
xLocal = 0;
xRegion += 1;
}
else{
if(xGlobal < 99){
xLocal = 0;
xRegion = 0;
xGlobal += 1;
}
}
}
break;
}
//Calculate the Overall Position
xTotal = xGlobal*1000+xRegion*10+xLocal;
yTotal = yGlobal*1000+yRegion*10+yLocal;
}