Wise&mystical  1.0
Project about Europe
Loading...
Searching...
No Matches
movement.cpp
Go to the documentation of this file.
1#include "raylib.h"
2#include "movement.h"
3
7void setInitialCameraPos(float* cameraPosXPtr, float* cameraPosYPtr, int num)
8{
9 switch (num)
10 {
11 case 0:
12 *cameraPosXPtr = 912;
13 *cameraPosYPtr = 549;
14 break;
15 case 7:
16 case 8:
17 case 14:
18 *cameraPosXPtr = 912;
19 *cameraPosYPtr = 1227;
20 break;
21 case 28:
22 case 29:
23 case 30:
24 case 31:
25 case 32:
26 case 33:
27 case 34:
28 *cameraPosXPtr = 912;
29 *cameraPosYPtr = 2199;
30 break;
31 case 22:
32 case 23:
33 case 24:
34 case 25:
35 case 26:
36 case 27:
37 case 35:
38 case 37:
39 case 38:
40 case 39:
41 *cameraPosXPtr = 1812;
42 *cameraPosYPtr = 2250;
43 break;
44 case 1:
45 case 2:
46 case 3:
47 case 4:
48 case 5:
49 case 6:
50 case 10:
51 case 36:
52 *cameraPosXPtr = 1566;
53 *cameraPosYPtr = 1167;
54 break;
55 case 9:
56 case 11:
57 case 12:
58 case 13:
59 case 15:
60 case 16:
61 case 17:
62 case 18:
63 case 19:
64 case 20:
65 case 21:
66 *cameraPosXPtr = 1287;
67 *cameraPosYPtr = 1677;
68 break;
69 default:
70 break;
71 }
72}
73
77void updateCameraPos(float* xCoordinate, float* yCoordinate)
78{
79 // Uptade camera position, based on W, A, S, D keys
80 if (IsKeyDown(KEY_A))
81 {
82 // Check left camera boundary
83 if (*xCoordinate > 910)
84 {
85 *xCoordinate -= 3.0f;
86 }
87 else
88 {
89 *xCoordinate += 3.0f;
90 }
91
92 // Check top or bottom key down
93 if (IsKeyDown(KEY_W))
94 {
95 // Check top boundary
96 if (*yCoordinate > 550)
97 {
98 *yCoordinate -= 3.0f;
99 }
100 else
101 {
102 *yCoordinate += 3.0f;
103 }
104 }
105 else if (IsKeyDown(KEY_S))
106 {
107 // Check bottom boundary
108 if (*yCoordinate < 2250)
109 {
110 *yCoordinate += 3.0f;
111 }
112 else
113 {
114 *yCoordinate -= 3.0f;
115 }
116 }
117 }
118 else if (IsKeyDown(KEY_D))
119 {
120 // Check right camera boundary
121 if (*xCoordinate < 1815)
122 {
123 *xCoordinate += 3.0f;
124 }
125 else
126 {
127 *xCoordinate -= 3.0f;
128 }
129
130 // Check top or bottom key down
131 if (IsKeyDown(KEY_W))
132 {
133 // Check top boundary
134 if (*yCoordinate > 550)
135 {
136 *yCoordinate -= 3.0f;
137 }
138 else
139 {
140 *yCoordinate += 3.0f;
141 }
142 }
143 else if (IsKeyDown(KEY_S))
144 {
145 // Check bottom boundary
146 if (*yCoordinate < 2250)
147 {
148 *yCoordinate += 3.0f;
149 }
150 else
151 {
152 *yCoordinate -= 3.0f;
153 }
154 }
155 }
156
157 // Update camera, based on seperate key input - W, A, S, D
158 if (IsKeyDown(KEY_W))
159 {
160 if (*yCoordinate > 550)
161 {
162 *yCoordinate -= 3.0f;
163 }
164 else
165 {
166 *yCoordinate += 3.0f;
167 }
168 }
169 else if (IsKeyDown(KEY_S))
170 {
171 if (*yCoordinate < 2250)
172 {
173 *yCoordinate += 3.0f;
174 }
175 else
176 {
177 *yCoordinate -= 3.0f;
178 }
179 }
180 else if (IsKeyDown(KEY_A))
181 {
182 if (*xCoordinate > 910)
183 {
184 *xCoordinate -= 3.0f;
185 }
186 else
187 {
188 *xCoordinate += 3.0f;
189 }
190 }
191 else if (IsKeyDown(KEY_D))
192 {
193 if (*xCoordinate < 1815)
194 {
195 *xCoordinate += 3.0f;
196 }
197 else
198 {
199 *xCoordinate -= 3.0f;
200 }
201 }
202}
void updateCameraPos(float *xCoordinate, float *yCoordinate)
Update camera position.
Definition: movement.cpp:77
void setInitialCameraPos(float *cameraPosXPtr, float *cameraPosYPtr, int num)
Set the camera's intial positon based on the starter city's index.
Definition: movement.cpp:7
@ KEY_W
Definition: raylib.h:566
@ KEY_D
Definition: raylib.h:547
@ KEY_A
Definition: raylib.h:544
@ KEY_S
Definition: raylib.h:562
RLAPI bool IsKeyDown(int key)
Definition: rcore.c:3505