Rev 7493 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7493 | Rev 7494 | ||
---|---|---|---|
1 | /* Rocket Forces |
1 | /* Rocket Forces |
2 | * Filename: rforces.cpp |
2 | * Filename: rforces.cpp |
3 | * Version 0.1.1 |
3 | * Version 0.1 |
4 | * Copyright (c) Serial 2007 |
4 | * Copyright (c) Serial 2007 |
5 | */ |
5 | */ |
- | 6 | ||
- | 7 | /* Version 0.2 |
|
- | 8 | * Copyright (c) Leency 2018 |
|
- | 9 | */ |
|
6 | 10 | ||
7 | 11 | ||
8 | #include |
12 | #include |
9 | 13 | ||
10 | #include "kosSyst.h" |
14 | #include "kosSyst.h" |
11 | #include "kosFile.h" |
15 | #include "kosFile.h" |
12 | #include "mymath.h" |
16 | #include "mymath.h" |
13 | #include "properties.h" |
17 | #include "properties.h" |
14 | #include "objects.h" |
18 | #include "objects.h" |
15 | #include "rforces.h" |
19 | #include "rforces.h" |
16 | 20 | ||
17 | 21 | ||
18 | const char header[] = GAME_NAME; |
22 | const char header[] = GAME_NAME; |
19 | cCursor *cursor; |
23 | cCursor *cursor; |
20 | cGun *gun = new cGun; |
24 | cGun *gun = new cGun; |
21 | cCross **crosses = new cCross*[R_COUNT]; |
25 | cCross **crosses = new cCross*[R_COUNT]; |
22 | cRocket **rockets = new cRocket*[R_COUNT]; |
26 | cRocket **rockets = new cRocket*[R_COUNT]; |
23 | cBomb **bombs = new cBomb*[B_COUNT]; |
27 | cBomb **bombs = new cBomb*[B_COUNT]; |
24 | cExplode **explodes = new cExplode*[R_COUNT + B_COUNT]; |
28 | cExplode **explodes = new cExplode*[R_COUNT + B_COUNT]; |
25 | cBuilding *house = new cBuilding(); |
29 | cBuilding *house = new cBuilding(); |
26 | Dword *cur_handle; |
30 | Dword *cur_handle; |
27 | int score, health; |
31 | int score, health; |
- | 32 | ||
- | 33 | bool game_over; |
|
28 | 34 | ||
29 | struct MouseState |
35 | struct MouseState |
30 | { |
36 | { |
31 | int x, y, lbclick; |
37 | int x, y, lbclick; |
32 | Dword buttons; |
38 | Dword buttons; |
33 | } ms; |
39 | } ms; |
34 | 40 | ||
35 | 41 | ||
36 | void kos_Main() |
42 | void kos_Main() |
37 | { |
43 | { |
38 | Dword btn_id; |
- | |
39 | Dword frame_start, frame_end; |
44 | Dword frame_start, frame_end; |
40 | OnStart(); |
45 | OnStart(); |
41 | Menu(); |
46 | Menu(); |
42 | kos_SetMaskForEvents(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER); |
47 | kos_SetMaskForEvents(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER); |
43 | for (;;) |
48 | for (;;) |
44 | { |
49 | { |
45 | frame_start = kos_GetTime(); |
50 | frame_start = kos_GetTime(); |
46 | switch (kos_CheckForEvent()) |
51 | switch (kos_CheckForEvent()) |
47 | { |
52 | { |
48 | case EM_WINDOW_REDRAW: |
- | |
49 | DrawWindow(); |
- | |
50 | break; |
- | |
51 | case EM_KEY_PRESS: |
53 | case EM_KEY_PRESS: |
52 | Byte keyCode; |
54 | Byte keyCode; |
53 | kos_GetKey(keyCode); |
55 | kos_GetKey(keyCode); |
54 | if (keyCode == 27) |
56 | if (keyCode == 27) |
55 | { |
57 | { |
56 | OnExit(); |
58 | kos_ExitApp(); |
57 | } |
59 | } |
58 | if (keyCode == 51) |
60 | if (keyCode == 51) |
59 | { |
61 | { |
60 | OnStart(); |
62 | OnStart(); |
61 | } |
63 | } |
62 | break; |
64 | break; |
63 | case EM_BUTTON_CLICK: // button pressed; we have only one button, close |
65 | case EM_BUTTON_CLICK: |
- | 66 | Dword btn_id; |
|
64 | if (kos_GetButtonID(btn_id)) { |
67 | if (kos_GetButtonID(btn_id)) { |
65 | if (btn_id == 1) OnExit(); |
68 | if (btn_id == 1) kos_ExitApp(); |
66 | } |
69 | } |
67 | break; |
70 | break; |
68 | case EM_MOUSE_EVENT: // ñîáûòèå îò ìûøè (íàæàòèå íà êíîïêó ìûøè èëè ïåðåìåùåíèå; ñáðàñûâàåòñÿ ïðè ïðî÷òåíèè) |
71 | case EM_MOUSE_EVENT: |
69 | OnMouseMove(); |
72 | OnMouseMove(); |
70 | if (ms.lbclick == 1) |
73 | if (ms.lbclick == 1) |
71 | { |
74 | { |
72 | OnLMBClick(); |
75 | OnLMBClick(); |
73 | } |
76 | } |
74 | break; |
77 | break; |
- | 78 | case EM_WINDOW_REDRAW: |
|
- | 79 | DrawWindow(); |
|
- | 80 | break; |
|
75 | default: |
81 | default: |
- | 82 | if (game_over) break; |
|
76 | DrawBombs(); |
83 | DrawBombs(); |
77 | DrawRocketsAndCrosses(); |
84 | DrawRocketsAndCrosses(); |
78 | DrawExplodes(); |
85 | DrawExplodes(); |
- | 86 | DrawStats(); |
|
79 | frame_end = kos_GetTime(); |
87 | frame_end = kos_GetTime(); |
80 | if (frame_end - frame_start < FRAME_TIME) |
88 | if (frame_end - frame_start < FRAME_TIME) { |
81 | { |
- | |
82 | kos_Pause(FRAME_TIME - (frame_end - frame_start)); |
89 | kos_Pause(FRAME_TIME - (frame_end - frame_start)); |
83 | } |
90 | } |
84 | if (health <= 0) |
91 | if (health <= 0) GameOver(); |
85 | { |
- | |
86 | OnExit(); |
- | |
87 | } |
- | |
88 | } |
92 | } |
89 | } |
93 | } |
90 | } |
94 | } |
91 | 95 | ||
92 | void DrawWindow() |
96 | void DrawWindow() |
93 | { |
97 | { |
94 | kos_WindowRedrawStatus(1); |
98 | kos_WindowRedrawStatus(1); |
95 | kos_DefineAndDrawWindow(10, 40, WINDOW_WIDTH + 8, WINDOW_HEIGHT + kos_GetSkinHeight() + 12, 0x34, BG_COLOR, 0, 0, (Dword)header); |
99 | kos_DefineAndDrawWindow(10, 40, WINDOW_WIDTH + 12, |
- | 100 | WINDOW_HEIGHT + kos_GetSkinHeight() + 12, 0x34, |
|
- | 101 | BG_COLOR, 0, 0, (Dword)header); |
|
96 | kos_WindowRedrawStatus(2); |
102 | kos_WindowRedrawStatus(2); |
97 | 103 | ||
- | 104 | DrawStats(); |
|
98 | OnMouseMove(); |
105 | if (health <= 0) GameOver(); |
99 | 106 | ||
100 | // Draw buildings |
107 | // Draw buildings |
101 | for (int i = 20; i < 5 * 50; i += 50) |
108 | for (int i = 20; i < 5 * 50; i += 50) |
102 | { |
109 | { |
103 | house->Draw(i, 467, H_COLOR); |
110 | house->Draw(i, 467, H_COLOR); |
104 | } |
111 | } |
105 | for (int i = 8 * 50; i < 13 * 50; i += 50) |
112 | for (int i = 8 * 50; i < 13 * 50; i += 50) |
106 | { |
113 | { |
107 | house->Draw(i, 467, H_COLOR); |
114 | house->Draw(i, 467, H_COLOR); |
108 | } |
115 | } |
109 | 116 | ||
110 | } |
117 | } |
111 | 118 | ||
112 | void DrawBombs() |
119 | void DrawBombs() |
113 | { |
120 | { |
114 | for (int i = 0; i < B_COUNT; i++) |
121 | for (int i = 0; i < B_COUNT; i++) |
115 | { |
122 | { |
116 | if (bombs[i]->IsEnabled() == 0) |
123 | if (bombs[i]->IsEnabled() == 0) |
117 | { |
124 | { |
118 | int rnd; |
125 | int rnd; |
119 | rnd = rtlRand() % B_POSSIBILITY; |
126 | rnd = rtlRand() % B_POSSIBILITY; |
120 | if (rnd == 1) |
127 | if (rnd == 1) |
121 | { |
128 | { |
122 | rnd = 10 + rtlRand() % 620; |
129 | rnd = 10 + rtlRand() % 620; |
123 | bombs[i]->Enable(rnd, 0, 4, 9, rnd + 2, 0); |
130 | bombs[i]->Enable(rnd, 0, 4, 9, rnd + 2, 0); |
124 | } |
131 | } |
125 | } |
132 | } |
126 | else |
133 | else |
127 | { |
134 | { |
128 | if (bombs[i]->cy > gun->cy + 5) |
135 | if (bombs[i]->cy > gun->cy + 5) |
129 | { |
136 | { |
130 | health -= 5; |
137 | health -= 5; |
131 | if (explodes[R_COUNT + i]->IsEnabled() == 1) |
138 | if (explodes[R_COUNT + i]->IsEnabled() == 1) |
132 | { |
139 | { |
133 | explodes[R_COUNT + i]->Disable(BG_COLOR); |
140 | explodes[R_COUNT + i]->Disable(BG_COLOR); |
134 | } |
141 | } |
135 | explodes[R_COUNT + i]->Enable(bombs[i]->cx, bombs[i]->cy); |
142 | explodes[R_COUNT + i]->Enable(bombs[i]->cx, bombs[i]->cy); |
136 | bombs[i]->Disable(BG_COLOR); |
143 | bombs[i]->Disable(BG_COLOR); |
137 | } |
144 | } |
138 | else |
145 | else |
139 | { |
146 | { |
140 | bombs[i]->cy += B_SPEED; |
147 | bombs[i]->cy += B_SPEED; |
141 | bombs[i]->DrawAngle(bombs[i]->cx, 639, B_COLOR); |
148 | bombs[i]->DrawAngle(bombs[i]->cx, 639, B_COLOR); |
142 | } |
149 | } |
143 | } |
150 | } |
144 | } |
151 | } |
145 | } |
152 | } |
146 | 153 | ||
147 | void DrawRocketsAndCrosses() |
154 | void DrawRocketsAndCrosses() |
148 | { |
155 | { |
149 | double a; |
156 | double a; |
150 | for (int i = 0; i < R_COUNT; i++) |
157 | for (int i = 0; i < R_COUNT; i++) |
151 | { |
158 | { |
152 | if (crosses[i]->IsEnabled() == 1) |
159 | if (crosses[i]->IsEnabled() == 1) |
153 | { |
160 | { |
154 | if (sqrt(((long int) (crosses[i]->x - rockets[i]->cx) * (crosses[i]->x - rockets[i]->cx)) + ((long int) (crosses[i]->y - rockets[i]->cy) * (crosses[i]->y - rockets[i]->cy))) < 5) |
161 | if (sqrt(((long int) (crosses[i]->x - rockets[i]->cx) * (crosses[i]->x - rockets[i]->cx)) + ((long int) (crosses[i]->y - rockets[i]->cy) * (crosses[i]->y - rockets[i]->cy))) < 5) |
155 | { |
162 | { |
156 | if (explodes[i]->IsEnabled() == 1) |
163 | if (explodes[i]->IsEnabled() == 1) |
157 | { |
164 | { |
158 | explodes[i]->Disable(BG_COLOR); |
165 | explodes[i]->Disable(BG_COLOR); |
159 | } |
166 | } |
160 | explodes[i]->Enable(crosses[i]->x, crosses[i]->y); |
167 | explodes[i]->Enable(crosses[i]->x, crosses[i]->y); |
161 | crosses[i]->Disable(BG_COLOR); |
168 | crosses[i]->Disable(BG_COLOR); |
162 | rockets[i]->Disable(BG_COLOR); |
169 | rockets[i]->Disable(BG_COLOR); |
163 | } |
170 | } |
164 | else |
171 | else |
165 | { |
172 | { |
166 | crosses[i]->Draw(CROSS_COLOR); |
173 | crosses[i]->Draw(CROSS_COLOR); |
167 | if (rockets[i]->cx - crosses[i]->x == 0) |
174 | if (rockets[i]->cx - crosses[i]->x == 0) |
168 | { |
175 | { |
169 | a = M_PI / 2; |
176 | a = M_PI / 2; |
170 | } |
177 | } |
171 | else |
178 | else |
172 | { |
179 | { |
173 | a = atan((double)(rockets[i]->cy - crosses[i]->y) / (double)(rockets[i]->cx - crosses[i]->x)); |
180 | a = atan((double)(rockets[i]->cy - crosses[i]->y) / (double)(rockets[i]->cx - crosses[i]->x)); |
174 | if (rockets[i]->cx - crosses[i]->x < 0) a += M_PI; |
181 | if (rockets[i]->cx - crosses[i]->x < 0) a += M_PI; |
175 | } |
182 | } |
176 | rockets[i]->cx = round_int(rockets[i]->cx - R_SPEED * cos(a)); |
183 | rockets[i]->cx = round_int(rockets[i]->cx - R_SPEED * cos(a)); |
177 | rockets[i]->cy = round_int(rockets[i]->cy - R_SPEED * sin(a)); |
184 | rockets[i]->cy = round_int(rockets[i]->cy - R_SPEED * sin(a)); |
178 | rockets[i]->DrawAngle(crosses[i]->x, crosses[i]->y, R_COLOR); |
185 | rockets[i]->DrawAngle(crosses[i]->x, crosses[i]->y, R_COLOR); |
179 | } |
186 | } |
180 | } |
187 | } |
181 | } |
188 | } |
182 | } |
189 | } |
183 | 190 | ||
184 | void DrawExplodes() |
191 | void DrawExplodes() |
185 | { |
192 | { |
186 | for (int i = 0; i < R_COUNT + B_COUNT; i++) |
193 | for (int i = 0; i < R_COUNT + B_COUNT; i++) |
187 | { |
194 | { |
188 | if (explodes[i]->IsEnabled() == 1) |
195 | if (explodes[i]->IsEnabled() == 1) |
189 | { |
196 | { |
190 | explodes[i]->DrawNext(EXP_COLOR); |
197 | explodes[i]->DrawNext(EXP_COLOR); |
191 | for (int j = 0; j < B_COUNT; j++) |
198 | for (int j = 0; j < B_COUNT; j++) |
192 | { |
199 | { |
193 | if ( bombs[j]->IsEnabled() == 1 && |
200 | if ( bombs[j]->IsEnabled() == 1 && |
194 | bombs[j]->cx > explodes[i]->cx - explodes[i]->step - 1 && bombs[j]->cx < explodes[i]->cx + explodes[i]->step + 1 && |
201 | bombs[j]->cx > explodes[i]->cx - explodes[i]->step - 1 && bombs[j]->cx < explodes[i]->cx + explodes[i]->step + 1 && |
195 | bombs[j]->cy + 5 > explodes[i]->cy - explodes[i]->step - 1 && bombs[j]->cy + 5 < explodes[i]->cy + explodes[i]->step + 1 |
202 | bombs[j]->cy + 5 > explodes[i]->cy - explodes[i]->step - 1 && bombs[j]->cy + 5 < explodes[i]->cy + explodes[i]->step + 1 |
196 | ) |
203 | ) |
197 | { |
204 | { |
198 | score += B_COUNT + 2; |
205 | score += B_COUNT + 2; |
199 | if (explodes[R_COUNT + j]->IsEnabled() == 1) |
206 | if (explodes[R_COUNT + j]->IsEnabled() == 1) |
200 | { |
207 | { |
201 | explodes[R_COUNT + j]->Disable(BG_COLOR); |
208 | explodes[R_COUNT + j]->Disable(BG_COLOR); |
202 | } |
209 | } |
203 | explodes[R_COUNT + j]->Enable(bombs[j]->cx, bombs[j]->cy); |
210 | explodes[R_COUNT + j]->Enable(bombs[j]->cx, bombs[j]->cy); |
204 | bombs[j]->Disable(BG_COLOR); |
211 | bombs[j]->Disable(BG_COLOR); |
205 | } |
212 | } |
206 | } |
213 | } |
207 | } |
214 | } |
208 | } |
215 | } |
209 | } |
216 | } |
210 | 217 | ||
211 | void OnMouseMove() |
218 | void OnMouseMove() |
212 | { |
219 | { |
213 | Dword old_buttons = ms.buttons; |
220 | Dword old_buttons = ms.buttons; |
214 | kos_GetMouseWindowXY(ms.x, ms.y); |
221 | kos_GetMouseWindowXY(ms.x, ms.y); |
215 | kos_GetMouseButtonsState(ms.buttons); |
222 | kos_GetMouseButtonsState(ms.buttons); |
- | 223 | ||
- | 224 | if (health <= 0) return; |
|
- | 225 | ||
- | 226 | //restore mouse cursor when it over Window Header |
|
- | 227 | if (ms.y > 5000) RestoreSystemCursor(); else SetGameCursor(); |
|
- | 228 | ||
216 | if ((old_buttons & 0x00000001) == 0 && (ms.buttons & 0x00000001) == 1) |
229 | if ((old_buttons & 0x00000001) == 0 && (ms.buttons & 0x00000001) == 1) |
217 | { |
230 | { |
218 | ms.lbclick = 1; |
231 | ms.lbclick = 1; |
219 | } |
232 | } |
220 | else |
233 | else |
221 | { |
234 | { |
222 | ms.lbclick = 0; |
235 | ms.lbclick = 0; |
223 | } |
236 | } |
224 | - | ||
225 | kos_DrawBar(8, 10, 6*11, 22, 0); |
- | |
226 | kos_WriteTextToWindow(8, 10, 0, TEXT_COLOR, "Population: %", 16); |
- | |
227 | kos_WriteTextToWindow(8, 22, 0, TEXT_COLOR, "Score:", 6); |
- | |
228 | - | ||
229 | kos_DisplayNumberToWindowBg(health, 3, 79, 10, TEXT_COLOR, BG_COLOR, nbDecimal, false); |
- | |
230 | kos_DisplayNumberToWindowBg(score, 4, 49, 22, TEXT_COLOR, BG_COLOR, nbDecimal, false); |
- | |
231 | 237 | ||
232 | if (ms.x >= 0 && ms.x < WINDOW_WIDTH && ms.y >= 0 && ms.y < WINDOW_HEIGHT) |
238 | if (ms.x >= 0 && ms.x < WINDOW_WIDTH && ms.y >= 0 && ms.y < WINDOW_HEIGHT) |
233 | { |
239 | { |
234 | gun->DrawAngle(ms.x, ms.y, G_COLOR); |
240 | gun->DrawAngle(ms.x, ms.y, G_COLOR); |
235 | } |
241 | } |
236 | 242 | ||
237 | if (HARDWARE_CURSOR == 0) |
243 | if (HARDWARE_CURSOR == 0) |
238 | { |
244 | { |
239 | cursor->Draw(ms.x, ms.y, CUR_COLOR); |
245 | cursor->Draw(ms.x, ms.y, CUR_COLOR); |
240 | } |
246 | } |
241 | 247 | ||
242 | /*if (DEBUG == 1) |
248 | /*if (DEBUG == 1) |
243 | { |
249 | { |
244 | kos_DisplayNumberToWindowBg(ms.x, 3, WINDOW_WIDTH - 30, 10, TEXT_COLOR, BG_COLOR, nbDecimal, false); |
250 | kos_DisplayNumberToWindowBg(ms.x, 3, WINDOW_WIDTH - 30, 10, TEXT_COLOR, BG_COLOR, nbDecimal, false); |
245 | kos_DisplayNumberToWindowBg(ms.y, 3, WINDOW_WIDTH - 30, 22, TEXT_COLOR, BG_COLOR, nbDecimal, false); |
251 | kos_DisplayNumberToWindowBg(ms.y, 3, WINDOW_WIDTH - 30, 22, TEXT_COLOR, BG_COLOR, nbDecimal, false); |
246 | kos_DisplayNumberToWindowBg(ms.buttons, 1, WINDOW_WIDTH - 30, 34, TEXT_COLOR, BG_COLOR, nbDecimal, false); |
252 | kos_DisplayNumberToWindowBg(ms.buttons, 1, WINDOW_WIDTH - 30, 34, TEXT_COLOR, BG_COLOR, nbDecimal, false); |
247 | }*/ |
253 | }*/ |
- | 254 | } |
|
- | 255 | ||
- | 256 | void DrawStats() |
|
- | 257 | { |
|
- | 258 | kos_WriteTextWithBg(8, 10, 0xC0, TEXT_COLOR, 0, "Population:", 11); |
|
- | 259 | kos_WriteTextWithBg(8+15*6, 9, 0xC0, TEXT_COLOR, 0, "%", 1); |
|
- | 260 | kos_WriteTextWithBg(8, 22, 0xC0, TEXT_COLOR, 0, "Score:", 6); |
|
- | 261 | kos_DisplayNumberToWindowBg(health, 3, 79, 10, TEXT_COLOR, BG_COLOR, nbDecimal, false); |
|
248 | 262 | kos_DisplayNumberToWindowBg(score, 4, 49, 22, TEXT_COLOR, BG_COLOR, nbDecimal, false); |
|
249 | } |
263 | } |
250 | 264 | ||
251 | void OnLMBClick() |
265 | void OnLMBClick() |
252 | { |
266 | { |
253 | if (ms.y < gun->cy - 10) |
267 | if (ms.y < gun->cy - 10) |
254 | { |
268 | { |
255 | double a; |
269 | double a; |
256 | int j = -1; |
270 | int j = -1; |
257 | for (int i = 0; i < R_COUNT; i++) |
271 | for (int i = 0; i < R_COUNT; i++) |
258 | { |
272 | { |
259 | if (crosses[i]->IsEnabled() == 0) |
273 | if (crosses[i]->IsEnabled() == 0) |
260 | { |
274 | { |
261 | if (j >= -1) j = i; |
275 | if (j >= -1) j = i; |
262 | } |
276 | } |
263 | else if (ms.x > crosses[i]->x - 10 && ms.x < crosses[i]->x + 10 && ms.y > crosses[i]->y - 10 && ms.y < crosses[i]->y + 10) |
277 | else if (ms.x > crosses[i]->x - 10 && ms.x < crosses[i]->x + 10 && ms.y > crosses[i]->y - 10 && ms.y < crosses[i]->y + 10) |
264 | { |
278 | { |
265 | j = -2; |
279 | j = -2; |
266 | break; |
280 | break; |
267 | } |
281 | } |
268 | } |
282 | } |
269 | if (j >= 0) |
283 | if (j >= 0) |
270 | { |
284 | { |
271 | if (score > 0) score -= 1; |
285 | if (score > 0) score -= 1; |
272 | crosses[j]->Enable(ms.x, ms.y); |
286 | crosses[j]->Enable(ms.x, ms.y); |
273 | if (gun->cx - ms.x == 0) |
287 | if (gun->cx - ms.x == 0) |
274 | { |
288 | { |
275 | a = M_PI/2; |
289 | a = M_PI/2; |
276 | } |
290 | } |
277 | else |
291 | else |
278 | { |
292 | { |
279 | a = atan((double)gun->cy - ms.y / (double) gun->cx - ms.x); |
293 | a = atan((double)gun->cy - ms.y / (double) gun->cx - ms.x); |
280 | if (gun->cx - ms.x < 0) a += M_PI; |
294 | if (gun->cx - ms.x < 0) a += M_PI; |
281 | } |
295 | } |
282 | rockets[j]->Enable(round_int(gun->cx - 15 * cos(a)) - 2, round_int(gun->cy - 15 * sin(a)) - 5, 3, 6, round_int(gun->cx - 15 * cos(a)), round_int(gun->cy - 15 * sin(a))); |
296 | rockets[j]->Enable(round_int(gun->cx - 15 * cos(a)) - 2, round_int(gun->cy - 15 * sin(a)) - 5, 3, 6, round_int(gun->cx - 15 * cos(a)), round_int(gun->cy - 15 * sin(a))); |
283 | } |
297 | } |
284 | } |
298 | } |
285 | } |
299 | } |
286 | - | ||
287 | void OnRMBClick() |
- | |
288 | { |
- | |
289 | } |
- | |
290 | 300 | ||
291 | void ChangeCursor() |
301 | void SetGameCursor() |
292 | { |
302 | { |
293 | Dword *cur = new Dword[1024]; |
303 | Dword *cur = new Dword[1024]; |
294 | for (int i = 0; i < 1024; i++) |
304 | for (int i = 0; i < 1024; i++) |
295 | { |
305 | { |
296 | cur[i] = 0x00000000; |
306 | cur[i] = 0x00000000; |
297 | } |
307 | } |
298 | if (HARDWARE_CURSOR == 1) |
308 | if (HARDWARE_CURSOR == 1) |
299 | { |
309 | { |
300 | Dword cur_color = 0xFF000000 | CUR_COLOR; |
310 | Dword cur_color = 0xFF000000 | CUR_COLOR; |
301 | cur[0 * 32 + 5] = cur_color; |
311 | cur[0 * 32 + 5] = cur_color; |
302 | cur[1 * 32 + 5] = cur_color; |
312 | cur[1 * 32 + 5] = cur_color; |
303 | cur[2 * 32 + 5] = cur_color; |
313 | cur[2 * 32 + 5] = cur_color; |
304 | cur[2 * 32 + 3] = cur_color; |
314 | cur[2 * 32 + 3] = cur_color; |
305 | cur[2 * 32 + 4] = cur_color; |
315 | cur[2 * 32 + 4] = cur_color; |
306 | cur[2 * 32 + 6] = cur_color; |
316 | cur[2 * 32 + 6] = cur_color; |
307 | cur[3 * 32 + 2] = cur_color; |
317 | cur[3 * 32 + 2] = cur_color; |
308 | cur[4 * 32 + 2] = cur_color; |
318 | cur[4 * 32 + 2] = cur_color; |
309 | cur[5 * 32 + 2] = cur_color; |
319 | cur[5 * 32 + 2] = cur_color; |
310 | cur[5 * 32 + 1] = cur_color; |
320 | cur[5 * 32 + 1] = cur_color; |
311 | cur[5 * 32 + 0] = cur_color; |
321 | cur[5 * 32 + 0] = cur_color; |
312 | 322 | ||
313 | cur[5 * 32 + 5] = cur_color; |
323 | cur[5 * 32 + 5] = cur_color; |
314 | 324 | ||
315 | cur[8 * 32 + 4] = cur_color; |
325 | cur[8 * 32 + 4] = cur_color; |
316 | cur[8 * 32 + 5] = cur_color; |
326 | cur[8 * 32 + 5] = cur_color; |
317 | cur[8 * 32 + 6] = cur_color; |
327 | cur[8 * 32 + 6] = cur_color; |
318 | cur[8 * 32 + 7] = cur_color; |
328 | cur[8 * 32 + 7] = cur_color; |
319 | cur[9 * 32 + 5] = cur_color; |
329 | cur[9 * 32 + 5] = cur_color; |
320 | cur[10 * 32 + 5] = cur_color; |
330 | cur[10 * 32 + 5] = cur_color; |
321 | cur[7 * 32 + 8] = cur_color; |
331 | cur[7 * 32 + 8] = cur_color; |
322 | cur[6 * 32 + 8] = cur_color; |
332 | cur[6 * 32 + 8] = cur_color; |
323 | cur[5 * 32 + 8] = cur_color; |
333 | cur[5 * 32 + 8] = cur_color; |
324 | cur[5 * 32 + 9] = cur_color; |
334 | cur[5 * 32 + 9] = cur_color; |
325 | cur[5 * 32 + 10] = cur_color; |
335 | cur[5 * 32 + 10] = cur_color; |
326 | } |
336 | } |
327 | cur_handle = kos_LoadMouseCursor(cur, 0x05050002); |
337 | cur_handle = kos_LoadMouseCursor(cur, 0x05050002); |
328 | delete[] cur; |
338 | delete[] cur; |
329 | kos_SetMouseCursor(cur_handle); |
339 | kos_SetMouseCursor(cur_handle); |
330 | } |
340 | } |
- | 341 | ||
- | 342 | void RestoreSystemCursor() |
|
- | 343 | { |
|
- | 344 | if (cur_handle) kos_SetMouseCursor(0); |
|
- | 345 | cur_handle=0; |
|
- | 346 | } |
|
331 | 347 | ||
332 | void Menu() |
348 | void Menu() |
333 | { |
349 | { |
334 | NewGame(); |
350 | NewGame(); |
335 | } |
351 | } |
336 | 352 | ||
337 | void NewGame() |
353 | void NewGame() |
338 | { |
354 | { |
339 | gun->DrawAngle((WINDOW_WIDTH / 2) - 5, WINDOW_HEIGHT - 20, G_COLOR); |
355 | gun->DrawAngle((WINDOW_WIDTH / 2) - 5, WINDOW_HEIGHT - 20, G_COLOR); |
340 | } |
356 | } |
341 | 357 | ||
342 | void OnStart() |
358 | void OnStart() |
343 | { |
359 | { |
344 | if (HARDWARE_CURSOR == 0) |
360 | if (HARDWARE_CURSOR == 0) |
345 | { |
361 | { |
346 | cursor = new cCursor(); |
362 | cursor = new cCursor(); |
347 | } |
363 | } |
348 | ChangeCursor(); |
364 | SetGameCursor(); |
349 | 365 | ||
350 | gun->Enable((WINDOW_WIDTH / 2) - 10, WINDOW_HEIGHT - 30, 10, 20, (WINDOW_WIDTH / 2) - 5, WINDOW_HEIGHT - 20); |
366 | gun->Enable((WINDOW_WIDTH / 2) - 10, WINDOW_HEIGHT - 30, 10, 20, (WINDOW_WIDTH / 2) - 5, WINDOW_HEIGHT - 20); |
351 | 367 | ||
352 | for (int i = 0; i < R_COUNT; i++) |
368 | for (int i = 0; i < R_COUNT; i++) |
353 | { |
369 | { |
354 | crosses[i] = new cCross(); |
370 | crosses[i] = new cCross(); |
355 | rockets[i] = new cRocket(); |
371 | rockets[i] = new cRocket(); |
356 | } |
372 | } |
357 | for (int i = 0; i < B_COUNT; i++) |
373 | for (int i = 0; i < B_COUNT; i++) |
358 | { |
374 | { |
359 | bombs[i] = new cBomb(); |
375 | bombs[i] = new cBomb(); |
360 | } |
376 | } |
361 | for (int i = 0; i < R_COUNT + B_COUNT; i++) |
377 | for (int i = 0; i < R_COUNT + B_COUNT; i++) |
362 | { |
378 | { |
363 | explodes[i] = new cExplode(); |
379 | explodes[i] = new cExplode(); |
364 | } |
380 | } |
365 | 381 | ||
366 | health = 100; |
382 | health = 100; |
367 | score = 0; |
383 | score = 0; |
- | 384 | ||
- | 385 | game_over = false; |
|
368 | 386 | ||
369 | rtlSrand(kos_GetTime()); |
387 | rtlSrand(kos_GetTime()); |
370 | 388 | ||
371 | DrawWindow(); |
389 | DrawWindow(); |
372 | } |
390 | } |
373 | 391 | ||
374 | void OnExit() |
392 | void GameOver() |
- | 393 | { |
|
- | 394 | int xcenter = WINDOW_WIDTH / 2; |
|
375 | { |
395 | int y = WINDOW_HEIGHT/ 2 - 40; |
- | 396 | kos_WriteTextToWindow(xcenter-50, y, 0x81, TEXT_COLOR, "Game Over", 9); |
|
- | 397 | kos_WriteTextToWindow(xcenter-43, y+36, 0x80, TEXT_COLOR, "[F2] - New game", 0); |
|
376 | kos_WriteTextToWindow(WINDOW_WIDTH / 2 - 35, WINDOW_HEIGHT / 2 - 10, 0, TEXT_COLOR, "Game Over", 9); |
398 | kos_WriteTextToWindow(xcenter-43, y+53, 0x80, TEXT_COLOR, "[Ecs] - Exit", 0); |
377 | 399 | // |
|
378 | kos_Pause(150); |
- | |
379 | 400 | RestoreSystemCursor(); |
|
380 | kos_ExitApp(); |
401 | game_over = true; |
381 | }>>>>>>>>>>>>>>>>>>>>>=>> |
402 | }>>>>>>>>>>>=>>>>>>>>>>>=>=>> |