Rev 5266 | Rev 5286 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
5266 | eugene455 | 1 | //screen Width and Height |
2 | #define Width 600 |
||
3 | #define Height 600 |
||
4 | int ScreenX=0; |
||
5 | int ScreenY=0; |
||
6 | int OffsetX=0; |
||
7 | int OffsetY=0; |
||
8 | int BufferDraw [Width][Height]; |
||
9 | char BufferCarry [Height][Width][3]; |
||
10 | int BufferCarry2 [Height][Width]; |
||
11 | int DRAW_TECH=0; |
||
12 | int Analyx [Width][Height]; |
||
13 | int CollideVerts[10][2]={}; |
||
14 | int DeltaH [8]={11,16,19,20,21,22,23,23}; |
||
15 | //-1-quit, 0-menu, 1-game |
||
16 | int GAME_TYPE=0; |
||
17 | |||
18 | int TactCount=0; |
||
19 | int GLOBAL_SPEED=0; |
||
20 | //colors |
||
21 | int COLOR_INDEX=0; |
||
22 | char RAINBOW_NAME[7][7]={"red","orange","yellow","green","blue","indigo","violet"}; |
||
23 | int RAINBOW_TABLE[7][5]= {{0x00ff0000, 0x00e80c7a, 0x00ff0dff, 0x00e82c0c, 0x00ff530d}, |
||
24 | {0x00ff4700, 0x00e8690c, 0x00ff970d, 0x00ff0d18, 0x00e8290c}, |
||
25 | {0x00ffff00, 0x00e8d20c, 0x00ffce0d, 0x009be80c, 0x0056ff0d}, |
||
26 | {0x0000ff00, 0x000ce84a, 0x0059e80c, 0x000dff96, 0x00b6ff0d}, |
||
27 | {0x0000ffff, 0x000d7fff, 0x000caeeb, 0x000dff76, 0x000ce8aa}, |
||
28 | {0x000000ff, 0x000c46eb, 0x00480ce8, 0x00910dff, 0x000d8cff}, |
||
29 | {0x006700ff, 0x00a00ce8, 0x00f20dff, 0x000d2eff, 0x00280ce8}}; |
||
30 | int GLOBAL_BLOCKCOLOR=0x00e80c7a; |
||
31 | int GLOBAL_BATUTCOLOR=0x00ff0dff; |
||
32 | int GLOBAL_PITCOLOR=0x00e82c0c; |
||
33 | int GLOBAL_FLAGCOLOR=0x00ff530d; |
||
34 | int GLOBAL_BACKGROUNDCOLOR=0x00000000; |
||
35 | int GLOBAL_FRONTCOLOR=0x00ffffff; |
||
36 | //menu settings |
||
37 | int MENU_SELECTED=0; |
||
38 | char NUMBER[100]="0"; |
||
39 | int CURRENT_LEVEL=3; |
||
40 | int MAX_LEVEL=3; |
||
41 | int TO_NEXT_LEVEL=0; |
||
42 | int DeltaSpeed=0; |
||
43 | int GLOBAL_CHECKPOINT=0; |
||
44 | int SPAWN_Y=0; |
||
45 | int isRestart=1; |
||
46 | int CurrentCheck=0; |
||
47 | |||
48 | //Hero data |
||
49 | int HeroX=100; |
||
50 | int HeroY=100; |
||
51 | int HeroSides=3; |
||
52 | int HeroAngle=0; |
||
53 | int HeroFly=0; |
||
54 | char HeroIsDead=0; |
||
55 | int HeroColor=0x00ff0000; |
||
56 | char Key=0; |
||
57 | |||
58 | //Saveload folder |
||
59 | int SAVE_FOLDER_TYPE=0; |
||
60 | |||
61 | //EDITOR |
||
62 | int Tile_X=0; |
||
63 | int Tile_Y=0; |
||
64 | int Panel=0; //0-grid,1-tools, 2-props |
||
65 | int Tile_Type=0; |
||
66 | int Q_SELECTED=0; |
||
67 | char TILENAME[6][11]={"empty","block","spike","jump pad","checkpt","finish"}; |
||
68 | |||
69 | //TIMING |
||
70 | int OLD_FPS=60; |
||
71 | int NEW_FPS=60; |
||
72 | |||
73 | //OTHER |
||
74 | int THE_END_COUNT=600; |
||
75 | |||
76 | //Libraries |
||
77 | #include |
||
78 | #include |
||
79 | #include |
||
80 | #include |
||
5267 | eugene455 | 81 | #include |
5266 | eugene455 | 82 | #include |
83 | #include |
||
84 | #include |
||
5267 | eugene455 | 85 | #include |
5266 | eugene455 | 86 | |
87 | |||
88 | |||
89 | //result of getKey is key character. Condition for Escape - if (getKey()==27) |
||
90 | char getKey() { |
||
91 | int NewKey=_ksys_get_key(); |
||
92 | NewKey/=256; |
||
93 | return (NewKey%256); |
||
94 | } |
||
95 | void LoadData () { |
||
96 | FILE *Profile; |
||
97 | if (SAVE_FOLDER_TYPE==1) { |
||
98 | Profile=fopen ("/usbhd0/1/Profile.bin","rb"); |
||
99 | } else { |
||
100 | Profile=fopen ("Profile.bin","rb"); |
||
101 | } |
||
102 | char Format=0; |
||
103 | Format=fgetc (Profile); |
||
104 | if (Format!='N') { |
||
105 | DrawText (100,300,"error (cannot load data)",GLOBAL_FRONTCOLOR); |
||
106 | Update(); |
||
107 | _ksys_delay(200); |
||
108 | MENU_SELECTED=1; |
||
109 | fclose (Profile); |
||
110 | return; |
||
111 | } |
||
112 | //Loading operations |
||
113 | fread (&(COLOR_INDEX), sizeof(int),1,Profile); |
||
114 | HeroColor=COLOR_INDEX; |
||
115 | fread (&(GLOBAL_BACKGROUNDCOLOR), sizeof(int),1,Profile); |
||
116 | fread (&(GLOBAL_FRONTCOLOR),sizeof(int),1,Profile); |
||
117 | Update(); |
||
118 | fread (&(DRAW_TECH),sizeof(int),1,Profile); |
||
119 | Update(); |
||
120 | MAX_LEVEL=fgetc (Profile); |
||
121 | CURRENT_LEVEL=MAX_LEVEL; |
||
122 | fread (&(LevelProps[0][2]), sizeof(int),1, Profile); |
||
123 | fread (USER_LEVEL0,1,9*LEVEL_MAXLEN,Profile); |
||
124 | fread (&(LevelProps[1][2]), sizeof(int),1,Profile); |
||
125 | fread (USER_LEVEL1,1,9*LEVEL_MAXLEN,Profile); |
||
126 | fread (&(LevelProps[2][2]), sizeof(int),1,Profile); |
||
127 | fread (USER_LEVEL2,1,9*LEVEL_MAXLEN,Profile); |
||
128 | DrawText (100,300,"loaded successfully",GLOBAL_FRONTCOLOR); |
||
129 | Update(); |
||
130 | _ksys_delay(200); |
||
131 | Update(); |
||
132 | |||
133 | MENU_SELECTED=1; |
||
134 | fclose (Profile); |
||
135 | } |
||
136 | |||
137 | void SaveData () { |
||
138 | FILE *Profile; |
||
139 | if (SAVE_FOLDER_TYPE==1) { |
||
140 | Profile=fopen ("/usbhd0/1/Profile.bin","wb"); |
||
141 | } else { |
||
142 | Profile=fopen ("Profile.bin","wb"); |
||
143 | } |
||
144 | if (Profile==NULL) { |
||
145 | DrawText (100,300,"error (cannot save data)",GLOBAL_FRONTCOLOR); |
||
146 | Update(); |
||
147 | _ksys_delay(200); |
||
148 | MENU_SELECTED=1; |
||
149 | return; |
||
150 | } |
||
151 | fputc ('N',Profile); |
||
152 | fwrite (&(COLOR_INDEX), sizeof(int),1,Profile); |
||
153 | fwrite (&(GLOBAL_BACKGROUNDCOLOR), sizeof(int),1,Profile); |
||
154 | fwrite (&(GLOBAL_FRONTCOLOR),sizeof(int),1,Profile); |
||
155 | fwrite (&(DRAW_TECH),sizeof(int),1,Profile); |
||
156 | fputc (MAX_LEVEL,Profile); |
||
157 | fwrite (&(LevelProps[0][2]), sizeof(int),1, Profile); |
||
158 | fwrite (USER_LEVEL0,1,9*LEVEL_MAXLEN,Profile); |
||
159 | fwrite (&(LevelProps[1][2]), sizeof(int),1,Profile); |
||
160 | fwrite (USER_LEVEL1,1,9*LEVEL_MAXLEN,Profile); |
||
161 | fwrite (&(LevelProps[2][2]), sizeof(int),1,Profile); |
||
162 | fwrite (USER_LEVEL2,1,9*LEVEL_MAXLEN,Profile); |
||
163 | DrawText (100,300,"saved successfully",GLOBAL_FRONTCOLOR); |
||
164 | Update(); |
||
165 | _ksys_delay(200); |
||
166 | MENU_SELECTED=1; |
||
167 | fclose (Profile); |
||
168 | } |
||
169 | |||
170 | void MainMenu () { |
||
171 | if (Key==27) GAME_TYPE=-1; |
||
172 | if (MENU_SELECTED==10 && Key==' ') GAME_TYPE=-1; |
||
173 | if (Key=='s') MENU_SELECTED++; |
||
174 | if (Key=='w') MENU_SELECTED--; |
||
175 | if (MENU_SELECTED<0) MENU_SELECTED=10; |
||
176 | if (MENU_SELECTED>10) MENU_SELECTED=0; |
||
177 | if (MENU_SELECTED==0 && Key==' ') { |
||
178 | GAME_TYPE=1; |
||
179 | GLOBAL_CHECKPOINT=0; |
||
180 | return; |
||
181 | } |
||
182 | if (MENU_SELECTED==3 && (Key=='a' || Key=='d')) { |
||
183 | if (GLOBAL_BACKGROUNDCOLOR==0) { |
||
184 | GLOBAL_BACKGROUNDCOLOR=0x00ffffff; |
||
185 | GLOBAL_FRONTCOLOR=0; |
||
186 | } else { |
||
187 | GLOBAL_BACKGROUNDCOLOR=0; |
||
188 | GLOBAL_FRONTCOLOR=0x00ffffff; |
||
189 | } |
||
190 | } |
||
191 | if (MENU_SELECTED==1) { |
||
192 | if (Key=='a' && CURRENT_LEVEL>0) CURRENT_LEVEL--; |
||
193 | if (Key=='d' && CURRENT_LEVEL |
||
194 | HeroSides=LevelProps[CURRENT_LEVEL][2]; |
||
195 | } |
||
196 | if (MENU_SELECTED==2) { |
||
197 | if (Key=='a' && COLOR_INDEX>0) COLOR_INDEX--; |
||
198 | if (Key=='d' && COLOR_INDEX<6) COLOR_INDEX++; |
||
199 | HeroColor=RAINBOW_TABLE [COLOR_INDEX][0]; |
||
200 | GLOBAL_BLOCKCOLOR=RAINBOW_TABLE [COLOR_INDEX][1]; |
||
201 | GLOBAL_BATUTCOLOR=RAINBOW_TABLE [COLOR_INDEX][2]; |
||
202 | GLOBAL_PITCOLOR=RAINBOW_TABLE [COLOR_INDEX][3]; |
||
203 | GLOBAL_FLAGCOLOR=RAINBOW_TABLE [COLOR_INDEX][4]; |
||
204 | } |
||
205 | if (MENU_SELECTED==7 && (Key=='a' || Key=='d')) { |
||
206 | if (SAVE_FOLDER_TYPE==0) { |
||
207 | SAVE_FOLDER_TYPE=1; |
||
208 | } else { |
||
209 | SAVE_FOLDER_TYPE=0; |
||
210 | } |
||
211 | } |
||
212 | if (MENU_SELECTED==8 && (Key=='a' || Key=='d')) { |
||
213 | int i=0; |
||
214 | int j=0; |
||
215 | for (i=0; i |
||
216 | for (j=0; j |
||
217 | BufferDraw[i][j]=GLOBAL_BACKGROUNDCOLOR; |
||
218 | } |
||
219 | } |
||
220 | Update(); |
||
221 | if (DRAW_TECH==0) { |
||
222 | DRAW_TECH=1; |
||
223 | } else { |
||
224 | DRAW_TECH=0; |
||
225 | } |
||
226 | Update(); |
||
227 | |||
228 | } |
||
229 | if (MENU_SELECTED==4 && Key==' ') LoadData(); |
||
230 | if (MENU_SELECTED==5 && Key==' ') SaveData(); |
||
231 | if (MENU_SELECTED==6 && Key==' ') { |
||
232 | if (CURRENT_LEVEL>=3) { |
||
233 | DrawText (300,300,"error",GLOBAL_FRONTCOLOR); |
||
234 | DrawText (30,320,"(choose level 0/1/2 to edit them)",GLOBAL_FRONTCOLOR); |
||
235 | Update(); |
||
236 | _ksys_delay(200); |
||
237 | MENU_SELECTED=1; |
||
238 | } else { |
||
239 | GAME_TYPE=3; |
||
240 | Panel=1; |
||
241 | } |
||
242 | } |
||
243 | if (Key=='f' && CURRENT_LEVEL<3) { |
||
244 | GAME_TYPE=3; |
||
245 | Panel=1; |
||
246 | } |
||
247 | if (MENU_SELECTED==9 && Key==' ') GAME_TYPE=2; |
||
248 | |||
249 | |||
250 | DrawTitle (60,100,GLOBAL_FRONTCOLOR); |
||
251 | DrawText (100,300,"start game",GLOBAL_FRONTCOLOR); |
||
252 | DrawText (100,320,"choose level < >",GLOBAL_FRONTCOLOR); |
||
253 | IntToStr(CURRENT_LEVEL,NUMBER); |
||
254 | DrawText (345,320,NUMBER,GLOBAL_FRONTCOLOR); |
||
255 | DrawText (100,340,"hero color < >",GLOBAL_FRONTCOLOR); |
||
256 | DrawText (330, 340, RAINBOW_NAME [COLOR_INDEX], GLOBAL_FRONTCOLOR); |
||
257 | DrawText (100,360,"background color < >",GLOBAL_FRONTCOLOR); |
||
258 | if (GLOBAL_BACKGROUNDCOLOR==0) { |
||
259 | DrawText (430,360,"black",GLOBAL_FRONTCOLOR); |
||
260 | } else { |
||
261 | DrawText (430,360,"white",GLOBAL_FRONTCOLOR); |
||
262 | } |
||
263 | |||
264 | DrawText (100,400,"load game",GLOBAL_FRONTCOLOR); |
||
265 | DrawText (100,420,"save game",GLOBAL_FRONTCOLOR); |
||
266 | DrawText (100,440,"level editor",GLOBAL_FRONTCOLOR); |
||
267 | DrawText (100,460,"saveload folder < >",GLOBAL_FRONTCOLOR); |
||
268 | if (SAVE_FOLDER_TYPE==0) { |
||
269 | DrawText (400,460,"local",GLOBAL_FRONTCOLOR); |
||
270 | } else { |
||
271 | DrawText (400,460,"usbhd0/1/",GLOBAL_FRONTCOLOR); |
||
272 | } |
||
273 | DrawText (100,480,"redraw technology < >",GLOBAL_FRONTCOLOR); |
||
274 | if (DRAW_TECH==0) { |
||
275 | DrawText (450,480,"frame",GLOBAL_FRONTCOLOR); |
||
276 | } else { |
||
277 | DrawText (450,480,"lines",GLOBAL_FRONTCOLOR); |
||
278 | } |
||
279 | DrawText (100,520,"help",GLOBAL_FRONTCOLOR); |
||
280 | DrawText (100,540,"quit",GLOBAL_FRONTCOLOR); |
||
281 | DrawText (20,580,"developed by e_shi games 2014",GLOBAL_FRONTCOLOR); |
||
282 | |||
283 | if (MENU_SELECTED==0) DrawText (100,300,"start game",HeroColor); |
||
284 | if (MENU_SELECTED==1) DrawText (100,320,"choose level < >",HeroColor); |
||
285 | if (MENU_SELECTED==2) DrawText (100,340,"hero color < >",HeroColor); |
||
286 | if (MENU_SELECTED==3) DrawText (100,360,"background color < >",HeroColor); |
||
287 | if (MENU_SELECTED==4) DrawText (100,400,"load game",HeroColor); |
||
288 | if (MENU_SELECTED==5) DrawText (100,420,"save game",HeroColor); |
||
289 | if (MENU_SELECTED==6) DrawText (100,440,"level editor",HeroColor); |
||
290 | if (MENU_SELECTED==7) DrawText (100,460,"saveload folder < >",HeroColor); |
||
291 | if (MENU_SELECTED==8) DrawText (100,480,"redraw technology < >",HeroColor); |
||
292 | if (MENU_SELECTED==9) DrawText (100,520,"help",HeroColor); |
||
293 | if (MENU_SELECTED==10) DrawText (100,540,"quit",HeroColor); |
||
294 | |||
295 | |||
296 | } |
||
297 | |||
298 | |||
299 | |||
300 | |||
301 | |||
302 | void GamePlay () { |
||
303 | DrawLine (0,500,800,500,GLOBAL_FRONTCOLOR); |
||
304 | if (Objects==0 || DataBase[Objects-1][1]<=Width-40) { |
||
305 | ReadLevel(CURRENT_LEVEL); |
||
306 | } |
||
307 | |||
308 | if (HeroIsDead==0) { |
||
309 | if (isRestart==1) { |
||
310 | HeroAngle=(HeroAngle+10)%360; |
||
311 | HeroIsDead=CheckCollision(); |
||
312 | HeroY+=HeroFly; |
||
313 | DrawHero (125,HeroY, HeroSides, HeroAngle, HeroColor); |
||
314 | } else { |
||
315 | DrawHero (125,HeroY,HeroSides,HeroAngle,GLOBAL_FRONTCOLOR); |
||
316 | } |
||
317 | if (TO_NEXT_LEVEL>0) { |
||
318 | DrawText (Width-TO_NEXT_LEVEL,300,"jump to start new level",GLOBAL_FRONTCOLOR); |
||
319 | if (TO_NEXT_LEVEL<500) { |
||
320 | TO_NEXT_LEVEL+=2; |
||
321 | } else { |
||
322 | if (Key==' ' && TO_NEXT_LEVEL<=504) { |
||
323 | CURRENT_LEVEL++; |
||
324 | HeroSides=CURRENT_LEVEL; |
||
325 | if (CURRENT_LEVEL>MAX_LEVEL) MAX_LEVEL=CURRENT_LEVEL; |
||
326 | GLOBAL_CHECKPOINT=0; |
||
327 | TO_NEXT_LEVEL=505; |
||
328 | } |
||
329 | if (TO_NEXT_LEVEL>=505) { |
||
330 | TO_NEXT_LEVEL+=2; |
||
331 | if (TO_NEXT_LEVEL>1000) TO_NEXT_LEVEL=0; |
||
332 | } |
||
333 | } |
||
334 | |||
335 | } |
||
336 | |||
337 | } else { |
||
338 | GLOBAL_SPEED=0; |
||
339 | DeltaSpeed=0; |
||
340 | TO_NEXT_LEVEL=0; |
||
341 | HeroIsDead++; |
||
342 | DrawPew (125,HeroY,HeroIsDead,HeroColor); |
||
343 | if (HeroIsDead>100) { |
||
344 | ResetLevel(CURRENT_LEVEL); |
||
345 | if (GLOBAL_CHECKPOINT==0) { |
||
346 | isRestart=1; |
||
347 | HeroY=100; |
||
348 | } else { |
||
349 | isRestart=0; |
||
350 | HeroY=SPAWN_Y+41-DeltaH[HeroSides]; |
||
351 | if (HeroSides>7) HeroY-=22; |
||
352 | } |
||
353 | HeroIsDead=0; |
||
354 | HeroFly=0; |
||
355 | if (HeroSides%2==0) { |
||
356 | HeroAngle=360/(HeroSides*2); |
||
357 | } else { |
||
358 | HeroAngle=0; |
||
359 | } |
||
360 | } |
||
361 | } |
||
362 | if (Key=='f'&& CURRENT_LEVEL<3) { |
||
363 | int i=0; |
||
364 | Objects=0; |
||
365 | for (i=0; i<11; i++) LevelProps[i][0]=0; |
||
366 | isRestart=1; |
||
367 | HeroIsDead=0; |
||
368 | HeroY=100; |
||
369 | HeroFly=1; |
||
370 | TO_NEXT_LEVEL=0; |
||
371 | GAME_TYPE=3; |
||
372 | Panel=1; |
||
373 | } |
||
374 | if (Key==27) { |
||
375 | GLOBAL_CHECKPOINT=0; |
||
376 | int i=0; |
||
377 | for (i=0; i<11; i++) ResetLevel (i); |
||
378 | isRestart=1; |
||
379 | HeroIsDead=0; |
||
380 | HeroY=100; |
||
381 | HeroFly=1; |
||
382 | TO_NEXT_LEVEL=0; |
||
383 | if (CURRENT_LEVEL<3) { |
||
384 | GAME_TYPE=3; |
||
385 | Panel=1; |
||
386 | Key=' '; |
||
387 | } else { |
||
388 | GAME_TYPE=0; |
||
389 | } |
||
390 | } |
||
391 | } |
||
392 | |||
393 | void ShowHelp() { |
||
394 | DrawText (5,10,"controls",HeroColor); |
||
395 | DrawText (5,30,"w/a/s/d_choose in menu/editor",GLOBAL_FRONTCOLOR); |
||
396 | DrawText (5,50,"space_select/jump",GLOBAL_FRONTCOLOR); |
||
397 | DrawText (5,70,"escape_return to menu/exit",GLOBAL_FRONTCOLOR); |
||
398 | DrawText (5,100,"level editor notes",HeroColor); |
||
399 | DrawText (5,120,"press e to switch grid/tools panel",GLOBAL_FRONTCOLOR); |
||
400 | DrawText (5,140,"press q to switch grid/properties",GLOBAL_FRONTCOLOR); |
||
401 | DrawText (5,160,"select save game to save all levels",GLOBAL_FRONTCOLOR); |
||
402 | DrawText (5,180,"select load game to load all levels",GLOBAL_FRONTCOLOR); |
||
403 | DrawText (5,200,"select level 0/1/2 to play/edit",GLOBAL_FRONTCOLOR); |
||
404 | DrawText (5,220,"use f to go to level editor quickly",GLOBAL_FRONTCOLOR); |
||
405 | DrawText (5,240+20,"use start column to test level from",GLOBAL_FRONTCOLOR); |
||
406 | DrawText (5,260+20,"desired place (note _ you can test",GLOBAL_FRONTCOLOR); |
||
407 | DrawText (5,280+20,"level from column which contains",GLOBAL_FRONTCOLOR); |
||
408 | DrawText (5,300+20,"checkpoint)",GLOBAL_FRONTCOLOR); |
||
409 | DrawText (5,360,"redraw technology notes",HeroColor); |
||
410 | DrawText (5,380,"lines tech works faster but",GLOBAL_FRONTCOLOR); |
||
411 | DrawText (5,400,"sometimes it can be unstable",GLOBAL_FRONTCOLOR); |
||
412 | DrawText (5,420,"frame tech works slower but stable",GLOBAL_FRONTCOLOR); |
||
413 | |||
414 | if (Key=='f') { |
||
415 | GAME_TYPE=3; |
||
416 | Panel=1; |
||
417 | } |
||
418 | |||
419 | if (Key==27) GAME_TYPE=0; |
||
420 | } |
||
421 | |||
422 | void SaveArray() { |
||
423 | FILE *ArrTxt; |
||
424 | |||
425 | if (SAVE_FOLDER_TYPE==1) { |
||
426 | ArrTxt=fopen ("/usbhd0/1/LEVEL2D.txt","wb"); |
||
427 | } else { |
||
428 | ArrTxt=fopen ("LEVEL2D.txt","wb"); |
||
429 | } |
||
430 | if (ArrTxt==NULL) { |
||
431 | DrawText (100,300,"error (cannot save data)",GLOBAL_FRONTCOLOR); |
||
432 | Update(); |
||
433 | _ksys_delay(200); |
||
434 | Panel=1; |
||
435 | return; |
||
436 | } |
||
437 | char StringLevel[3*9*LEVEL_MAXLEN]="unsigned char NEW_LEVEL[9][LEVEL_MAXLEN]=\n{"; |
||
438 | int CurCharIndex=43; |
||
439 | int i=0; |
||
440 | int j=0; |
||
441 | for (i=0;i<9;i++) { |
||
442 | StringLevel[CurCharIndex]='{'; |
||
443 | CurCharIndex++; |
||
444 | for (j=0; j |
||
445 | StringLevel[CurCharIndex]= *(Levels[CURRENT_LEVEL]+i*LEVEL_MAXLEN+j)+48; |
||
446 | CurCharIndex++; |
||
447 | if (j |
||
448 | StringLevel[CurCharIndex]=','; |
||
449 | CurCharIndex++; |
||
450 | } |
||
451 | } |
||
452 | StringLevel[CurCharIndex]='}'; |
||
453 | CurCharIndex++; |
||
454 | if (i<8) { |
||
455 | StringLevel[CurCharIndex]=','; |
||
456 | CurCharIndex++; |
||
457 | } |
||
458 | StringLevel[CurCharIndex]='\n'; |
||
459 | CurCharIndex++; |
||
460 | } |
||
461 | StringLevel[CurCharIndex]='}'; |
||
462 | CurCharIndex++; |
||
463 | StringLevel[CurCharIndex]=';'; |
||
464 | CurCharIndex++; |
||
465 | StringLevel[CurCharIndex]='\0'; |
||
466 | fwrite (StringLevel,1,CurCharIndex,ArrTxt); |
||
467 | fclose (ArrTxt); |
||
468 | } |
||
469 | |||
470 | void LevelEditor () { |
||
471 | int i=0; |
||
472 | int j=0; |
||
473 | if (Panel==0) { |
||
474 | if (Key=='d' && Tile_X<399) Tile_X++; |
||
475 | if (Key=='a' && Tile_X>0) Tile_X--; |
||
476 | if (Key=='s' && Tile_Y<8) Tile_Y++; |
||
477 | if (Key=='w' && Tile_Y>0) Tile_Y--; |
||
478 | if (Key==' ') { |
||
479 | if (Tile_Type==5) { |
||
480 | for (i=0; i |
||
481 | *(Levels[CURRENT_LEVEL]+0*LEVEL_MAXLEN+Tile_X)=5; |
||
482 | } else { |
||
483 | *(Levels[CURRENT_LEVEL]+Tile_Y*LEVEL_MAXLEN+Tile_X)=Tile_Type; |
||
484 | } |
||
485 | } |
||
486 | } |
||
487 | if (Panel==1) { |
||
488 | if (Key=='s' && Tile_Type<5) Tile_Type++; |
||
489 | if (Key=='w' && Tile_Type>0) Tile_Type--; |
||
490 | } |
||
491 | if (Panel==2) { |
||
492 | if (Key=='s' && Q_SELECTED<5) Q_SELECTED++; |
||
493 | if (Key=='w' && Q_SELECTED>0) Q_SELECTED--; |
||
494 | if (Key==' ' && Q_SELECTED==0) { |
||
495 | GAME_TYPE=1; |
||
496 | if (GLOBAL_CHECKPOINT>0) { |
||
497 | int isCheck=0; |
||
498 | for (i=0;i<9; i++) { |
||
499 | int CurBlock=*(Levels[CURRENT_LEVEL]+i*LEVEL_MAXLEN+GLOBAL_CHECKPOINT); |
||
500 | if (CurBlock==4) { |
||
501 | SPAWN_Y=(i+1)*43+41+70-DeltaH[HeroSides]; |
||
502 | isCheck=1; |
||
503 | break; |
||
504 | } |
||
505 | } |
||
506 | if (isCheck==0) { |
||
507 | DrawText (100,300,"error (checkpoint not found)",GLOBAL_FRONTCOLOR); |
||
508 | Update(); |
||
509 | _ksys_delay(200); |
||
510 | GAME_TYPE=3; |
||
511 | Panel=1; |
||
512 | return; |
||
513 | } |
||
514 | ResetLevel(CURRENT_LEVEL); |
||
515 | isRestart=0; |
||
516 | HeroIsDead=0; |
||
517 | HeroFly=0; |
||
518 | HeroY=SPAWN_Y; |
||
519 | if (HeroSides>7) HeroY-=22; |
||
520 | if (HeroSides%2==0) { |
||
521 | HeroAngle=360/(HeroSides*2); |
||
522 | } else { |
||
523 | HeroAngle=0; |
||
524 | } |
||
525 | } |
||
526 | } |
||
527 | if (Q_SELECTED==1) { |
||
528 | if (Key=='d' && GLOBAL_CHECKPOINT<399) GLOBAL_CHECKPOINT++; |
||
529 | if (Key=='a' && GLOBAL_CHECKPOINT>0) GLOBAL_CHECKPOINT--; |
||
530 | } |
||
531 | if (Key==' ' && Q_SELECTED==2) { |
||
532 | for (i=0; i<9; i++) { |
||
533 | for (j=0; j |
||
534 | *(Levels[CURRENT_LEVEL]+i*LEVEL_MAXLEN+j)=0; |
||
535 | } |
||
536 | } |
||
537 | } |
||
538 | if (Key==' ' && Q_SELECTED==3) SaveArray(); |
||
539 | if (Q_SELECTED==4) { |
||
540 | if (Key=='a' && LevelProps[CURRENT_LEVEL][2]>3) LevelProps[CURRENT_LEVEL][2]--; |
||
541 | if (Key=='d' && LevelProps[CURRENT_LEVEL][2]<10) LevelProps[CURRENT_LEVEL][2]++; |
||
542 | HeroSides=LevelProps[CURRENT_LEVEL][2]; |
||
543 | } |
||
544 | if (Key==' ' && Q_SELECTED==5) GAME_TYPE=0; |
||
545 | } |
||
546 | if (Key=='e') { |
||
547 | if (Panel==0) { |
||
548 | Panel=1; |
||
549 | } else { |
||
550 | Panel=0; |
||
551 | } |
||
552 | } |
||
553 | if (Key=='q') { |
||
554 | if (Panel==0) { |
||
555 | Panel=2; |
||
556 | } else { |
||
557 | Panel=0; |
||
558 | } |
||
559 | } |
||
560 | //Draw grid |
||
561 | for (i=0; i<=10; i++) { |
||
562 | DrawLine (43*i,0,43*i,43*9,GLOBAL_FRONTCOLOR); |
||
563 | } |
||
564 | for (i=0; i<=9; i++) { |
||
565 | DrawLine (0,43*i,430,43*i,GLOBAL_FRONTCOLOR); |
||
566 | } |
||
567 | //Draw panel |
||
568 | DrawText (450,10,"e_tools",GLOBAL_FRONTCOLOR); |
||
569 | IntToStr (Tile_X,NUMBER); |
||
570 | DrawText (450,30,"(",GLOBAL_FRONTCOLOR); |
||
571 | DrawText (470,30,NUMBER,GLOBAL_FRONTCOLOR); |
||
572 | DrawText (530,30,"/",GLOBAL_FRONTCOLOR); |
||
573 | IntToStr (Tile_Y,NUMBER); |
||
574 | DrawText (550,30,NUMBER,GLOBAL_FRONTCOLOR); |
||
575 | DrawText (570,30,")",GLOBAL_FRONTCOLOR); |
||
576 | |||
577 | DrawLine (480,70,530,70,GLOBAL_FRONTCOLOR); |
||
578 | DrawLine (480,70,480,70+300,GLOBAL_FRONTCOLOR); |
||
579 | DrawLine (530,70,530,70+300,GLOBAL_FRONTCOLOR); |
||
580 | for (i=1;i<=6; i++) DrawLine (480,70+50*i,530,70+50*i,GLOBAL_FRONTCOLOR); |
||
581 | //Empty block |
||
582 | DrawLine (480+4,70+4,480+42,70+42,GLOBAL_FRONTCOLOR); |
||
583 | DrawLine (480+4,70+42,480+42,70+4,GLOBAL_FRONTCOLOR); |
||
584 | DrawBlock (480+4,70+4+50,GLOBAL_FRONTCOLOR); |
||
585 | DrawPit (480+7,70+4+100,GLOBAL_FRONTCOLOR); |
||
586 | DrawBatut (480+4,70+4+150,GLOBAL_FRONTCOLOR); |
||
587 | DrawFlag (480+8,70+4+200,GLOBAL_FRONTCOLOR); |
||
588 | DrawText (480+14,70+14+250,"f",GLOBAL_FRONTCOLOR); |
||
589 | DrawText (450,400,TILENAME [Tile_Type],GLOBAL_FRONTCOLOR); |
||
590 | |||
591 | //Draw properties |
||
592 | DrawText (10,410,"q_properties",GLOBAL_FRONTCOLOR); |
||
593 | DrawText (10,430+20,"test level",GLOBAL_FRONTCOLOR); |
||
594 | DrawText (10,470,"start column < >",GLOBAL_FRONTCOLOR); |
||
595 | IntToStr (GLOBAL_CHECKPOINT,NUMBER); |
||
596 | DrawText (270,470,NUMBER,GLOBAL_FRONTCOLOR); |
||
597 | DrawText (10,490,"reset level",GLOBAL_FRONTCOLOR); |
||
598 | DrawText (10,510,"save as 2d array (for developers)",GLOBAL_FRONTCOLOR); |
||
599 | DrawText (10,530,"hero sides < >",GLOBAL_FRONTCOLOR); |
||
600 | IntToStr (LevelProps[CURRENT_LEVEL][2],NUMBER); |
||
601 | DrawText (230,530,NUMBER,GLOBAL_FRONTCOLOR); |
||
602 | DrawText (10,550,"back to menu",GLOBAL_FRONTCOLOR); |
||
603 | |||
604 | if (Panel==0) { |
||
605 | DrawLine ((Tile_X%10)*43,0,(Tile_X%10)*43,400,HeroColor); |
||
606 | DrawLine ((Tile_X%10)*43+43,0,(Tile_X%10)*43+43,400,HeroColor); |
||
607 | DrawLine (0,(Tile_Y%10)*43,440,(Tile_Y%10)*43,HeroColor); |
||
608 | DrawLine (0,(Tile_Y%10)*43+43,440,(Tile_Y%10)*43+43,HeroColor); |
||
609 | } |
||
610 | if (Panel==1) { |
||
611 | DrawText (450,10,"e_tools",HeroColor); |
||
612 | DrawLine (480,70+Tile_Type*50,530,70+Tile_Type*50,HeroColor); |
||
613 | DrawLine (480,70+Tile_Type*50,480,70+50+Tile_Type*50,HeroColor); |
||
614 | DrawLine (480,70+Tile_Type*50+50,530,70+50+Tile_Type*50,HeroColor); |
||
615 | DrawLine (530,70+Tile_Type*50,530,70+Tile_Type*50+50,HeroColor); |
||
616 | DrawText (450,400,TILENAME [Tile_Type],HeroColor); |
||
617 | } |
||
618 | if (Panel==2) { |
||
619 | DrawText (10,410,"q_properties",HeroColor); |
||
620 | if (Q_SELECTED==0) DrawText (10,450,"test level",HeroColor); |
||
621 | if (Q_SELECTED==1) DrawText (10,470,"start column < >",HeroColor); |
||
622 | if (Q_SELECTED==2) DrawText (10,490,"reset level",HeroColor); |
||
623 | if (Q_SELECTED==3) DrawText (10,510,"save as 2d array (for developers)",HeroColor); |
||
624 | if (Q_SELECTED==4) DrawText (10,530,"hero sides < >",HeroColor); |
||
625 | if (Q_SELECTED==5) DrawText (10,550,"back to menu",HeroColor); |
||
626 | } |
||
627 | |||
628 | for (i=0; i<10; i++) { |
||
629 | for (j=0; j<9; j++) { |
||
630 | int CurBlock=*(Levels[CURRENT_LEVEL]+j*LEVEL_MAXLEN+Tile_X-Tile_X%10+i); |
||
631 | if (CurBlock==1) DrawBlock (43*i,43*j,GLOBAL_BLOCKCOLOR); |
||
632 | if (CurBlock==2) DrawPit (43*i,43*j,GLOBAL_PITCOLOR); |
||
633 | if (CurBlock==3) DrawBatut (43*i,43*j,GLOBAL_BATUTCOLOR); |
||
634 | if (CurBlock==4) DrawFlag (43*i,43*j,GLOBAL_FLAGCOLOR); |
||
635 | |||
636 | } |
||
637 | if (*(Levels[CURRENT_LEVEL]+0*LEVEL_MAXLEN+Tile_X-Tile_X%10+i)==5) { |
||
638 | for (j=0; j<9;j++) { |
||
639 | DrawText (43*i+10,43*j+10,"f",GLOBAL_FRONTCOLOR); |
||
640 | } |
||
641 | } |
||
642 | } |
||
643 | if (Key==27) { |
||
644 | GAME_TYPE=0; |
||
645 | } |
||
646 | } |
||
647 | |||
648 | void Authors () { |
||
649 | if (THE_END_COUNT>0) THE_END_COUNT--; |
||
650 | DrawText (240,10+THE_END_COUNT,"the end",HeroColor); |
||
651 | DrawText (10,40+THE_END_COUNT,"dev team",HeroColor); |
||
652 | DrawText (10,60+THE_END_COUNT,"game director _ shimanskey eugene",GLOBAL_FRONTCOLOR); |
||
653 | DrawText (10,80+THE_END_COUNT,"level designer _ chuduk alexander", GLOBAL_FRONTCOLOR); |
||
654 | DrawText (10,100+THE_END_COUNT,"programmer _ shimanskey eugene", GLOBAL_FRONTCOLOR); |
||
655 | DrawText (10,120+THE_END_COUNT,"font designer _ chuduk alexander", GLOBAL_FRONTCOLOR); |
||
656 | DrawText (10,170+THE_END_COUNT,"this game is dedicated to our",GLOBAL_FRONTCOLOR); |
||
657 | DrawText (10,190+THE_END_COUNT,"relatives and friends",GLOBAL_FRONTCOLOR); |
||
658 | if (Key==27) { |
||
659 | GAME_TYPE=0; |
||
660 | THE_END_COUNT=600; |
||
661 | } |
||
662 | } |
||
663 | |||
664 | |||
665 | int main(int argc, char **argv) { |
||
666 | _ksys_get_screen_size (&ScreenX, &ScreenY); |
||
667 | OffsetX=ScreenX/2-Width/2; |
||
668 | OffsetY=ScreenY/2-Height/2; |
||
669 | draw_window(); |
||
670 | |||
671 | int TIME_START=0; |
||
672 | int TIME_END=0; |
||
673 | int Delta_Hz=0; |
||
674 | |||
675 | TIME_START=_ksys_get_system_clock(); |
||
676 | while (!0) { |
||
677 | TIME_END=_ksys_get_system_clock(); |
||
678 | if (TIME_START==TIME_END) { |
||
679 | Delta_Hz++; |
||
680 | } else { |
||
681 | OLD_FPS=NEW_FPS; |
||
682 | NEW_FPS=Delta_Hz; |
||
683 | TIME_START=TIME_END; |
||
684 | Delta_Hz=0; |
||
685 | } |
||
686 | _ksys_delay((OLD_FPS+NEW_FPS)/120); |
||
687 | Key=getKey(); |
||
688 | if (GAME_TYPE==-1) return 0; |
||
689 | if (GAME_TYPE==0) MainMenu (); |
||
690 | if (GAME_TYPE==1) GamePlay (); |
||
691 | if (GAME_TYPE==2) ShowHelp (); |
||
692 | if (GAME_TYPE==3) LevelEditor(); |
||
693 | if (GAME_TYPE==4) Authors(); |
||
694 | Update(); |
||
695 | |||
696 | } |
||
697 | }9;j++)>9;>10;>>>>>=6;>=9;>=10;>10)>9;>399)>9;>5)>5)>8)>399)>8)>9;i++)>3)>11;>11;>3)>=504)>500)>=Width-40)>>>>>>>>>>>3)>6)>0)> |