Rev 7229 | Rev 7977 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7229 | Rev 7578 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | THE BUS |
2 | THE BUS |
3 | Copyright (C) 2008, 2012, 2017 Leency |
3 | Copyright (C) 2008, 2012, 2017 Leency |
4 | Menu image from Freepik.com |
4 | Menu image from Freepik.com |
5 | D O N K E Y |
5 | D O N K E Y |
6 | Copyright (C) 2008 O.Bogomaz |
6 | Copyright (C) 2008 O.Bogomaz |
7 | */ |
7 | */ |
8 | 8 | ||
9 | #ifndef AUTOBUILD |
9 | #ifndef AUTOBUILD |
10 | #include "lang.h--" |
10 | #include "lang.h--" |
11 | #endif |
11 | #endif |
12 | 12 | ||
13 | #define MEMSIZE 1024 * 60; |
13 | #define MEMSIZE 1024 * 60; |
14 | 14 | ||
15 | #include "..\lib\kolibri.h" |
15 | #include "..\lib\kolibri.h" |
16 | #include "..\lib\random.h" |
16 | #include "..\lib\random.h" |
17 | 17 | ||
18 | #include "..\lib\obj\libio.h" |
18 | #include "..\lib\obj\libio.h" |
19 | #include "..\lib\obj\libimg.h" |
19 | #include "..\lib\obj\libimg.h" |
20 | 20 | ||
21 | libimg_image menu; |
21 | libimg_image menu; |
22 | libimg_image road; |
22 | libimg_image road; |
23 | libimg_image objects; |
23 | libimg_image objects; |
24 | 24 | ||
25 | int frame_timeout = 1; |
25 | int frame_timeout = 1; |
26 | 26 | ||
27 | int lifes=0, level=0, score=0; |
27 | int lifes=0, level=0, score=0; |
28 | int don_x, don_y, don_h, don_w=68, don_type, don_image_y, don_step_y, don_step_y_default=3; |
28 | int don_x, don_y, don_h, don_w=68, don_type, don_image_y, don_step_y, don_step_y_default=3; |
29 | int don_h_mas[8] = { 36,72,36,74,24,64,48,74 }; |
29 | int don_h_mas[8] = { 36,72,36,74,24,64,48,74 }; |
30 | int bus_x, bus_w=42, bus_y, bus_h=88, bus_y_default=290; |
30 | int bus_x, bus_w=42, bus_y, bus_h=88, bus_y_default=290; |
31 | 31 | ||
32 | #define SCR_MENU_MAIN 1 |
32 | #define SCR_MENU_MAIN 1 |
33 | #define SCR_GAME 2 |
33 | #define SCR_GAME 2 |
34 | #define SCR_PAUSE 3 |
34 | #define SCR_PAUSE 3 |
35 | 35 | ||
36 | #define RAND -1 |
36 | #define RAND -1 |
37 | 37 | ||
38 | #define WIN_X 516 |
38 | #define WIN_X 516 |
39 | #define WIN_Y 382 |
39 | #define WIN_Y 382 |
40 | 40 | ||
41 | int screen_type=SCR_MENU_MAIN; |
41 | int screen_type=SCR_MENU_MAIN; |
42 | 42 | ||
43 | #define COLOR_ROAD 0x6D879B; |
43 | #define COLOR_ROAD 0x6D879B; |
44 | 44 | ||
45 | int active_menu_item=0; |
45 | int active_menu_item=0; |
46 | 46 | ||
47 | #ifdef LANG_RUS |
47 | #ifdef LANG_RUS |
48 | #define THE_BUS_TEXT " àèàã⪠" |
48 | #define THE_BUS_TEXT " àèàã⪠" |
49 | #define CONTROLS_TEXT "' àèàã⪠|
49 | #define CONTROLS_TEXT "' àèàã⪠|
50 | ¯à ¢«¥¨¥: |
50 | ¯à ¢«¥¨¥: |
51 | «¥¢®/¯à ¢® ¨«¨ ஡¥« |
51 | «¥¢®/¯à ¢® ¨«¨ ஡¥« |
52 | « ¢¨è P áâ ¢¨â ¯ ã§ã'tI" |
52 | « ¢¨è P áâ ¢¨â ¯ ã§ã'tI" |
53 | #define ABOUT_TEXT "' àèàã⪠|
53 | #define ABOUT_TEXT "' àèàã⪠|
54 | ¥àá¨ï v1.01 |
54 | ¥àá¨ï v1.01 |
55 | 55 | ||
56 | ë£à ©â¥ § ¤¥à§ª®£® ¬ àèàãâ稪 , |
56 | ë£à ©â¥ § ¤¥à§ª®£® ¬ àèàãâ稪 , |
57 | ª®â®àë© ¥á¥âáï ¤®¬®© ¯®á«¥ ᬥë. |
57 | ª®â®àë© ¥á¥âáï ¤®¬®© ¯®á«¥ ᬥë. |
58 | 㦥 ¢ê¥¡ « àî¬ åã á ¬ã¦¨ª ¬¨ |
58 | 㦥 ª ⨫ àî¬ åã á ¬ã¦¨ª ¬¨ |
59 | ¨ ⥯¥àì ¥£® ¨çâ® ¥ ®áâ ®¢¨â! |
59 | ¨ ⥯¥àì ¥£® ¨çâ® ¥ ®áâ ®¢¨â! |
60 | 60 | ||
61 | ¢â®à Leency |
61 | ¢â®à Leency |
62 | à⨪ ¢ ¬¥î Freepik.com'tI" |
62 | à⨪ ¢ ¬¥î Freepik.com'tI" |
63 | #define PAUSE_TEXT "" |
63 | #define PAUSE_TEXT "" |
64 | #define GAME_OVER_TEXT "£à ®ª®ç¥ " |
64 | #define GAME_OVER_TEXT "£à ®ª®ç¥ " |
65 | #define FINAL_SCORE_TEXT "¨ «ìë© áç¥â" |
65 | #define FINAL_SCORE_TEXT "¨ «ìë© áç¥â" |
66 | #define LIFES_TEXT "¨§¨" |
66 | #define LIFES_TEXT "¨§¨" |
67 | #define LEVEL_TEXT "஢¥ì" |
67 | #define LEVEL_TEXT "஢¥ì" |
68 | #define SCORE_TEXT "ç¥â" |
68 | #define SCORE_TEXT "ç¥â" |
69 | char *MENU_LIST[]={ |
69 | char *MENU_LIST[]={ |
70 | "®¢ ï ¨£à ", |
70 | "®¢ ï ¨£à ", |
71 | "¯à ¢«¥¨¥", |
71 | "¯à ¢«¥¨¥", |
72 | "¡ ¨£à¥", |
72 | "¡ ¨£à¥", |
73 | "ë室", |
73 | "ë室", |
74 | 0}; |
74 | 0}; |
75 | #else |
75 | #else |
76 | #define THE_BUS_TEXT "THE BUS" |
76 | #define THE_BUS_TEXT "THE BUS" |
77 | #define CONTROLS_TEXT "'The Bus |
77 | #define CONTROLS_TEXT "'The Bus |
78 | Control keys: |
78 | Control keys: |
79 | Left, Right, Space |
79 | Left, Right, Space |
80 | Press P key for pause'tI" |
80 | Press P key for pause'tI" |
81 | #define ABOUT_TEXT "'The Bus |
81 | #define ABOUT_TEXT "'The Bus |
82 | Version v1.01 |
82 | Version v1.01 |
83 | Author: Leency |
83 | Author: Leency |
84 | Menu image from Freepik.com'tI" |
84 | Menu image from Freepik.com'tI" |
85 | #define PAUSE_TEXT "PAUSE" |
85 | #define PAUSE_TEXT "PAUSE" |
86 | #define GAME_OVER_TEXT "GAME OVER" |
86 | #define GAME_OVER_TEXT "GAME OVER" |
87 | #define FINAL_SCORE_TEXT "Final Score" |
87 | #define FINAL_SCORE_TEXT "Final Score" |
88 | #define LIFES_TEXT "Lifes" |
88 | #define LIFES_TEXT "Lifes" |
89 | #define LEVEL_TEXT "Level" |
89 | #define LEVEL_TEXT "Level" |
90 | #define SCORE_TEXT "Score" |
90 | #define SCORE_TEXT "Score" |
91 | char *MENU_LIST[]={ |
91 | char *MENU_LIST[]={ |
92 | "New game", |
92 | "New game", |
93 | "Control keys", |
93 | "Control keys", |
94 | "About", |
94 | "About", |
95 | "Exit", |
95 | "Exit", |
96 | 0}; |
96 | 0}; |
97 | #endif |
97 | #endif |
98 | 98 | ||
99 | 99 | ||
100 | void DrawObstacle(signed int x, y) { |
100 | void DrawObstacle(signed int x, y) { |
101 | int don_offset_y; |
101 | int don_offset_y; |
102 | int image_h; |
102 | int image_h; |
103 | 103 | ||
104 | if (y >= 0) { |
104 | if (y >= 0) { |
105 | image_h = don_h; |
105 | image_h = don_h; |
106 | don_offset_y = don_image_y; |
106 | don_offset_y = don_image_y; |
107 | } |
107 | } |
108 | else { |
108 | else { |
109 | image_h = don_h + y; |
109 | image_h = don_h + y; |
110 | don_offset_y = don_image_y - y; |
110 | don_offset_y = don_image_y - y; |
111 | y = 0; |
111 | y = 0; |
112 | } |
112 | } |
113 | DrawBar(x, y-don_step_y, don_w, don_step_y, COLOR_ROAD); |
113 | DrawBar(x, y-don_step_y, don_w, don_step_y, COLOR_ROAD); |
114 | if (y>0) && (y |
114 | if (y>0) && (y |
115 | if (image_h>0) DrawLibImage(objects.image, x, y, don_w, image_h, 0, don_offset_y); |
115 | if (image_h>0) DrawLibImage(objects.image, x, y, don_w, image_h, 0, don_offset_y); |
116 | } |
116 | } |
117 | void DrawBus(dword x, y) { DrawLibImage(objects.image, x, y, bus_w, bus_h, 0, 444); } |
117 | void DrawBus(dword x, y) { DrawLibImage(objects.image, x, y, bus_w, bus_h, 0, 444); } |
118 | void DrawBoom(dword x, y) { DrawLibImage(objects.image, x, y, 78, 66, 0, 536); } |
118 | void DrawBoom(dword x, y) { DrawLibImage(objects.image, x, y, 78, 66, 0, 536); } |
119 | void DrawHighway() { DrawLibImage(road.image, 0,0, WIN_X, WIN_Y, 0, 0); } |
119 | void DrawHighway() { DrawLibImage(road.image, 0,0, WIN_X, WIN_Y, 0, 0); } |
120 | void DrawMenuBackground() { DrawLibImage(menu.image, 0, 0, WIN_X, WIN_Y, 0, 0); } |
120 | void DrawMenuBackground() { DrawLibImage(menu.image, 0, 0, WIN_X, WIN_Y, 0, 0); } |
121 | 121 | ||
122 | void main() |
122 | void main() |
123 | { |
123 | { |
124 | randomize(); |
124 | randomize(); |
125 | StartNewGame(); |
125 | StartNewGame(); |
126 | 126 | ||
127 | load_dll(libio, #libio_init,1); |
127 | load_dll(libio, #libio_init,1); |
128 | load_dll(libimg, #libimg_init,1); |
128 | load_dll(libimg, #libimg_init,1); |
129 | Libimg_LoadImage(#menu, abspath("menu.png")); |
129 | Libimg_LoadImage(#menu, abspath("menu.png")); |
130 | Libimg_LoadImage(#road, abspath("road.png")); |
130 | Libimg_LoadImage(#road, abspath("road.png")); |
131 | Libimg_LoadImage(#objects, abspath("objects.png")); |
131 | Libimg_LoadImage(#objects, abspath("objects.png")); |
132 | 132 | ||
133 | loop() |
133 | loop() |
134 | { |
134 | { |
135 | WaitEventTimeout(frame_timeout); |
135 | WaitEventTimeout(frame_timeout); |
136 | 136 | ||
137 | switch(EAX & 0xFF) |
137 | switch(EAX & 0xFF) |
138 | { |
138 | { |
139 | case evKey: |
139 | case evKey: |
140 | GetKeys(); |
140 | GetKeys(); |
141 | if (key_scancode == SCAN_CODE_ESC) |
141 | if (key_scancode == SCAN_CODE_ESC) |
142 | { |
142 | { |
143 | if (screen_type==SCR_GAME) SetScreen(SCR_MENU_MAIN); |
143 | if (screen_type==SCR_GAME) SetScreen(SCR_MENU_MAIN); |
144 | else if (screen_type==SCR_MENU_MAIN) ExitProcess(); |
144 | else if (screen_type==SCR_MENU_MAIN) ExitProcess(); |
145 | } |
145 | } |
146 | if (key_scancode == SCAN_CODE_DOWN) && (screen_type==SCR_MENU_MAIN) |
146 | if (key_scancode == SCAN_CODE_DOWN) && (screen_type==SCR_MENU_MAIN) |
147 | { |
147 | { |
148 | if (active_menu_item<>3) active_menu_item++; ELSE active_menu_item=0; |
148 | if (active_menu_item<>3) active_menu_item++; ELSE active_menu_item=0; |
149 | DrawMenuList(); |
149 | DrawMenuList(); |
150 | } |
150 | } |
151 | if (key_scancode == SCAN_CODE_UP) && (screen_type==SCR_MENU_MAIN) |
151 | if (key_scancode == SCAN_CODE_UP) && (screen_type==SCR_MENU_MAIN) |
152 | { |
152 | { |
153 | if (active_menu_item<>0) active_menu_item--; ELSE active_menu_item=3; |
153 | if (active_menu_item<>0) active_menu_item--; ELSE active_menu_item=3; |
154 | DrawMenuList(); |
154 | DrawMenuList(); |
155 | } |
155 | } |
156 | if (key_scancode == SCAN_CODE_ENTER) && (screen_type==SCR_MENU_MAIN) |
156 | if (key_scancode == SCAN_CODE_ENTER) && (screen_type==SCR_MENU_MAIN) |
157 | { |
157 | { |
158 | if (active_menu_item==0) |
158 | if (active_menu_item==0) |
159 | { |
159 | { |
160 | StartNewGame(); |
160 | StartNewGame(); |
161 | SetScreen(SCR_GAME); |
161 | SetScreen(SCR_GAME); |
162 | } |
162 | } |
163 | if (active_menu_item==1) notify(CONTROLS_TEXT); |
163 | if (active_menu_item==1) notify(CONTROLS_TEXT); |
164 | if (active_menu_item==2) notify(ABOUT_TEXT); |
164 | if (active_menu_item==2) notify(ABOUT_TEXT); |
165 | if (active_menu_item==3) ExitProcess(); |
165 | if (active_menu_item==3) ExitProcess(); |
166 | } |
166 | } |
167 | if (key_scancode == SCAN_CODE_SPACE) && (screen_type==SCR_GAME) |
167 | if (key_scancode == SCAN_CODE_SPACE) && (screen_type==SCR_GAME) |
168 | { |
168 | { |
169 | DrawBar(bus_x*80+200, bus_y, bus_w, bus_h+1, COLOR_ROAD); |
169 | DrawBar(bus_x*80+200, bus_y, bus_w, bus_h+1, COLOR_ROAD); |
170 | if (bus_x==1) bus_x=0; else bus_x=1; |
170 | if (bus_x==1) bus_x=0; else bus_x=1; |
171 | } |
171 | } |
172 | if (key_scancode == SCAN_CODE_LEFT) && (screen_type==SCR_GAME) |
172 | if (key_scancode == SCAN_CODE_LEFT) && (screen_type==SCR_GAME) |
173 | { |
173 | { |
174 | if (bus_x==0) break; |
174 | if (bus_x==0) break; |
175 | DrawBar(bus_x*80+200, bus_y, bus_w, bus_h+1, COLOR_ROAD); |
175 | DrawBar(bus_x*80+200, bus_y, bus_w, bus_h+1, COLOR_ROAD); |
176 | bus_x=0; |
176 | bus_x=0; |
177 | } |
177 | } |
178 | if (key_scancode == SCAN_CODE_RIGHT) && (screen_type==SCR_GAME) |
178 | if (key_scancode == SCAN_CODE_RIGHT) && (screen_type==SCR_GAME) |
179 | { |
179 | { |
180 | if (bus_x==1) break; |
180 | if (bus_x==1) break; |
181 | DrawBar(bus_x*80+200, bus_y, bus_w, bus_h+1, COLOR_ROAD); |
181 | DrawBar(bus_x*80+200, bus_y, bus_w, bus_h+1, COLOR_ROAD); |
182 | bus_x=1; |
182 | bus_x=1; |
183 | } |
183 | } |
184 | if (key_scancode == SCAN_CODE_KEY_P) |
184 | if (key_scancode == SCAN_CODE_KEY_P) |
185 | { |
185 | { |
186 | if (screen_type==SCR_MENU_MAIN) break; |
186 | if (screen_type==SCR_MENU_MAIN) break; |
187 | else if (screen_type==SCR_GAME) SetScreen(SCR_PAUSE); |
187 | else if (screen_type==SCR_GAME) SetScreen(SCR_PAUSE); |
188 | else if (screen_type==SCR_PAUSE) SetScreen(SCR_GAME); |
188 | else if (screen_type==SCR_PAUSE) SetScreen(SCR_GAME); |
189 | } |
189 | } |
190 | break; |
190 | break; |
191 | 191 | ||
192 | case evReDraw: |
192 | case evReDraw: |
193 | DefineAndDrawWindow(250,150,WIN_X-1,WIN_Y-1,0x01,0,THE_BUS_TEXT,0); //0x74 is also possible if you fix bottom border |
193 | DefineAndDrawWindow(250,150,WIN_X-1,WIN_Y-1,0x01,0,THE_BUS_TEXT,0); //0x74 is also possible if you fix bottom border |
194 | DrawScreen(); |
194 | DrawScreen(); |
195 | break; |
195 | break; |
196 | 196 | ||
197 | case evButton: |
197 | case evButton: |
198 | ExitProcess(); |
198 | ExitProcess(); |
199 | break; |
199 | break; |
200 | 200 | ||
201 | default: |
201 | default: |
202 | if (screen_type==SCR_GAME) |
202 | if (screen_type==SCR_GAME) |
203 | { |
203 | { |
204 | if ((don_x == bus_x)&&(don_y + don_h > bus_y )&&(don_y < bus_y + don_h )) { |
204 | if ((don_x == bus_x)&&(don_y + don_h > bus_y )&&(don_y < bus_y + don_h )) { |
205 | lifes--; |
205 | lifes--; |
206 | DrawBus(bus_x*80+200,bus_y); |
206 | DrawBus(bus_x*80+200,bus_y); |
207 | DrawBoom(bus_x*80+180,bus_y+10); |
207 | DrawBoom(bus_x*80+180,bus_y+10); |
208 | pause(150); |
208 | pause(150); |
209 | GetNewObstacle(RAND); |
209 | GetNewObstacle(RAND); |
210 | DrawScreen(); |
210 | DrawScreen(); |
211 | } |
211 | } |
212 | 212 | ||
213 | if (lifes==0) { |
213 | if (lifes==0) { |
214 | DrawGameOverMessage(); |
214 | DrawGameOverMessage(); |
215 | break; |
215 | break; |
216 | } |
216 | } |
217 | 217 | ||
218 | don_y += don_step_y; |
218 | don_y += don_step_y; |
219 | 219 | ||
220 | if (don_y - don_step_y >= WIN_Y) |
220 | if (don_y - don_step_y >= WIN_Y) |
221 | { |
221 | { |
222 | GetNewObstacle(RAND); |
222 | GetNewObstacle(RAND); |
223 | score++; |
223 | score++; |
224 | bus_y -= don_step_y+1; |
224 | bus_y -= don_step_y+1; |
225 | DrawBar(bus_x*80+200, bus_y+bus_h, bus_w, don_step_y+1, COLOR_ROAD); |
225 | DrawBar(bus_x*80+200, bus_y+bus_h, bus_w, don_step_y+1, COLOR_ROAD); |
226 | WriteScore(); |
226 | WriteScore(); |
227 | } |
227 | } |
228 | 228 | ||
229 | if (score) && (score % 15 == 0) |
229 | if (score) && (score % 15 == 0) |
230 | { |
230 | { |
231 | score++; |
231 | score++; |
232 | NewLevel(); |
232 | NewLevel(); |
233 | DrawScreen(); |
233 | DrawScreen(); |
234 | don_step_y++; |
234 | don_step_y++; |
235 | } |
235 | } |
236 | 236 | ||
237 | DrawRoad(); |
237 | DrawRoad(); |
238 | } |
238 | } |
239 | } |
239 | } |
240 | } |
240 | } |
241 | } |
241 | } |
242 | 242 | ||
243 | void NewLevel() |
243 | void NewLevel() |
244 | { |
244 | { |
245 | level++; |
245 | level++; |
246 | bus_y = bus_y_default; |
246 | bus_y = bus_y_default; |
247 | } |
247 | } |
248 | 248 | ||
249 | void StartNewGame() |
249 | void StartNewGame() |
250 | { |
250 | { |
251 | lifes=3; |
251 | lifes=3; |
252 | level=0; |
252 | level=0; |
253 | score=0; |
253 | score=0; |
254 | bus_y = bus_y_default; |
254 | bus_y = bus_y_default; |
255 | don_step_y = don_step_y_default; |
255 | don_step_y = don_step_y_default; |
256 | GetNewObstacle(RAND); |
256 | GetNewObstacle(RAND); |
257 | } |
257 | } |
258 | 258 | ||
259 | void WriteScore() { |
259 | void WriteScore() { |
260 | DrawLibImage(road.image, 20, 166, 120, 24, 20, 164); |
260 | DrawLibImage(road.image, 20, 166, 120, 24, 20, 164); |
261 | WriteText(20, 140, 0x81, 0xFFFFFF, SCORE_TEXT); |
261 | WriteText(20, 140, 0x81, 0xFFFFFF, SCORE_TEXT); |
262 | WriteText(20, 166, 0x81, 0xFFFFFF, itoa(score)); |
262 | WriteText(20, 166, 0x81, 0xFFFFFF, itoa(score)); |
263 | } |
263 | } |
264 | 264 | ||
265 | void SetScreen(dword _screen_type) { |
265 | void SetScreen(dword _screen_type) { |
266 | screen_type = _screen_type; |
266 | screen_type = _screen_type; |
267 | DrawScreen(); |
267 | DrawScreen(); |
268 | } |
268 | } |
269 | 269 | ||
270 | void DrawScreen() |
270 | void DrawScreen() |
271 | { |
271 | { |
272 | int i; |
272 | int i; |
273 | if (screen_type==SCR_MENU_MAIN) |
273 | if (screen_type==SCR_MENU_MAIN) |
274 | { |
274 | { |
275 | DrawMenuBackground(); |
275 | DrawMenuBackground(); |
276 | WriteTextB(20, 20, 0x83, 0xE8783F, THE_BUS_TEXT); |
276 | WriteTextB(20, 20, 0x83, 0xE8783F, THE_BUS_TEXT); |
277 | DrawMenuList(); |
277 | DrawMenuList(); |
278 | } |
278 | } |
279 | if (screen_type==SCR_GAME) || (screen_type==SCR_PAUSE) |
279 | if (screen_type==SCR_GAME) || (screen_type==SCR_PAUSE) |
280 | { |
280 | { |
281 | DrawHighway(); |
281 | DrawHighway(); |
282 | WriteText(20, 20, 0x81, 0xFFFFFF, LIFES_TEXT); |
282 | WriteText(20, 20, 0x81, 0xFFFFFF, LIFES_TEXT); |
283 | WriteText(20, 46, 0x81, 0xFFFFFF, itoa(lifes)); |
283 | WriteText(20, 46, 0x81, 0xFFFFFF, itoa(lifes)); |
284 | WriteText(20, 80, 0x81, 0xFFFFFF, LEVEL_TEXT); |
284 | WriteText(20, 80, 0x81, 0xFFFFFF, LEVEL_TEXT); |
285 | WriteText(20, 106, 0x81, 0xFFFFFF, itoa(level)); |
285 | WriteText(20, 106, 0x81, 0xFFFFFF, itoa(level)); |
286 | WriteScore(); |
286 | WriteScore(); |
287 | DrawRoad(); |
287 | DrawRoad(); |
288 | if (screen_type==SCR_PAUSE) { |
288 | if (screen_type==SCR_PAUSE) { |
289 | DrawBar(0,0,140,60,0xFF0000); |
289 | DrawBar(0,0,140,60,0xFF0000); |
290 | WriteText(10,14,0x83,0xFFFfff,PAUSE_TEXT); |
290 | WriteText(10,14,0x83,0xFFFfff,PAUSE_TEXT); |
291 | } |
291 | } |
292 | } |
292 | } |
293 | } |
293 | } |
294 | 294 | ||
295 | 295 | ||
296 | void DrawMenuList() |
296 | void DrawMenuList() |
297 | { |
297 | { |
298 | int j; |
298 | int j; |
299 | for (j=0; j<4; j++) DrawMenuItem(j, j); |
299 | for (j=0; j<4; j++) DrawMenuItem(j, j); |
300 | } |
300 | } |
301 | 301 | ||
302 | void DrawMenuItem(int item_n, text_n) |
302 | void DrawMenuItem(int item_n, text_n) |
303 | { |
303 | { |
304 | dword color; |
304 | dword color; |
305 | if (active_menu_item==item_n) color = 0xFF0000; else color = 0xFFffff; |
305 | if (active_menu_item==item_n) color = 0xFF0000; else color = 0xFFffff; |
306 | WriteText(20+2, item_n*56+116+2, 0x81, 0xAAAaaa, MENU_LIST[text_n]); |
306 | WriteText(20+2, item_n*56+116+2, 0x81, 0xAAAaaa, MENU_LIST[text_n]); |
307 | WriteText(20, item_n*56+116, 0x81, color, MENU_LIST[text_n]); |
307 | WriteText(20, item_n*56+116, 0x81, color, MENU_LIST[text_n]); |
308 | } |
308 | } |
309 | 309 | ||
310 | void DrawGameOverMessage() |
310 | void DrawGameOverMessage() |
311 | { |
311 | { |
312 | DrawBar(0, 0, WIN_X, WIN_Y, 0xF3E1BD); |
312 | DrawBar(0, 0, WIN_X, WIN_Y, 0xF3E1BD); |
313 | WriteText(40, 40, 0x81, 0xA48C74, GAME_OVER_TEXT); |
313 | WriteText(40, 40, 0x81, 0xA48C74, GAME_OVER_TEXT); |
314 | WriteText(40, 75, 0x81, 0xA48C74, FINAL_SCORE_TEXT); |
314 | WriteText(40, 75, 0x81, 0xA48C74, FINAL_SCORE_TEXT); |
315 | WriteTextB(40, 140, 0x85, 0xA48C74, itoa(score)); |
315 | WriteTextB(40, 140, 0x85, 0xA48C74, itoa(score)); |
316 | pause(350); |
316 | pause(350); |
317 | active_menu_item=0; |
317 | active_menu_item=0; |
318 | SetScreen(SCR_MENU_MAIN); |
318 | SetScreen(SCR_MENU_MAIN); |
319 | } |
319 | } |
320 | 320 | ||
321 | void GetNewObstacle(int N) |
321 | void GetNewObstacle(int N) |
322 | { |
322 | { |
323 | int i; |
323 | int i; |
324 | don_x = random(2); |
324 | don_x = random(2); |
325 | if (N==RAND) don_type = random(7); else don_type = N; |
325 | if (N==RAND) don_type = random(7); else don_type = N; |
326 | don_h = don_h_mas[don_type]; |
326 | don_h = don_h_mas[don_type]; |
327 | don_y = -don_h; |
327 | don_y = -don_h; |
328 | don_image_y = 0; |
328 | don_image_y = 0; |
329 | for (i = 0; i < don_type; i++) don_image_y += don_h_mas[i]+2; //calculate image y offset for current obstacle |
329 | for (i = 0; i < don_type; i++) don_image_y += don_h_mas[i]+2; //calculate image y offset for current obstacle |
330 | } |
330 | } |
331 | 331 | ||
332 | #define LINE_LENGTH 10 |
332 | #define LINE_LENGTH 10 |
333 | int line_y=0; |
333 | int line_y=0; |
334 | void DrawLineSeparator() |
334 | void DrawLineSeparator() |
335 | { |
335 | { |
336 | int y; |
336 | int y; |
337 | if (screen_type == SCR_GAME) line_y += don_step_y; |
337 | if (screen_type == SCR_GAME) line_y += don_step_y; |
338 | //the beginning of the white dashed line between two roadways |
338 | //the beginning of the white dashed line between two roadways |
339 | if (line_y>=20) { |
339 | if (line_y>=20) { |
340 | line_y=0; |
340 | line_y=0; |
341 | } |
341 | } |
342 | else |
342 | else |
343 | { |
343 | { |
344 | DrawBar(258, 0, 2, line_y, COLOR_ROAD); |
344 | DrawBar(258, 0, 2, line_y, COLOR_ROAD); |
345 | DrawBar(258, 0, 2, line_y-LINE_LENGTH, 0xDDE9F2); |
345 | DrawBar(258, 0, 2, line_y-LINE_LENGTH, 0xDDE9F2); |
346 | } |
346 | } |
347 | for (y=0; y |
347 | for (y=0; y |
348 | { |
348 | { |
349 | DrawBar(258, line_y+y, 2, LINE_LENGTH, 0xDDE9F2); |
349 | DrawBar(258, line_y+y, 2, LINE_LENGTH, 0xDDE9F2); |
350 | DrawBar(258, line_y+y+LINE_LENGTH, 2, LINE_LENGTH, COLOR_ROAD); |
350 | DrawBar(258, line_y+y+LINE_LENGTH, 2, LINE_LENGTH, COLOR_ROAD); |
351 | } |
351 | } |
352 | } |
352 | } |
353 | 353 | ||
354 | void DrawRoad() |
354 | void DrawRoad() |
355 | { |
355 | { |
356 | DrawLineSeparator(); |
356 | DrawLineSeparator(); |
357 | DrawObstacle(don_w+10*don_x+186,don_y); |
357 | DrawObstacle(don_w+10*don_x+186,don_y); |
358 | DrawBus(bus_x*80+200,bus_y); |
358 | DrawBus(bus_x*80+200,bus_y); |
359 | } |
359 | } |
360 | 360 | ||
361 | 361 | ||
362 | 362 | ||
363 | 363 | ||
364 | 364 | ||
365 | stop:>4;>>>> |
365 | stop:>4;>>>> |