Anupznk

after combining mine with sb

Sep 8th, 2019
158
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # include "iGraphics.h"
  2. # include "gl.h"
  3. # include <Windows.h>
  4. #include<math.h>
  5. #include<stdio.h>
  6. int man_x=10, man_y=150;
  7. int dx, dy;
  8. int sprint=0;
  9. int lasercolorR = 0,lasercolorG = 0,lasercolorB = 0, changecolor = 0;
  10. //int laser_x[]={300,250},laser_y[]={200,150}
  11. int movingLaserRange_x1[]={40,500,100,50},movingLaserRange_x2[]={500,900,600,500},laserMove[]={1,1,1,1},laserLen=500;
  12. int laser_x[]={300,700,200,500},laser_y[]={190,270,400,500};
  13. int horizontal_laser_count=4;
  14. int vertical_movingLaserRange_y1[]={550,300},vertical_movingLaserRange_y2[]={650,500},vertical_laserMove[]={0,1};
  15. int vertical_laser_x[]={850,700},vertical_laser_y[]={600,400};
  16. int vertical_laser_count=2;
  17. int level=0;
  18. double health=100;
  19. double health_x[]={600,300,900},health_y[]={768,768,768},hel_initial_x,hel_initial_y;
  20. int health_taken=0,pack_len,pack_wid;//,health_yes
  21. int man_wid,man_height;
  22. int man_mov_right=1,man_mov_left=0,man_mov_up=0,man_mov_down=0;
  23. int mouse_clk=0;
  24. int stop_sound=0;
  25. int bg=1;
  26. double bomb_x[]={1336,1000,300,0},bomb_y[]={768,768,768,300},bomb_x_change[]={-2,-1.5,2,2},bomb_y_change[]={-1,-1.5,-1.5,1},
  27. bomb_initial_x,bomb_initial_y,bomb_r=8;
  28. double d[5];//for bomb_chk
  29. int hel_tm,health_pack_chk,hel_pck_num;
  30. int bomb_tm,bomb_chk,bomb_cnt;
  31. int back_from_howto=0,back_from_high=0;
  32. int cont=0,new_game=0,high_score=0,how_to_play=0,cont_chk=1;
  33. int gem_collected[]={0,0,0};
  34. int game_over=0, game_over_y=0,game_end;
  35. double max_score_count=0;
  36. int score_count[]={0,0,0,0,0},current_score=0;
  37. double timer=0;
  38. int score_multiplier=1;
  39. int dead_man_x,dead_man_y;
  40. float camx=0, camy=0;
  41. int leftkbhit = 0, rightkbhit = 0, camxLSCount = 0, camxRSCount = 0;
  42. float enemyFX = 1500, enemyFY=600;
  43.  
  44.  
  45. //ENEMY VARIABLES:
  46. float enemyX[4] = {200, 400, 600, 1000}, enemyY[4] = {50,100,150,300};
  47. float enemyHealth[4] = {100,100,100,100};
  48. int enemyHitIndex;
  49.  
  50. //LASER VARIABLES:
  51. float laserEnd;
  52. int laserSwitch = 0, laserTimer=0, laserStat = 0;
  53. float laserHealth = 100;
  54. int manLeft = 0, manRight = 1;
  55.  
  56.  
  57. void menu_sound()
  58. {
  59. if(level==0)
  60. PlaySound("music\\menu background.wav", NULL, SND_LOOP | SND_ASYNC);
  61. else
  62. PlaySound(NULL, NULL, SND_ASYNC);
  63.  
  64. }
  65. void pause_menu_sound()
  66. {
  67. if(level==0)
  68. PlaySound("music\\Pause menu.wav", NULL, SND_LOOP | SND_ASYNC);
  69. else
  70. PlaySound(NULL, NULL, SND_ASYNC);
  71.  
  72. }
  73. void score_page_sound()
  74. {
  75. if( high_score)
  76. PlaySound("music\\high score.wav", NULL, SND_ASYNC);
  77. else if(high_score==0)
  78. PlaySound(NULL, NULL, SND_ASYNC);
  79.  
  80. }
  81. void level_one_sound()
  82. {
  83. if(level==1 && game_over==0)
  84. PlaySound("music\\game background.wav", NULL, SND_LOOP | SND_ASYNC);
  85. else
  86. PlaySound(NULL, NULL,SND_ASYNC);
  87.  
  88. }
  89.  
  90.  
  91. void game_over_sound()
  92. {
  93. if(game_over)
  94. PlaySound("music\\Game_Over.wav", NULL, SND_ASYNC);
  95. else
  96. PlaySound(NULL, NULL, SND_ASYNC);
  97.  
  98.  
  99. }
  100.  
  101. /*
  102. ********************************** FOLLOWING AND STATIC ENEMY CODE *********************************************************
  103. */
  104.  
  105. void enemy()
  106. {
  107. iSetColor(0,0,255);
  108. for(int i = 0; i<4; i++)
  109. {
  110. if(enemyHealth[i]>10)
  111. iRectangle((enemyX[i]-camx), (enemyY[i]-camy), 100, 100);
  112. }
  113.  
  114. }
  115.  
  116. float laserEndDetect(float laserX, float laserY) //FUNCTION TO DETECT THE ENDING POINT OF A LASER
  117. {
  118. float matchX[100]; //KEEPS RECORD OF ALL X'S WHICH MATCH THE REQUIREMENTS
  119. int c=0; //KEEPS TRACK OF THE NUMBER OF ELEMENTS IN ARRAY AKA THE NUMBER OF MATCHES+1 (REASON BELOW)
  120.  
  121. if(manRight)
  122. {
  123. for(int i=0; i<4; i++)
  124. {
  125.  
  126. if(laserY-(enemyY[i]-camy)>0 && laserY-(enemyY[i]-camy)<100 && laserX<(enemyX[i]-camx) && enemyHealth[i]>0.01)
  127. {
  128. //POPULATING THE ARRAY
  129. matchX[c] = (enemyX[i]-camx);
  130.  
  131. c++; //CAUSES C TO ALWAYS BE LARGER BY 1
  132.  
  133.  
  134. }
  135. }
  136.  
  137. if(!c)//IF THERE ARE NO MATCHES
  138. {
  139. enemyHitIndex = -1;
  140. return 2000; //INFINITE LASER
  141. }
  142.  
  143.  
  144. else
  145. {
  146. //finding the minimum
  147.  
  148. float minX = matchX[0];
  149. for(int i = 0; i<c; i++)
  150. {
  151. if(matchX[i]<minX)
  152. minX = matchX[i];
  153.  
  154. }
  155.  
  156. for(int i=0; i<4; i++)
  157. {
  158. if(minX == (enemyX[i]-camx))
  159. enemyHitIndex = i;
  160. }
  161.  
  162. return minX;
  163. }
  164. }
  165.  
  166. if(manLeft)
  167. {
  168. for(int i=0; i<4; i++)
  169. {
  170.  
  171. if(laserY-(enemyY[i]-camy)>0 && laserY-(enemyY[i]-camy)<100 && laserX>(enemyX[i]-camx) && enemyHealth[i]>0.01)
  172. {
  173. //POPULATING THE ARRAY
  174. matchX[c] = (enemyX[i]-camx);
  175. c++; //CAUSES C TO ALWAYS BE LARGER BY 1
  176.  
  177.  
  178. }
  179. }
  180.  
  181. if(!c)//IF THERE ARE NO MATCHES
  182. {
  183. enemyHitIndex = -1;
  184. return -2000; //INFINITE LASER
  185. }
  186.  
  187.  
  188. else
  189. {
  190. //finding the minimum
  191.  
  192. float minX = matchX[0];
  193. for(int i = 0; i<c; i++)
  194. {
  195. if(matchX[i]<minX)
  196. minX = matchX[i];
  197.  
  198. }
  199.  
  200. for(int i=0; i<4; i++)
  201. {
  202. if(minX == (enemyX[i]-camx))
  203. enemyHitIndex = i;
  204. }
  205.  
  206. return minX+100;
  207. }
  208. }
  209. }
  210.  
  211. void reduceEnemyHealth() //FUNCTION TO REDUCE ENEMY HEALTH TO 0
  212. {
  213. if(laserSwitch == 1 && enemyHitIndex != -1)
  214. {
  215. if(enemyHealth[enemyHitIndex]>=0)
  216. {
  217. enemyHealth[enemyHitIndex]-=2;
  218. }
  219. }
  220. }
  221.  
  222. void laser()
  223. {
  224.  
  225. if(manRight)
  226. {
  227. float laserX = man_x+60;
  228. float laserY = man_y+70;
  229. iSetColor(255,0,0);
  230. iLine(laserX, laserY, laserEndDetect(laserX, laserY), laserY);
  231.  
  232. }
  233.  
  234. if(manLeft)
  235. {
  236. float laserX = man_x;
  237. float laserY = man_y+90;
  238. iSetColor(255,0,0);
  239. iLine(laserX, laserY, laserEndDetect(laserX, laserY), laserY);
  240. }
  241.  
  242. }
  243.  
  244.  
  245.  
  246. void enemyF()
  247. {
  248. iSetColor(0,0,0);
  249. iRectangle(enemyFX-camx, enemyFY-camy, 10, 10);
  250. }
  251.  
  252. void changeEnemy()
  253. {
  254.  
  255. if((enemyFX-camx<man_x+200)&&(enemyFX-camx>man_x-100) && (enemyFY-camy<man_y+200) && (enemyFY-camy>man_y-100))
  256. return;
  257.  
  258.  
  259. if(enemyFX-camx-man_x>10 || man_x-enemyFX+camx>10)
  260. {
  261. if(enemyFX-camx>man_x)
  262. enemyFX-=10;
  263. else
  264. enemyFX+=10;
  265.  
  266. if(enemyFY-camy>man_y)
  267. {
  268. enemyFY-=10*((enemyFY-man_y)/abs(enemyFX-man_x));
  269. }
  270.  
  271. else if(enemyFY-camy<man_y)
  272. {
  273. enemyFY+=10*((man_y-(enemyFY-camy))/abs(enemyFX-camx-man_x));
  274. }
  275.  
  276. }
  277.  
  278.  
  279.  
  280. }
  281. void changelasercolor(){
  282.  
  283. if(changecolor==0 && lasercolorR!=255)
  284. {
  285. lasercolorR+=15; // to change color faster
  286. if(lasercolorR==255)
  287. {
  288. changecolor=1;
  289. }
  290. }
  291. if(changecolor==1 && lasercolorR!=0)
  292. {
  293. lasercolorR-=15; // to change color faster
  294. if(lasercolorR==0)
  295. {
  296. changecolor=0;
  297. }
  298. }
  299.  
  300. }
  301.  
  302.  
  303. /*
  304. function iMouseMove() is called when the user presses and drags the mouse.
  305. (mx, my) is the position where the mouse pointer is.
  306. */
  307. void iMouseMove(int mx, int my)
  308. {
  309. //place your codes here
  310. }
  311.  
  312. /*
  313. function iMouse() is called when the user presses/releases the mouse.
  314. (mx, my) is the position where the mouse pointer is.
  315. */
  316. void iMouse(int button, int state, int mx, int my)
  317. {
  318. if(button == GLUT_LEFT_BUTTON && state == GLUT_DOWN && level!=1)
  319. {
  320. if(mx>=185 && mx<=185+270 && my>=382 && my<=382+100)
  321. {
  322. cont=1;
  323. //cont_chk=1;
  324. new_game=0;
  325. how_to_play=0;
  326. high_score=0;
  327. back_from_howto=0;
  328. back_from_high=0;
  329. //iText(500,500,"Continue");
  330.  
  331. // FILE* fp1,*fp2,*fp3,*fp4,*fp5,*fp6,*fp7,*fp8,*fp9,*fp10,*fp11, *fp12;
  332. // fp1=fopen("man_x_man_y.txt","r");
  333. // fscanf(fp1,"%d %d",&man_x,&man_y);
  334. // fclose(fp1);
  335. //
  336. // fp2=fopen("dx_dy.txt","r");
  337. // fscanf(fp2,"%d %d",&dx,&dy);
  338. // fclose(fp2);
  339. //
  340. //
  341. // fp3=fopen("horizontal_laser.txt","r");
  342. // fscanf(fp3,"%d %d %d %d",&laser_x[0],&laser_x[1],&laser_x[2],&laser_x[3]);
  343. // fclose(fp3);
  344. //
  345. //
  346. // fp4=fopen("vertical_laser.txt","r");
  347. // fscanf(fp4,"%d %d",&vertical_laser_y[0],&vertical_laser_y[1]);
  348. // fclose(fp4);
  349. //
  350. //
  351. // fp5=fopen("bomb1.txt","r");
  352. // fscanf(fp5,"%d %d %d",&bomb_cnt,&bomb_chk,&bomb_tm);
  353. // fclose(fp5);
  354. //
  355. //
  356. // fp6=fopen("bomb2.txt","r");
  357. // fscanf(fp6,"%f %f %f %f %f %f",&bomb_x[bomb_cnt-1],&bomb_y[bomb_cnt-1],&bomb_x_change[bomb_cnt-1],&bomb_y_change[bomb_cnt-1],&bomb_initial_x,&bomb_initial_y);
  358. // fclose(fp6);
  359. //
  360. //
  361. // fp7=fopen("health.txt","r");
  362. // fscanf(fp7,"%f",&health);
  363. // fclose(fp7);
  364. //
  365. //
  366. // fp8=fopen("health_pack1.txt","r");
  367. // fscanf(fp8,"%d %d %d",&hel_pck_num,&health_pack_chk,&hel_tm);
  368. // fclose(fp8);
  369. //
  370. //
  371. // fp9=fopen("health_pack_2.txt","r");
  372. // fscanf(fp9,"%lf %lf %d %d",&health_x[hel_pck_num-1],&health_y[hel_pck_num-1],&hel_initial_x,&hel_initial_y);
  373. // fclose(fp9);
  374. //
  375. //
  376. // fp10=fopen("timer.txt","r");
  377. // fscanf(fp10,"%f",&timer);
  378. // fclose(fp10);
  379. //
  380. // fp11=fopen("score.txt","r");
  381. // fscanf(fp11,"%f",&score_count);
  382. // fclose(fp11);
  383. //
  384. // fp12=fopen("high score list.txt","r");
  385. // for(int i=0;i<5;i++)
  386. // {
  387. // fscanf(fp12,"%d ",&score_count[i]);
  388. // }
  389. // fclose(fp12);
  390.  
  391. level=1;
  392. menu_sound();
  393. level_one_sound();
  394. }
  395.  
  396. if(mx>=185 && mx<=185+295 && my>=302 && my<=382 && level!=1)
  397. {
  398.  
  399. new_game=1;
  400. score_multiplier=1;
  401. score_count[0]=0;
  402. score_count[1]=0;
  403. score_count[2]=0;
  404. score_count[3]=0;
  405. score_count[4]=0;
  406. current_score=0;
  407. man_x=30, man_y=150;
  408. health=100;
  409. sprint=0;
  410. cont=0;
  411. level=1;
  412. man_mov_right=1;
  413. man_mov_down=0;
  414. man_mov_left=0;
  415. man_mov_up=0;
  416. man_x=10;
  417. man_y=150;
  418. dx=3, dy=3;
  419. sprint=0;
  420. lasercolorR = 0,lasercolorG = 0,lasercolorB = 0, changecolor = 0;
  421.  
  422. laserMove[0]=1;
  423. laserMove[1]=1;
  424. laserMove[2]=1;
  425. laserMove[3]=1;
  426.  
  427. laser_x[0]=300;
  428. laser_x[1]=700;
  429. laser_x[2]=200;
  430. laser_x[3]=500;
  431.  
  432. laser_y[0]=190;
  433. laser_y[1]=270;
  434. laser_y[2]=400;
  435. laser_y[3]=500;
  436.  
  437. vertical_laserMove[0]=0;
  438. vertical_laserMove[1]=1;
  439.  
  440.  
  441. vertical_laser_x[0]=850;
  442. vertical_laser_x[1]=700;
  443.  
  444. vertical_laser_y[0]=600;
  445. vertical_laser_y[1]=400;
  446.  
  447. vertical_laser_count=2;
  448. health=100;
  449. // health_x[]={600,300,900},health_y[]={768,768,768};
  450.  
  451. health_x[0]=600;
  452. health_x[1]=300;
  453. health_x[2]=900;
  454.  
  455. health_y[0]=768;
  456. health_y[1]=768;
  457. health_y[2]=768;
  458.  
  459. hel_tm=0,health_pack_chk=0,hel_pck_num=0;
  460.  
  461. health_taken=0;//health_yes
  462.  
  463. bomb_x[0]=1336;
  464. bomb_x[2]=1000;
  465. bomb_x[2]=300;
  466. bomb_x[3]=0;
  467.  
  468. bomb_y[0]=768;
  469. bomb_y[1]=768;
  470. bomb_y[2]=768;
  471. bomb_y[3]=300;
  472.  
  473. bomb_tm=0,bomb_chk=0,bomb_cnt=0;
  474.  
  475. gem_collected[0]=0;
  476. gem_collected[1]=0;
  477. gem_collected[2]=0;
  478.  
  479. how_to_play=0;
  480. high_score=0;
  481. back_from_howto=0;
  482. back_from_high=0;
  483. level=1;
  484. menu_sound();
  485. level_one_sound();
  486. }
  487.  
  488. if(mx>=185 && mx<=185+315 && my>=222&& my<=222+80 && level!=1)
  489. {
  490. cont=0;
  491. new_game=0;
  492. how_to_play=0;
  493. high_score=1;
  494. // level=-1;
  495. menu_sound();
  496. score_page_sound();
  497.  
  498. back_from_howto=0;
  499. back_from_high=0;
  500. //level=1;
  501. }
  502.  
  503. if(mx>=185 && mx<=185+350 && my>=142 && my<=142+80 && level!=1)
  504.  
  505. {
  506. cont=0;
  507. new_game=0;
  508. how_to_play=1;
  509. high_score=0;
  510. back_from_howto=0;
  511. back_from_high=0;
  512. //level=1;
  513. }
  514. if( how_to_play && mx>=603 && mx<=603+180 && my>=50 && my<=50+65 && level!=1)
  515. {
  516. back_from_howto=1;
  517. back_from_high=0;
  518. }
  519. if( high_score && mx>=603 && mx<=603+180 && my>=50 && my<=50+65 && level!=1)
  520. {
  521. back_from_howto=0;
  522. back_from_high=1;
  523. high_score=0;
  524. score_page_sound();
  525. menu_sound();
  526.  
  527. }
  528. }
  529.  
  530. if(button == GLUT_RIGHT_BUTTON && state == GLUT_DOWN)
  531. {
  532. //place your codes here
  533. }
  534. }
  535.  
  536. /*
  537. function iKeyboard() is called whenever the user hits a key in keyboard.
  538. key- holds the ASCII value of the key pressed.
  539. */
  540. void iKeyboard(unsigned char key)
  541. {
  542. if((key=='p'||key=='P') && game_over!=1){
  543. level=0;
  544. game_over=0;
  545. new_game=0;
  546. cont=0;
  547. level_one_sound();
  548. pause_menu_sound();
  549. }
  550.  
  551. if(key == 13 && !laserStat)
  552. {
  553. laserSwitch = 1;
  554. }
  555.  
  556. }
  557.  
  558. /*
  559. function iSpecialKeyboard() is called whenver user hits special keys like-
  560. function keys, home, end, pg up, pg down, arraows etc. you have to use
  561. appropriate constants to detect them. A list is:
  562. GLUT_KEY_F1, GLUT_KEY_F2, GLUT_KEY_F3, GLUT_KEY_F4, GLUT_KEY_F5, GLUT_KEY_F6,
  563. GLUT_KEY_F7, GLUT_KEY_F8, GLUT_KEY_F9, GLUT_KEY_F10, GLUT_KEY_F11, GLUT_KEY_F12,
  564. GLUT_KEY_LEFT, GLUT_KEY_UP, GLUT_KEY_RIGHT, GLUT_KEY_DOWN, GLUT_KEY_PAGE UP,
  565. GLUT_KEY_PAGE DOWN, GLUT_KEY_HOME, GLUT_KEY_END, GLUT_KEY_INSERT
  566.  
  567. */
  568. void iSpecialKeyboard(unsigned char key)
  569. {
  570. if(key == GLUT_KEY_DOWN)
  571. {
  572. dy=3;
  573. if(sprint%2==1)
  574. dy=8;
  575.  
  576. if(man_y<=100 && camy!=0)
  577. {
  578. camy-=dy;
  579. }
  580.  
  581. if(man_y>100 && camy!=0)
  582. {
  583. man_y-=dy;
  584. }
  585.  
  586. if(camy==0 && man_y>10)
  587. {
  588. man_y-=dy;
  589. }
  590.  
  591.  
  592. man_mov_down=1;
  593. man_mov_left=0;
  594. man_mov_right=0;
  595. man_mov_up=0;
  596.  
  597. }
  598. if(key == GLUT_KEY_UP)
  599. {
  600. dy=3;
  601. if(sprint%2==1)
  602. dy=8;
  603.  
  604. if(man_y<400)
  605. man_y+=dy;
  606.  
  607. else if(camy<500)
  608. {
  609. camy+=dy;
  610. }
  611.  
  612. man_mov_down=0;
  613. man_mov_left=0;
  614. man_mov_right=0;
  615. man_mov_up=1;
  616. }
  617. if(key == GLUT_KEY_RIGHT)
  618. {
  619. dx=10;
  620. if(sprint%2==1)
  621. dx=8;
  622.  
  623. manLeft=0;
  624. manRight=1;
  625.  
  626. if(man_x<1246)
  627. {
  628.  
  629. //COORDINATION BETWEEN MAN AND CAMERA: FIRST 500 UNITS WITHOUT CHANGING THE CAMERA POSITION
  630. if(man_x<=500)
  631. {
  632. man_x+=dx;
  633. }
  634. //MIDDLE MOVEMENT HAPPENS WHEN MAN X TIRES TO EXCEED 400 AND CAMERA IS BETWEEN 0 AND 1000
  635. else if(man_x>500)
  636. {
  637. if(camx<=1000)
  638. camx+=dx;
  639. }
  640.  
  641. //STOPPING THE CAMERA AFTER CAMERA X TRIES TO EXCEED 1000
  642. if(camx>1000)
  643. {
  644. man_x+=dx;
  645. }
  646.  
  647.  
  648. }
  649.  
  650.  
  651. man_mov_down=0;
  652. man_mov_left=0;
  653. man_mov_right=1;
  654. man_mov_up=0;
  655.  
  656. }
  657. if(key == GLUT_KEY_LEFT)
  658. {
  659. dx=15;
  660. if(sprint%2==1)
  661. dx=8;
  662.  
  663. manLeft=1;
  664. manRight=0;
  665.  
  666. //BASE CONDITION: UNTIL THE MAN REACHES 10
  667. if(man_x>10)
  668. {
  669.  
  670. //ONCE CAMX TRIES TO GO TO A NEGATIVE VALUE, REDUCE man_x UP TILL BASE CONDITION AT THE TOP
  671.  
  672. if(camx<0)
  673. {
  674. man_x-=dx;
  675. }
  676.  
  677.  
  678. //IF CAMERA X IS GREATER THAN 1000 (5 added to make small buffer (ALWAYS LESS THAN dx))
  679. else if(camx>=1000)
  680. {
  681. // MOVE THE MAN UPTIL man_x=800
  682. if(man_x>=600)
  683. {
  684. man_x-=dx;
  685. }
  686.  
  687. }
  688.  
  689. //IF man_x TRIES TO GO BELOW 800, REDUCE CAMERA X UNTIL CAMERA X BECOMES EQUAL TO 0
  690. if(man_x<600)
  691. {
  692. if(camx>=0)
  693. camx-=dx;
  694. }
  695. }
  696.  
  697.  
  698. man_mov_down=0;
  699. man_mov_left=1;
  700. man_mov_right=0;
  701. man_mov_up=0;
  702.  
  703.  
  704. }
  705. if(key== GLUT_KEY_PAGE_DOWN)
  706. {
  707. sprint++;
  708. }
  709.  
  710. // while(key == GLUT_KEY_PAGE_UP)
  711. // {
  712. // }
  713.  
  714. if(key == GLUT_KEY_END)
  715. exit(0);
  716. }
  717. void health_change(int i)
  718. {
  719. if((man_x>=laser_x[i]-camx-man_wid && man_x<=laser_x[i]-camx+100) && (man_y>=laser_y[i]-camy-man_height && man_y<=laser_y[i]-camy+2))
  720. {
  721. FILE *fp;
  722. man_x-=2;
  723. man_y+=2;
  724. if(health>0)
  725. health-=1;
  726. stop_sound=1;
  727. fp=fopen("health.txt","w");
  728. fprintf(fp,"%d",health);
  729. fclose(fp);
  730. }
  731.  
  732. }
  733. void vertical_health_change(int i)
  734. {
  735.  
  736. if((man_y>=vertical_laser_y[i]-camy-man_height && man_y<=vertical_laser_y[i]-camy+100) && (man_x>=vertical_laser_x[i]-camx-man_wid && man_x<=vertical_laser_x[i]-camx+3))
  737. {
  738. man_x-=2;
  739. man_y-=2;
  740. if(health>0)
  741. health-=1;
  742. //stop_sound=1;
  743.  
  744. }
  745.  
  746.  
  747. }
  748.  
  749. void horizontalLaser(int laserLen,int i)
  750. {
  751. iSetColor(lasercolorR,255,lasercolorB);
  752. iFilledRectangle(laser_x[i]-camx,laser_y[i]-camy,laserLen,3);
  753. iSetColor(0,255,0);
  754. iFilledRectangle(laser_x[i]-camx-10,laser_y[i]-camy-3,10,10);
  755.  
  756. iSetColor(0,255,0);
  757. iFilledRectangle(laser_x[i]-camx+100,laser_y[i]-camy-3,10,10);
  758.  
  759. }
  760. void verticalLaser(int laserLen,int i)
  761. {
  762. iSetColor(lasercolorR,255,lasercolorB);
  763. iFilledRectangle(vertical_laser_x[i]-camx,vertical_laser_y[i]-camy,3,laserLen);
  764. iSetColor(0,255,0);
  765. iFilledRectangle(vertical_laser_x[i]-camx-3,vertical_laser_y[i]-camy-10,10,10);
  766. iSetColor(0,255,0);
  767. iFilledRectangle(vertical_laser_x[i]-camx-3,vertical_laser_y[i]-camy+100,10,10);
  768. }
  769. void healthPack()
  770. {
  771. if(health_pack_chk){
  772. if(hel_pck_num<=3)
  773. {
  774. pack_len=26, pack_wid=22;
  775. iSetColor(211,211,211);
  776. iFilledRectangle(health_x[hel_pck_num-1]-camx,health_y[hel_pck_num-1]-camy,pack_len,pack_wid);
  777. iSetColor(0,0,0);
  778. iFilledRectangle(health_x[hel_pck_num-1]-camx+(pack_len/2)-2,health_y[hel_pck_num-1]+3-camy,4,pack_wid-6);
  779. iFilledRectangle(health_x[hel_pck_num-1]+3-camx,health_y[hel_pck_num-1]+(pack_wid/2)-2-camy,pack_len-6,4);
  780. if(health_y[hel_pck_num-1]>0)
  781. health_y[hel_pck_num-1]-=.5;
  782. }
  783. if((man_x>=health_x[hel_pck_num-1]-man_wid-camx && man_x<=health_x[hel_pck_num-1]+pack_len-camx) && (man_y>=health_y[hel_pck_num-1]-man_height-camy && man_y<=health_y[hel_pck_num-1]+pack_wid-camy))
  784. {
  785. //health_taken=1;
  786. health_x[hel_pck_num-1]=-10; //making the healthpacks disappear
  787. health_y[hel_pck_num-1]=-10;
  788. if (health>=80)
  789. health=100;
  790. else
  791. health+=20;
  792. health_pack_chk=0;
  793. }
  794. if(health_y[hel_pck_num-1]<=50){
  795. health_pack_chk=0;
  796. health_x[hel_pck_num-1]=hel_initial_x;
  797. health_y[hel_pck_num-1]=hel_initial_y;
  798. }
  799. }
  800.  
  801. }
  802. void bomb()
  803. {
  804. // BOMB ER RESPONSE CAM DEPENDENT KORA LAGBE
  805. // SUMON ER CODE
  806.  
  807. if(bomb_chk){
  808. iSetColor(255,0,0);
  809. iFilledCircle(bomb_x[bomb_cnt-1],bomb_y[bomb_cnt-1],bomb_r,100);
  810. bomb_x[bomb_cnt-1]+=bomb_x_change[bomb_cnt-1];
  811. bomb_y[bomb_cnt-1]+=bomb_y_change[bomb_cnt-1];
  812. d[0]=sqrt((man_x-bomb_x[bomb_cnt-1])*(man_x-bomb_x[bomb_cnt-1])+(man_y-bomb_y[bomb_cnt-1])*(man_y-bomb_y[bomb_cnt-1]));
  813. d[1]=sqrt(((man_x+man_wid)-bomb_x[bomb_cnt-1])*((man_x+man_wid)-bomb_x[bomb_cnt-1])+(man_y-bomb_y[bomb_cnt-1])*(man_y-bomb_y[bomb_cnt-1]));
  814. d[2]=sqrt((man_x-bomb_x[bomb_cnt-1])*(man_x-bomb_x[bomb_cnt-1])+((man_y+man_height)-bomb_y[bomb_cnt-1])*((man_y+man_height)-bomb_y[bomb_cnt-1]));
  815. d[3]=sqrt(((man_x+man_wid)-bomb_x[bomb_cnt-1])*((man_x+man_wid)-bomb_x[bomb_cnt-1])+((man_y+man_height)-bomb_y[bomb_cnt-1])*((man_y+man_height)-bomb_y[bomb_cnt-1]));
  816. if(d[0]<=bomb_r||d[1]<=bomb_r||d[2]<=bomb_r||d[3]<=bomb_r){
  817. if(health>2)
  818. health-=2;
  819. else
  820. health=0;
  821. }
  822. if(bomb_y[bomb_cnt-1]<=50||bomb_y[3]>=768){
  823. bomb_chk=0;
  824. bomb_x[bomb_cnt-1]=bomb_initial_x;
  825. bomb_y[bomb_cnt-1]=bomb_initial_y;
  826. }
  827.  
  828. }
  829. }
  830. void score_show_live()
  831. {
  832. char curr_score[100], buf[100];
  833. strcpy(curr_score,"CURRENT SCORE: ");
  834. strcat(curr_score,itoa(current_score,buf,10));
  835. iSetColor(255,0,0);
  836. iText(10,750,curr_score);
  837.  
  838. char score_mul[100];
  839. strcpy(score_mul,"SCORE MULTIPLIER: X");
  840. strcat(score_mul,itoa(score_multiplier,buf,10));
  841. iSetColor(255,0,0);
  842. iText(10,730,score_mul);
  843.  
  844. char hi_score[100];
  845. strcpy(hi_score,"HIGH SCORE: ");
  846. strcat(hi_score,itoa(score_count[0],buf,10));
  847. iSetColor(255,0,0);
  848. iText(10,710,hi_score);
  849. }
  850.  
  851. void score()
  852. {
  853. current_score+=1*score_multiplier;
  854. }
  855. //void gem_collection(int man_x, int man_y)
  856. //{
  857. // int gem_cou;
  858. // if(man_x>=1000 && man_x<=1000+40 && man_y>=700 && man_y<=700+40)
  859. // gem_collected[gem_cou]=1;
  860. // //if(gem_collected[])
  861. //}
  862.  
  863. void iDraw()
  864. {
  865.  
  866. iClear();
  867.  
  868. // if(leftkbhit)
  869. // {
  870. //
  871. // //NEEDS TO BE FIXED DEPENDING ON BMP
  872. // camx-=20;
  873. // man_x+=20;
  874. // camxLSCount++;
  875. //
  876. //
  877. // if(camxLSCount>20)
  878. // {
  879. // leftkbhit=0;
  880. //
  881. // if(man_x<=850)
  882. // camxLSCount=0;
  883. // }
  884. //
  885. // }
  886. //
  887. // if(rightkbhit)
  888. // {
  889. // //NEEDS TO BE FIXED DEPENDING ON BMP
  890. // camx+=20;
  891. // man_x-=20;
  892. // camxRSCount++;
  893. //
  894. //
  895. // if(camxRSCount>20)
  896. // {
  897. // rightkbhit=0;
  898. //
  899. // if(man_x<450)
  900. // camxRSCount=0;
  901. // }
  902. //
  903. // }
  904.  
  905.  
  906.  
  907.  
  908. //level=0;
  909.  
  910.  
  911. if(level==0)
  912. {
  913. if(bg>=1&&bg<15)
  914. iShowBMP(0,0,"images\\1.bmp");
  915. if(bg>=15&&bg<30)
  916. iShowBMP(0,0,"images\\2.bmp");
  917. if(bg>=30&&bg<55)
  918. iShowBMP(0,0,"images\\3.bmp");
  919. if(bg>=45&&bg<60)
  920. iShowBMP(0,0,"images\\4.bmp");
  921.  
  922. bg++;
  923. if(bg>=60)
  924. bg=1;
  925.  
  926. // iRectangle(185,382,270,100);
  927. // iRectangle(185,382-80,295,80);
  928. // iRectangle(185,382-160,315,80);
  929. // iRectangle(185,382-240,350,80);
  930.  
  931.  
  932. //if(cont==1)
  933. //{
  934. FILE* fp1,*fp2,*fp3,*fp4,*fp5,*fp6,*fp7,*fp8,*fp9,*fp10,*fp11, *fp12;
  935.  
  936. fp1=fopen("man_x_man_y.txt","r");
  937. fscanf(fp1,"%d %d",&man_x,&man_y);
  938. fclose(fp1);
  939.  
  940. fp2=fopen("dx_dy.txt","r");
  941. fscanf(fp2,"%d %d",&dx,&dy);
  942. fclose(fp2);
  943.  
  944.  
  945. fp3=fopen("horizontal_laser.txt","r");
  946. fscanf(fp3,"%d %d %d %d",&laser_x[0],&laser_x[1],&laser_x[2],&laser_x[3]);
  947. fclose(fp3);
  948.  
  949.  
  950. fp4=fopen("vertical_laser.txt","r");
  951. fprintf(fp4,"%d %d",vertical_laser_y[0],vertical_laser_y[1]);
  952. fclose(fp4);
  953.  
  954.  
  955. fp5=fopen("bomb1.txt","r");
  956. fscanf(fp5,"%d %d %d",&bomb_cnt,&bomb_chk,&bomb_tm);
  957. fclose(fp5);
  958.  
  959.  
  960. fp6=fopen("bomb2.txt","r");
  961. fscanf(fp6,"%f %f %f %f %f %f",&bomb_x[bomb_cnt-1],&bomb_y[bomb_cnt-1],&bomb_x_change[bomb_cnt-1],&bomb_y_change[bomb_cnt-1],&bomb_initial_x,&bomb_initial_y);
  962. fclose(fp6);
  963.  
  964.  
  965. fp7=fopen("health.txt","r");
  966. fscanf(fp7,"%f",&health);
  967. fclose(fp7);
  968.  
  969.  
  970. fp8=fopen("health_pack1.txt","r");
  971. fscanf(fp8,"%d %d %d",&hel_pck_num,&health_pack_chk,&hel_tm);
  972. fclose(fp8);
  973.  
  974.  
  975. fp9=fopen("health_pack_2.txt","r");
  976. fscanf(fp9,"%lf %lf %d %d",&health_x[hel_pck_num-1],&health_y[hel_pck_num-1],&hel_initial_x,&hel_initial_y);
  977. fclose(fp9);
  978.  
  979. fp10=fopen("timer.txt","r");
  980. fscanf(fp10,"%f",&timer);
  981. fclose(fp10);
  982.  
  983. fp11=fopen("score.txt","r");
  984. fscanf(fp11,"%d %d",&current_score,&score_multiplier);
  985. fclose(fp11);
  986.  
  987. fp12=fopen("high score list.txt","r");
  988. for(int i=0;i<5;i++)
  989. {
  990. fscanf(fp12,"%d ",&score_count[i]);
  991. }
  992. fclose(fp12);
  993. //iText(500,500,"Continue");
  994. cont=0;
  995.  
  996.  
  997. //}
  998. if(how_to_play==1)
  999. {
  1000. iShowBMP(0,0,"images\\howto.bmp");
  1001. if(back_from_howto)
  1002. how_to_play=0;
  1003. iRectangle(603,50,180,65);
  1004. //iText(500,500,"how");
  1005. }
  1006. if(new_game==1)
  1007. {
  1008. timer=0;
  1009. //iText(500,500,"new");
  1010. level=1;
  1011. new_game=0;
  1012. cont=0;
  1013. }
  1014. if(high_score==1)
  1015. {
  1016. //level=-1;
  1017. iShowBMP(0,0,"images\\highscore.bmp");
  1018. if(back_from_high)
  1019. {
  1020. high_score=0;
  1021. }
  1022. iRectangle(603,50,180,65);
  1023. }
  1024.  
  1025. }
  1026.  
  1027. man_wid=60,man_height=80;
  1028. //level=1;
  1029. if(level==1)
  1030. {
  1031. //iRectangle(man_x,man_y,man_wid,man_height);
  1032.  
  1033. timer+=.01;
  1034.  
  1035. if(timer>=10)
  1036. score_multiplier=2;
  1037. if(timer>=50)
  1038. score_multiplier=5;
  1039. // if(timer>=10)
  1040. // health=110;
  1041. // takes 36 seconds to reach 0 to 10
  1042.  
  1043. iShowBMP(0,0,"images\\background-game-3.bmp");
  1044.  
  1045. score_show_live();
  1046.  
  1047. int gem_cou;
  1048. if(man_x>=1000-man_wid && man_x<=1000+40 && man_y>=700-man_height && man_y<=700+40) // make it like bomb touch
  1049. gem_collected[0]=1; //show the gem in one corner in small size if taken
  1050. if(!gem_collected[0])
  1051. iShowBMP2(1000,700,"images\\pink-gem.bmp",0xFFFFFF); //this is gem 1
  1052.  
  1053. if(gem_collected[0])
  1054. iText(80,700,"CONGRATULATIONS! You have collected a gem");
  1055. // GEM TEXT
  1056. iSetColor(255, 100, 10);
  1057.  
  1058. iRectangle(man_x,man_y,man_wid,man_height);
  1059. //iRectangle(dead_man_x,dead_man_y,man_wid,man_height);
  1060.  
  1061. if(man_mov_left && sprint%2==0)
  1062. iShowBMP2(man_x,man_y,"images\\left.bmp",0xFFFFFF);
  1063. if(man_mov_left && sprint%2!=0)
  1064. iShowBMP2(man_x,man_y,"images\\leftsprint.bmp",0xFFFFFF);
  1065. if(man_mov_right && sprint%2==0)
  1066. iShowBMP2(man_x,man_y,"images\\right.bmp",0xFFFFFF);
  1067. if(man_mov_right && sprint%2!=0)
  1068. iShowBMP2(man_x,man_y,"images\\rightsprint.bmp",0xFFFFFF);
  1069. if(man_mov_down || man_mov_up)
  1070. iShowBMP2(man_x,man_y,"images\\right.bmp",0xFFFFFF);
  1071. changelasercolor();
  1072. int i;
  1073. for(i=0;i<horizontal_laser_count;i++)
  1074. {
  1075. if(laserMove[i]==0 && laser_x[i]!=movingLaserRange_x2[i])
  1076. {
  1077. laser_x[i]+=1;
  1078. if(laser_x[i]==movingLaserRange_x2[i])
  1079. {
  1080. laserMove[i]=1;
  1081. }
  1082. }
  1083. if(laserMove[i]==1 && laser_x[i]!=movingLaserRange_x1[i])
  1084. {
  1085. laser_x[i]-=1;
  1086. if(laser_x[i]==movingLaserRange_x1[i])
  1087. {
  1088. laserMove[i]=0;
  1089. }
  1090. }
  1091. horizontalLaser(laserLen,i);
  1092. health_change(i);
  1093. if(health>50)
  1094. iSetColor(0,255,0);
  1095. else if(health>20&&health<40)
  1096. iSetColor(255,255,0);
  1097. else
  1098. iSetColor(255,0,0);
  1099. //iFilledRectangle(1200,700,health,6);
  1100. }
  1101.  
  1102. for(i=0;i<vertical_laser_count;i++)
  1103. {
  1104. if(vertical_laserMove[i]==0 && vertical_laser_y[i]>=vertical_movingLaserRange_y1[i])
  1105. {
  1106. vertical_laser_y[i]-=1;
  1107. if(vertical_laser_y[i]==vertical_movingLaserRange_y1[i])
  1108. {
  1109. vertical_laserMove[i]=1;
  1110. }
  1111. }
  1112. if(vertical_laserMove[i]==1 && vertical_laser_y[i]<=vertical_movingLaserRange_y2[i])
  1113. {
  1114. vertical_laser_y[i]+=1;
  1115. if(vertical_laser_y[i]==vertical_movingLaserRange_y2[i])
  1116. {
  1117. vertical_laserMove[i]=0;
  1118. }
  1119. }
  1120. verticalLaser(100,i);
  1121. vertical_health_change(i);
  1122. if(health>50)
  1123. iSetColor(0,255,0);
  1124. else if(health>20&&health<=50)
  1125. iSetColor(255,255,0);
  1126. else
  1127. iSetColor(255,0,0);
  1128. iRectangle(1200,700,100,8);
  1129. iFilledRectangle(1200,700,health,8);
  1130. }
  1131.  
  1132. if(!health_pack_chk)
  1133. {
  1134. hel_tm++;
  1135. if(hel_pck_num==3)
  1136. hel_pck_num=0;
  1137. if(hel_tm%400==0){
  1138. health_pack_chk=1;
  1139. hel_tm=0;
  1140. hel_pck_num++;
  1141. hel_initial_x=health_x[hel_pck_num-1];
  1142. hel_initial_y=health_y[hel_pck_num-1];
  1143. }
  1144. }
  1145. if(health_pack_chk)
  1146. healthPack();
  1147. if(!bomb_chk)
  1148. {
  1149. bomb_tm++;
  1150. if(bomb_cnt==4)
  1151. bomb_cnt=0;
  1152. if(bomb_tm%200==0)
  1153. {
  1154. bomb_chk=1;
  1155. bomb_tm=0;
  1156. bomb_cnt++;
  1157. bomb_initial_x=bomb_x[bomb_cnt-1];
  1158. bomb_initial_y=bomb_y[bomb_cnt-1];
  1159. }
  1160. }
  1161. if(bomb_chk)
  1162. bomb();
  1163.  
  1164. // iSetColor(0,255,0);
  1165. // iFilledRectangle(1200,700,health,4);
  1166. iSetColor(0,255,0);
  1167.  
  1168.  
  1169. if(health==100)
  1170. iText(1200,700-13,"Health = Full");
  1171. else if(health<20 && health!=0)
  1172. iText(1200,700-13,"Health Critical");
  1173. else if(health==0)
  1174. iText(1200,700-13,"Zero Health");
  1175. else
  1176. iText(1200,700-13,"Health");
  1177. //health=0;
  1178. if(!health)
  1179. {
  1180. game_over = 1;
  1181. level_one_sound();
  1182. game_over_sound();
  1183. health = 0.1;
  1184. }
  1185.  
  1186. enemyF();
  1187.  
  1188. //LASER BAR
  1189. iSetColor(255,0,0);
  1190. iText(1200,660, "Laser Power");
  1191. iRectangle(1200,670,100,6);
  1192. iFilledRectangle(1200,670,laserHealth,6);
  1193.  
  1194.  
  1195. //LASER INITIATE CODE
  1196. if(!laserStat) //INDICATES ONE COMPLETE CYCLE OF LASER
  1197. {
  1198. if(laserSwitch) //INDICATES ON/OFF OF LASER
  1199. {
  1200. laser();
  1201. laserTimer++;
  1202. if(laserHealth>0)
  1203. laserHealth-=1; //PRODUCT OF LASERHEALTH AND LASERTIMER IS ALWAYS EQUAL TO 100 - THE SIZE OF THE LASER BAR
  1204.  
  1205. if(laserTimer>100) //INCREASE THIS NUMBER TO INCREASE DURATION OF LASER
  1206. {
  1207. laserStat=1;
  1208. laserTimer=0;
  1209. laserSwitch=0;
  1210. }
  1211.  
  1212. }
  1213. }
  1214.  
  1215. //REFILLING THE LASER
  1216.  
  1217. if(laserStat)
  1218. {
  1219. laserHealth+=0.1;
  1220.  
  1221. if(laserHealth>=100)
  1222. laserStat=0;
  1223. }
  1224.  
  1225.  
  1226.  
  1227. //ENEMIES:
  1228. enemy();
  1229. reduceEnemyHealth();
  1230.  
  1231.  
  1232.  
  1233.  
  1234.  
  1235.  
  1236.  
  1237. }
  1238. if(game_over)
  1239. {
  1240. // dead_man_y=man_y,dead_man_x=man_x;
  1241. man_x=-1000, man_y=-1000;
  1242. //if(game_over)
  1243. // if(dead_man_y>=10)
  1244. // dead_man_y--;
  1245. // kam baki ase
  1246. // iFilledRectangle(man_x,man_y,30,40),
  1247.  
  1248. iShowBMP2(470,game_over_y,"images\\game_over.bmp",0xFFFFFF);
  1249. if(game_over_y<=280)
  1250. game_over_y+=4;
  1251. if(game_over_y>=280)
  1252. {
  1253. game_end++;
  1254. if(game_end==100){
  1255.  
  1256.  
  1257. man_x=30, man_y=150;
  1258. health=100;
  1259. sprint=0;
  1260. cont=0;
  1261. //level=1;
  1262. high_score=1;
  1263. game_over=0;
  1264. game_over_sound();
  1265. score_page_sound();
  1266.  
  1267.  
  1268. man_x=10;
  1269. man_y=150;
  1270. dx=3, dy=3;
  1271. sprint=0;
  1272. lasercolorR = 0,lasercolorG = 0,lasercolorB = 0, changecolor = 0;
  1273.  
  1274. int laserMove[]={1,1,1,1},laser_x[]={300,700,200,500},laser_y[]={190,270,400,500};
  1275.  
  1276. vertical_laserMove[0]=0;
  1277. vertical_laserMove[1]=1;
  1278.  
  1279.  
  1280. vertical_laser_x[0]=850;
  1281. vertical_laser_x[1]=700;
  1282.  
  1283. vertical_laser_y[0]=600;
  1284. vertical_laser_y[1]=400;
  1285.  
  1286. vertical_laser_count=2;
  1287. health=100;
  1288. // health_x[]={600,300,900},health_y[]={768,768,768};
  1289.  
  1290. health_x[0]=600;
  1291. health_x[1]=300;
  1292. health_x[2]=900;
  1293.  
  1294. health_y[0]=768;
  1295. health_y[1]=768;
  1296. health_y[2]=768;
  1297.  
  1298. hel_tm=0,health_pack_chk=0,hel_pck_num=0;
  1299.  
  1300. health_taken=0;//health_yes
  1301.  
  1302. bomb_x[0]=1336;
  1303. bomb_x[2]=1000;
  1304. bomb_x[2]=300;
  1305. bomb_x[3]=0;
  1306.  
  1307. bomb_y[0]=768;
  1308. bomb_y[1]=768;
  1309. bomb_y[2]=768;
  1310. bomb_y[3]=300;
  1311.  
  1312. bomb_tm=0,bomb_chk=0,bomb_cnt=0;
  1313.  
  1314. gem_collected[0]=0;
  1315. gem_collected[1]=0;
  1316. gem_collected[2]=0;
  1317.  
  1318. level=0; // level=2 indicating the score page
  1319. game_over=0;
  1320. new_game=0;
  1321. cont=0;
  1322. game_end=0;
  1323.  
  1324. }
  1325.  
  1326. }
  1327. }
  1328.  
  1329. FILE * fp1,*fp2,*fp3,*fp4,*fp5,*fp6,*fp7,*fp8,*fp9, *fp10,*fp11, *fp12;
  1330. fp1=fopen("man_x_man_y.txt","w");
  1331. fprintf(fp1,"%d %d",man_x,man_y);
  1332. fclose(fp1);
  1333.  
  1334.  
  1335. fp2=fopen("dx_dy.txt","w");
  1336. fprintf(fp2,"%d %d",dx,dy);
  1337. fclose(fp2);
  1338.  
  1339. fp3=fopen("horizontal_laser.txt","w");
  1340. fprintf(fp3,"%d %d %d %d",laser_x[0],laser_x[1],laser_x[2],laser_x[3]);
  1341. fclose(fp3);
  1342.  
  1343.  
  1344. fp4=fopen("vertical_laser.txt","w");
  1345. fprintf(fp4,"%d %d",vertical_laser_y[0],vertical_laser_y[1]);
  1346. fclose(fp4);
  1347.  
  1348.  
  1349. fp5=fopen("bomb1.txt","w");
  1350. fprintf(fp5,"%d %d %d",bomb_cnt,bomb_chk,bomb_tm);
  1351. fclose(fp5);
  1352.  
  1353. fp6=fopen("bomb2.txt","w");
  1354. fprintf(fp6,"%f %f %f %f %f %f",bomb_x[bomb_cnt-1],bomb_y[bomb_cnt-1],bomb_x_change[bomb_cnt-1],bomb_y_change[bomb_cnt-1],bomb_initial_x,bomb_initial_y);
  1355. fclose(fp6);
  1356.  
  1357.  
  1358. fp7=fopen("health.txt","w");
  1359. fprintf(fp7,"%f",health);
  1360. fclose(fp7);
  1361.  
  1362.  
  1363. fp8=fopen("health_pack1.txt","w");
  1364. fprintf(fp8,"%d %d %d",hel_pck_num,health_pack_chk,hel_tm);
  1365. fclose(fp8);
  1366.  
  1367.  
  1368. fp9=fopen("health_pack_2.txt","w");
  1369. fprintf(fp9,"%f %f %f %f",health_x[hel_pck_num-1],health_y[hel_pck_num-1],hel_initial_x,hel_initial_y);
  1370. fclose(fp9);
  1371.  
  1372. fp10=fopen("timer.txt","w");
  1373. fprintf(fp10,"%f",timer);
  1374. fclose(fp10);
  1375.  
  1376. fp11=fopen("score.txt","w");
  1377. fprintf(fp11,"%d %d",current_score,score_multiplier);
  1378. fclose(fp11);
  1379.  
  1380. fp12=fopen("high score list.txt","w");
  1381. for(int i=0;i<5;i++)
  1382. {
  1383. fprintf(fp12,"%d ",score_count[i]);
  1384. }
  1385. fclose(fp12);
  1386.  
  1387. int i,j;
  1388. for(i=0;i<5;i++)
  1389. {
  1390. if(current_score>score_count[i])
  1391. {
  1392. for(j=4;j>i;j--)
  1393. {
  1394. score_count[j]=score_count[j-1];
  1395. }
  1396. score_count[i]=current_score;
  1397. break;
  1398. }
  1399. }
  1400. // for(i=0;i<5;i++){
  1401. // printf("%d ",score_count[i]);
  1402. // }
  1403.  
  1404. }
  1405. int main()
  1406. {
  1407. menu_sound();
  1408. iSetTimer(50, changeEnemy);
  1409. iSetTimer(100,score);
  1410. // PlaySound((LPCSTR) "C:\\Users\\Public\\Music\\Sample Music\\Sleep Away.mp3", NULL, SND_FILENAME | SND_ASYNC);
  1411. //DWORD dwError = GetLastError();
  1412.  
  1413. //place your own initialization codes here.
  1414. // iSetTimer(5, ballChange);
  1415. //
  1416.  
  1417. iInitialize(1366, 768, "Superman Adventures ver 1.2");
  1418.  
  1419. return 0;
  1420. }
RAW Paste Data