当前位置:   article > 正文

c语言飞机大战

c语言飞机大战
  1. #include"game.h"
  2. #include<conio.h>
  3. #include<iostream>
  4. #include<stdio.h>
  5. #include<easyx.h>
  6. #include<graphics.h>
  7. #include<windows.h>
  8. #include<mmsystem.h>//包含多媒体设备接口文件
  9. #pragma comment(lib,"winmm.lib")//加载静态库
  10. #define _CRT_SECURE_NO_WARNINGS
  11. #define width 624
  12. #define highth 960
  13. #define bul_max 100//屏幕上同时出现的子弹上限
  14. #define enemy_bul_max 100
  15. #define enemy1_hp 30
  16. #define enemy2_hp 50
  17. #define enemy3_hp 150
  18. #define enemy4_hp 50
  19. #define enemy5_hp 4000
  20. #define enemy6_hp 5000
  21. IMAGE bg1,bg2,bg3,bg;
  22. IMAGE Start2;
  23. IMAGE loading2;
  24. IMAGE player[2];
  25. IMAGE player_bullet[2];
  26. IMAGE protect[2];
  27. IMAGE heart[2];
  28. IMAGE supply[2];
  29. IMAGE supply_draw[2];
  30. IMAGE GG[2];
  31. IMAGE Enemy1[3];//小飞机
  32. IMAGE Enemy2[2];//中飞机
  33. IMAGE Enemy2Bullet[2];//中飞机子弹
  34. IMAGE Enemy3[2];//大飞机
  35. IMAGE Enemy3Bullet[2];//大飞机子弹
  36. IMAGE Enemy4[2];//横行飞机
  37. IMAGE Enemy4Bullet[2];//横行飞机子弹
  38. IMAGE Enemy5[2];//第二关boss
  39. IMAGE Enemy5Bullet[2];//第二关boss子弹
  40. IMAGE Enemy6[2];//第三关boss
  41. IMAGE Enemy6Bullet[2];//第三关boss子弹
  42. struct Plane //玩家子弹
  43. {
  44. double x;
  45. double y;
  46. bool life;
  47. int hp;
  48. int atk;
  49. double wide;
  50. double high;
  51. }bullet[bul_max], plane, enemy1[10], enemy2[5], enemy2_bullet[enemy_bul_max], enemy3[3], enemy3_bullet[enemy_bul_max], enemy4[3], enemy4_bullet[enemy_bul_max], enemy5[1], enemy5_bullet[enemy_bul_max], enemy6[1], enemy6_Sbullet[enemy_bul_max], enemy6_Lbullet[enemy_bul_max], enemy6_Rbullet[enemy_bul_max],Boom[1];
  52. int score = 0;//2500分后出现第一关boss,5000通过第一关,8000分第二关boss出现,12000分进入第三关
  53. int supply_count = 1;
  54. int enemy3_direct0 = 1;
  55. int enemy3_direct1 = 1;
  56. int enemy3_direct2 = 1;
  57. int enemy5_direct0 = 1;
  58. int enemy6_direct0 = 1;
  59. int level_change_count = 1;
  60. //系统设置,游戏画面及声音实现
  61. int main();
  62. void LoadImg()//加载图片
  63. {
  64. //加L或_T可以解决Realease版本不能加载图片的问题
  65. //我方飞机
  66. if (level() == 1)
  67. {
  68. loadimage(&bg1, L"E:\\飞机大战素材\\L1.jpg");
  69. }
  70. else if (level() == 2)
  71. {
  72. loadimage(&bg2, L"E:\\飞机大战素材\\L2.png");
  73. }
  74. else
  75. {
  76. loadimage(&bg3, L"E:\\飞机大战素材\\L3.jpg");
  77. }
  78. loadimage(&player[0], L"E:\\飞机大战素材\\planeyy.jpg");//掩码图
  79. loadimage(&player[1], L"E:\\飞机大战素材\\plane.jpg");//一定得用jpg格式的图片啊!!!
  80. loadimage(&player_bullet[0], L"E:\\飞机大战素材\\bullet0.jpg");
  81. loadimage(&player_bullet[1], L"E:\\飞机大战素材\\bullet1.jpg");
  82. loadimage(&protect[0], L"E:\\飞机大战素材\\proy.jpg");
  83. loadimage(&protect[1], L"E:\\飞机大战素材\\pro.jpg");
  84. loadimage(&heart[0], L"E:\\飞机大战素材\\hearty.jpg");
  85. loadimage(&heart[1], L"E:\\飞机大战素材\\heart.jpg");
  86. loadimage(&supply[0], L"E:\\飞机大战素材\\bomb_supplyy.jpg");
  87. loadimage(&supply[1], L"E:\\飞机大战素材\\bomb_supply.jpg");
  88. loadimage(&supply_draw[0], L"E:\\飞机大战素材\\bomby.jpg");
  89. loadimage(&supply_draw[1], L"E:\\飞机大战素材\\bomb.jpg");
  90. loadimage(&GG[0], L"E:\\飞机大战素材\\R-C (1)y.jpg");
  91. loadimage(&GG[1], L"E:\\飞机大战素材\\R-C (1).jpg");
  92. /*loadimage(&player[0], "E:\\飞机大战素材\\kunkun.jpg");
  93. loadimage(&player[1], "E:\\飞机大战素材\\kunkuny.jpg");
  94. loadimage(&player_bullet[0], "E:\\飞机大战素材\\RCy.jpg");
  95. loadimage(&player_bullet[1], "E:\\飞机大战素材\\RC.jpg");*/
  96. //敌方飞机
  97. loadimage(&Enemy1[0], L"E:\\飞机大战素材\\enemy1y_jpg.jpg");//敌机1
  98. loadimage(&Enemy1[1], L"E:\\飞机大战素材\\enemy1_jpg.jpg");
  99. //loadimage(&Enemy1[2], "E:\\飞机大战素材\\enemy1_down2.png");
  100. loadimage(&Enemy2[0], L"E:\\飞机大战素材\\enemy2yy.jpg");//敌机2
  101. loadimage(&Enemy2[1], L"E:\\飞机大战素材\\enemy2_jpg.jpg");
  102. loadimage(&Enemy2Bullet[0], L"E:\\飞机大战素材\\llly_jpg.jpg");
  103. loadimage(&Enemy2Bullet[1], L"E:\\飞机大战素材\\lll_jpg.jpg");
  104. //敌机3
  105. loadimage(&Enemy3[0], L"E:\\飞机大战素材\\enemyPlane1.jpg");
  106. loadimage(&Enemy3[1], L"E:\\飞机大战素材\\enemyPlane2.jpg");
  107. loadimage(&Enemy3Bullet[0], L"E:\\飞机大战素材\\enemy3_buly.jpg");
  108. loadimage(&Enemy3Bullet[1], L"E:\\飞机大战素材\\enemy3_bull.jpg");
  109. //敌机4
  110. loadimage(&Enemy4[0], L"E:\\飞机大战素材\\enemy4y.jpg");
  111. loadimage(&Enemy4[1], L"E:\\飞机大战素材\\enemy4.jpg");
  112. loadimage(&Enemy4Bullet[0], L"E:\\飞机大战素材\\enemy4_buly.jpg");
  113. loadimage(&Enemy4Bullet[1], L"E:\\飞机大战素材\\enemy4_bul.jpg");
  114. //敌机5
  115. loadimage(&Enemy5[0], L"E:\\飞机大战素材\\银翼杀手2y.jpg");
  116. loadimage(&Enemy5[1], L"E:\\飞机大战素材\\银翼杀手2.jpg");
  117. loadimage(&Enemy5Bullet[0], L"E:\\飞机大战素材\\boss1y.jpg");
  118. loadimage(&Enemy5Bullet[1], L"E:\\飞机大战素材\\boss1.jpg");
  119. //敌机6
  120. loadimage(&Enemy6[0], L"E:\\飞机大战素材\\银翼杀手2y.jpg");
  121. loadimage(&Enemy6[1], L"E:\\飞机大战素材\\金色毁灭2.jpg");
  122. loadimage(&Enemy6Bullet[0], L"E:\\飞机大战素材\\boss2y.jpg");
  123. loadimage(&Enemy6Bullet[1], L"E:\\飞机大战素材\\boss2.jpg");
  124. }
  125. //void LoadBgm()
  126. //{
  127. // mciSendString("open E:\\c语言练习\\PlaneWar\\黑麦 - 游戏音乐试听(飞机大战).mp3", NULL, 0, NULL);
  128. // mciSendString("play E:\\c语言练习\\PlaneWar\\黑麦 - 游戏音乐试听(飞机大战).mp3", NULL, 0, NULL);
  129. //}
  130. //这里有待学习
  131. bool Timer_enemycreat(int ms)//定时器
  132. {
  133. static DWORD t1 = 0, t2 = 0;
  134. if (t2 - t1 > ms)
  135. {
  136. t1 = t2;
  137. return true;
  138. }
  139. t2 = clock();
  140. return false;
  141. }
  142. bool Timer_enemy2_bullet_creat(int ms)//定时器
  143. {
  144. static DWORD t1 = 0, t2 = 0;
  145. if (t2 - t1 > ms)
  146. {
  147. t1 = t2;
  148. return true;
  149. }
  150. t2 = clock();
  151. return false;
  152. }
  153. bool Timer_enemy3_bullet_creat(int ms)//定时器
  154. {
  155. static DWORD t1 = 0, t2 = 0;
  156. if (t2 - t1 > ms)
  157. {
  158. t1 = t2;
  159. return true;
  160. }
  161. t2 = clock();
  162. return false;
  163. }
  164. bool Timer_enemy4_bullet_creat(int ms)//定时器
  165. {
  166. static DWORD t1 = 0, t2 = 0;
  167. if (t2 - t1 > ms)
  168. {
  169. t1 = t2;
  170. return true;
  171. }
  172. t2 = clock();
  173. return false;
  174. }
  175. bool Timer_enemy5_bullet_creat(int ms)//定时器
  176. {
  177. static DWORD t1 = 0, t2 = 0;
  178. if (t2 - t1 > ms)
  179. {
  180. t1 = t2;
  181. return true;
  182. }
  183. t2 = clock();
  184. return false;
  185. }
  186. bool Timer_enemy6_bullet_creat(int ms)//定时器
  187. {
  188. static DWORD t1 = 0, t2 = 0;
  189. if (t2 - t1 > ms)
  190. {
  191. t1 = t2;
  192. return true;
  193. }
  194. t2 = clock();
  195. return false;
  196. }
  197. bool Timer_supply_creat(int ms)//定时器
  198. {
  199. static DWORD t1 = 0, t2 = 0;
  200. if (t2 - t1 > ms)
  201. {
  202. t1 = t2;
  203. return true;
  204. }
  205. t2 = clock();
  206. return false;
  207. }
  208. void Enemy_Clean()
  209. {
  210. int i, j;
  211. for (i = 0; i < 10; i++)//敌机1
  212. {
  213. if (enemy1[i].life == true)
  214. {
  215. enemy1[i].life = false;
  216. }
  217. }
  218. for (j = 0; j < 5; j++)//敌机2,这个地方应该不会有问题
  219. {
  220. if (enemy2[j].life == true)
  221. {
  222. enemy2[j].life = false;
  223. }
  224. }
  225. for (j = 0; j < 3; j++)//敌机3
  226. {
  227. if (enemy3[j].life == true)
  228. {
  229. enemy3[j].life = false;
  230. }
  231. }
  232. for (j = 0; j < 3; j++)//敌机4
  233. {
  234. if (enemy4[j].life == true)
  235. {
  236. enemy4[j].life = false;
  237. }
  238. }
  239. //以下为子弹清除
  240. for (i = 0; i < enemy_bul_max; i++)
  241. {
  242. if (enemy2_bullet[i].life == true)
  243. {
  244. enemy2_bullet[i].life = false;
  245. }
  246. if (enemy3_bullet[i].life == true)
  247. {
  248. enemy3_bullet[i].life = false;
  249. }
  250. if (enemy4_bullet[i].life == true)
  251. {
  252. enemy4_bullet[i].life = false;
  253. }
  254. }
  255. }
  256. int level()
  257. {
  258. if (score > 5000 && score < 10000)
  259. {
  260. return 2;
  261. }
  262. else if (score < 5000)
  263. {
  264. return 1;
  265. }
  266. else if (score>10000)
  267. {
  268. return 3;
  269. }
  270. if (score > 17000)
  271. {
  272. return 4;
  273. }
  274. }
  275. void level_change()
  276. {
  277. int ret = level();
  278. if (level_change_count == 1 && score > 5000)
  279. {
  280. level_change_count += 1;
  281. plane.hp = 100;
  282. Enemy_Clean();
  283. }
  284. if (level_change_count == 2 && score >= 12000)
  285. {
  286. level_change_count += 1;
  287. plane.hp = 100;
  288. Enemy_Clean();
  289. }
  290. }
  291. //level()放在主函数用于判断是否进入下一关
  292. void BeginMenu(int x, int y)
  293. {
  294. loadimage(&bg, L"E:\\飞机大战素材\\black.jpg");
  295. putimage(0, -900, &bg);
  296. initgraph(width, highth);
  297. setaspectratio(1, 1);
  298. setorigin(0, 0);
  299. TCHAR time_test1[50];
  300. TCHAR time_test2[50];
  301. TCHAR time_test3[50];
  302. TCHAR time_test4[50];
  303. TCHAR time_test5[50];
  304. _stprintf_s(time_test1, _T("若干年后,外星敌机来犯,人类陷入恐慌"));
  305. _stprintf_s(time_test2, _T("身为星际王牌飞行员的你,"));
  306. _stprintf_s(time_test3, _T("嘴角勾起了一丝不易令人察觉的弧度,"));
  307. _stprintf_s(time_test4, _T("低声道:"));
  308. _stprintf_s(time_test5, _T("\"无所谓,我会出手\""));
  309. settextstyle(25, 0, _T("宋体"));
  310. Sleep(1000);
  311. outtextxy(x, y, time_test1);
  312. Sleep(2000);
  313. outtextxy(x, y + 50, time_test2);
  314. Sleep(2000);
  315. outtextxy(x, y + 100, time_test3);
  316. Sleep(2000);
  317. outtextxy(x, y + 150, time_test4);
  318. Sleep(3000);
  319. outtextxy(x, y + 200, time_test5);
  320. Sleep(3000);
  321. }
  322. void FailMenu()
  323. {
  324. char input;
  325. printf("Game Over\n");
  326. printf("是否继续游戏?\n请输入:(yes/no)并回车\n");
  327. while (1)
  328. {
  329. scanf("%s", &input);
  330. if (strcmp(&input, "yes") == 0)
  331. {
  332. break;
  333. }
  334. else if (strcmp(&input, "no") == 0)
  335. {
  336. exit(0);
  337. }
  338. else
  339. {
  340. printf("输入无效,请重新输入\n");
  341. }
  342. }
  343. main();
  344. }
  345. void EndMenu()
  346. {
  347. Enemy_Clean();
  348. enemy6[0].life = false;
  349. /*int x = 10;
  350. int y = 20;
  351. Sleep(1000);
  352. initgraph(width, highth);
  353. setaspectratio(1, 1);
  354. setorigin(0, 0);
  355. putimage(0, -900, &bg);
  356. TCHAR time_test6[50];
  357. TCHAR time_test7[50];
  358. TCHAR time_test8[50];
  359. _stprintf_s(time_test6, _T("地球安全了,"));
  360. _stprintf_s(time_test7, _T("你漠视着满天的敌机残骸,笑道:"));
  361. _stprintf_s(time_test8, _T("\"我无敌\""));
  362. settextstyle(25, 0, _T("宋体"));
  363. Sleep(1000);
  364. outtextxy(x, y, time_test6);
  365. Sleep(2000);
  366. outtextxy(x, y + 50, time_test7);
  367. Sleep(3000);
  368. outtextxy(x, y + 100, time_test8);
  369. Sleep(4000);*/
  370. printf("地球安全了,\n你漠视着漫天的敌机残骸,\n笑道:\n\"我无敌\"");
  371. exit(0);
  372. }
  373. void Judge()
  374. {
  375. if (plane.hp <= 0)
  376. {
  377. if (level() == 1)
  378. {
  379. score = 0;
  380. }
  381. if (level() == 2 && score < 8000)
  382. {
  383. score = 5001;
  384. }
  385. if (level() == 2 && score > 8000)
  386. {
  387. score = 8001;
  388. }
  389. if (level() == 3)
  390. {
  391. score = 12001;
  392. }
  393. supply_count = 1;
  394. FailMenu();
  395. }
  396. if (score > 17000)
  397. {
  398. EndMenu();
  399. }
  400. }
  401. bool Timer(int ms)//定时器
  402. {
  403. static DWORD t1 = 0, t2 = 0;
  404. if (t2 - t1 > ms)
  405. {
  406. t1 = t2;
  407. return true;
  408. }
  409. t2 = clock();
  410. return false;
  411. }
  412. bool Timer2(int ms)//定时器
  413. {
  414. static DWORD t1 = 0, t2 = 0;
  415. if (t2 - t1 > ms)
  416. {
  417. t1 = t2;
  418. return true;
  419. }
  420. t2 = clock();
  421. return false;
  422. }
  423. void GameDraw()//打印游戏画面
  424. {
  425. LoadImg();
  426. if (level() == 1)
  427. {
  428. putimage(0, 0, &bg1);
  429. }
  430. else if (level() == 2)
  431. {
  432. putimage(0, 0, &bg2);
  433. }
  434. else
  435. {
  436. putimage(0, 0, &bg3);
  437. }
  438. //Show_Score(100, 0, score);//显示分数
  439. /*putimage(plane.x, plane.y, &protect[0], NOTSRCERASE);
  440. putimage(plane.x, plane.y, &protect[1], SRCINVERT);*/
  441. putimage(plane.x + 12, plane.y + 10, &player[0], NOTSRCERASE);
  442. putimage(plane.x + 12, plane.y + 10, &player[1], SRCINVERT);
  443. if (Boom[0].life)
  444. {
  445. putimage(Boom[0].x, Boom[0].y, &supply[0], NOTSRCERASE);
  446. putimage(Boom[0].x, Boom[0].y, &supply[1], SRCINVERT);
  447. }
  448. if (plane.hp >= 30)
  449. {
  450. putimage(10, 10, &heart[0], NOTSRCERASE);
  451. putimage(10, 10, &heart[1], SRCINVERT);
  452. }
  453. if (plane.hp >= 40)
  454. {
  455. putimage(55, 10, &heart[0], NOTSRCERASE);
  456. putimage(55, 10, &heart[1], SRCINVERT);
  457. }
  458. if (plane.hp >= 60)
  459. {
  460. putimage(100, 10, &heart[0], NOTSRCERASE);
  461. putimage(100, 10, &heart[1], SRCINVERT);
  462. }
  463. if (plane.hp >= 80)
  464. {
  465. putimage(145, 10, &heart[0], NOTSRCERASE);
  466. putimage(145, 10, &heart[1], SRCINVERT);
  467. }
  468. if (plane.hp >= 100)
  469. {
  470. putimage(190, 10, &heart[0], NOTSRCERASE);
  471. putimage(190, 10, &heart[1], SRCINVERT);
  472. }
  473. if (supply_count >= 1)
  474. {
  475. putimage(10, 60, &supply_draw[0], NOTSRCERASE);
  476. putimage(10, 60, &supply_draw[1], SRCINVERT);
  477. }
  478. if (supply_count >= 2)
  479. {
  480. putimage(55, 60, &supply_draw[0], NOTSRCERASE);
  481. putimage(55, 60, &supply_draw[1], SRCINVERT);
  482. }
  483. if (supply_count >= 3)
  484. {
  485. putimage(100, 60, &supply_draw[0], NOTSRCERASE);
  486. putimage(100, 60, &supply_draw[1], SRCINVERT);
  487. }
  488. int i;
  489. for (i = 0; i < bul_max; i++)
  490. {
  491. if (bullet[i].life == true)
  492. {
  493. putimage(bullet[i].x, bullet[i].y, &player_bullet[0], NOTSRCERASE);
  494. putimage(bullet[i].x, bullet[i].y, &player_bullet[1], SRCINVERT);
  495. }
  496. }
  497. //敌方飞机
  498. for (i = 0; i < 10; i++)//敌机1
  499. {
  500. if (enemy1[i].life == true)
  501. {
  502. putimage(enemy1[i].x, enemy1[i].y, &Enemy1[0], NOTSRCERASE);
  503. putimage(enemy1[i].x, enemy1[i].y, &Enemy1[1], SRCINVERT);
  504. }
  505. }
  506. for (i = 0; i < 5; i++)//敌机2
  507. {
  508. if (enemy2[i].life == true)
  509. {
  510. putimage(enemy2[i].x, enemy2[i].y, &Enemy2[0], NOTSRCERASE);
  511. putimage(enemy2[i].x, enemy2[i].y, &Enemy2[1], SRCINVERT);
  512. }
  513. }
  514. for (i = 0; i < enemy_bul_max; i++)
  515. {
  516. if (enemy2_bullet[i].life == true)
  517. {
  518. putimage(enemy2_bullet[i].x, enemy2_bullet[i].y, &Enemy2Bullet[0], NOTSRCERASE);
  519. putimage(enemy2_bullet[i].x, enemy2_bullet[i].y, &Enemy2Bullet[1], SRCINVERT);
  520. }
  521. }
  522. for (i = 0; i < 3; i++)//敌机3
  523. {
  524. if (enemy3[i].life == true)
  525. {
  526. putimage(enemy3[i].x, enemy3[i].y, &Enemy3[0], NOTSRCERASE);
  527. putimage(enemy3[i].x, enemy3[i].y, &Enemy3[1], SRCINVERT);
  528. }
  529. }
  530. for (i = 0; i < enemy_bul_max; i++)
  531. {
  532. if (enemy3_bullet[i].life == true)
  533. {
  534. putimage(enemy3_bullet[i].x, enemy3_bullet[i].y, &Enemy3Bullet[0], NOTSRCERASE);
  535. putimage(enemy3_bullet[i].x, enemy3_bullet[i].y, &Enemy3Bullet[1], SRCINVERT);
  536. }
  537. }
  538. for (i = 0; i < 3; i++)//敌机4
  539. {
  540. if (enemy4[i].life == true)
  541. {
  542. putimage(enemy4[i].x, enemy4[i].y, &Enemy4[0], NOTSRCERASE);
  543. putimage(enemy4[i].x, enemy4[i].y, &Enemy4[1], SRCINVERT);
  544. }
  545. }
  546. for (i = 0; i < enemy_bul_max; i++)
  547. {
  548. if (enemy4_bullet[i].life == true)
  549. {
  550. putimage(enemy4_bullet[i].x, enemy4_bullet[i].y, &Enemy4Bullet[0], NOTSRCERASE);
  551. putimage(enemy4_bullet[i].x, enemy4_bullet[i].y, &Enemy4Bullet[1], SRCINVERT);
  552. }
  553. }
  554. for (i = 0; i < 1; i++)//敌机5
  555. {
  556. if (enemy5[i].life == true)
  557. {
  558. putimage(enemy5[i].x, enemy5[i].y, &Enemy5[0], NOTSRCERASE);
  559. putimage(enemy5[i].x, enemy5[i].y, &Enemy5[1], SRCINVERT);
  560. }
  561. }
  562. for (i = 0; i < enemy_bul_max; i++)
  563. {
  564. if (enemy5_bullet[i].life == true)
  565. {
  566. putimage(enemy5_bullet[i].x, enemy5_bullet[i].y, &Enemy5Bullet[0], NOTSRCERASE);
  567. putimage(enemy5_bullet[i].x, enemy5_bullet[i].y, &Enemy5Bullet[1], SRCINVERT);
  568. }
  569. }
  570. for (i = 0; i < 1; i++)//敌机6
  571. {
  572. if (enemy6[i].life == true)
  573. {
  574. putimage(enemy6[i].x, enemy6[i].y, &Enemy6[0], NOTSRCERASE);
  575. putimage(enemy6[i].x, enemy6[i].y, &Enemy6[1], SRCINVERT);
  576. }
  577. }
  578. for (i = 0; i < enemy_bul_max; i++)
  579. {
  580. if (enemy6_Sbullet[i].life == true)
  581. {
  582. putimage(enemy6_Sbullet[i].x, enemy6_Sbullet[i].y, &Enemy6Bullet[0], NOTSRCERASE);
  583. putimage(enemy6_Sbullet[i].x, enemy6_Sbullet[i].y, &Enemy6Bullet[1], SRCINVERT);
  584. }
  585. }
  586. for (i = 0; i < enemy_bul_max; i++)
  587. {
  588. if (enemy6_Lbullet[i].life == true)
  589. {
  590. putimage(enemy6_Lbullet[i].x, enemy6_Lbullet[i].y, &Enemy6Bullet[0], NOTSRCERASE);
  591. putimage(enemy6_Lbullet[i].x, enemy6_Lbullet[i].y, &Enemy6Bullet[1], SRCINVERT);
  592. }
  593. }
  594. for (i = 0; i < enemy_bul_max; i++)
  595. {
  596. if (enemy6_Rbullet[i].life == true)
  597. {
  598. putimage(enemy6_Rbullet[i].x, enemy6_Rbullet[i].y, &Enemy6Bullet[0], NOTSRCERASE);
  599. putimage(enemy6_Rbullet[i].x, enemy6_Rbullet[i].y, &Enemy6Bullet[1], SRCINVERT);
  600. }
  601. }
  602. }
  603. void GameInit()//游戏各数据初始化
  604. {
  605. int i;
  606. plane.life = true;//玩家飞机初始化
  607. plane.x = width / 2 - 50;
  608. plane.y = 1;
  609. plane.hp = 100;
  610. plane.wide = 115;
  611. plane.high = 115;
  612. Boom[0].wide = 48;
  613. Boom[0].high = 85;
  614. Boom[0].x = -200;
  615. Boom[0].y = -200;
  616. Boom[0].life = false;
  617. //以下为敌机初始化
  618. for (i = 0; i < 10; i++)
  619. {
  620. enemy1[i].life = false;
  621. enemy1[i].hp = 30;
  622. enemy1[i].x = -10;
  623. enemy1[i].y = -10;
  624. enemy1[i].atk = 10;
  625. enemy1[i].wide = 52;
  626. enemy1[i].high = 39;
  627. }
  628. for (i = 0; i < 5; i++)
  629. {
  630. enemy2[i].life = false;
  631. enemy2[i].hp = 50;
  632. enemy2[i].x = -1;
  633. enemy2[i].y = -1;
  634. enemy2[i].atk = 20;
  635. enemy2[i].wide = 69;
  636. enemy2[i].high = 99;
  637. }
  638. for (i = 0; i < 3; i++)
  639. {
  640. enemy3[i].life = false;
  641. enemy3[i].hp = 150;
  642. enemy3[i].x = -1;
  643. enemy3[i].y = -1;
  644. enemy3[i].atk = 30;
  645. enemy3[i].wide = 104;
  646. enemy3[i].high = 148;
  647. }
  648. for (i = 0; i < 3; i++)
  649. {
  650. enemy4[i].life = false;
  651. enemy4[i].hp = 50;
  652. enemy4[i].x = -1;
  653. enemy4[i].y = -1;
  654. enemy4[i].atk = 30;
  655. enemy4[i].wide = 79;
  656. enemy4[i].high = 120;
  657. }
  658. for (i = 0; i < 1; i++)
  659. {
  660. enemy5[i].life = false;
  661. enemy5[i].hp = 4000;
  662. enemy5[i].x = -1;
  663. enemy5[i].y = -1;
  664. enemy5[i].atk = 100;
  665. enemy5[i].wide = 324;
  666. enemy5[i].high = 220;
  667. }
  668. for (i = 0; i < 1; i++)
  669. {
  670. enemy6[i].life = false;
  671. enemy6[i].hp = 4000;
  672. enemy6[i].x = -1;
  673. enemy6[i].y = -1;
  674. enemy6[i].atk = 100;
  675. enemy6[i].wide = 324;
  676. enemy6[i].high = 220;
  677. }
  678. //以下为子弹初始化
  679. for (i = 0; i < bul_max; i++)//先把所有子弹全都设置在界面外
  680. { //玩家子弹
  681. bullet[i].life = false;
  682. bullet[i].x = -1;
  683. bullet[i].y = -1;
  684. bullet[i].atk = 15;
  685. bullet[i].wide = 9;
  686. bullet[i].high = 21;
  687. }
  688. for (i = 0; i < enemy_bul_max; i++)
  689. { //敌机2子弹
  690. enemy2_bullet[i].life = false;
  691. enemy2_bullet[i].x = -1;
  692. enemy2_bullet[i].y = -1;
  693. enemy2_bullet[i].atk = 15;
  694. enemy2_bullet[i].wide = 32;
  695. enemy2_bullet[i].high = 32;
  696. }
  697. for (i = 0; i < enemy_bul_max; i++)
  698. { //敌机3子弹
  699. enemy3_bullet[i].life = false;
  700. enemy3_bullet[i].x = -5;
  701. enemy3_bullet[i].y = -5;
  702. enemy3_bullet[i].atk = 30;
  703. enemy3_bullet[i].wide = 29;
  704. enemy3_bullet[i].high = 40;
  705. }
  706. for (i = 0; i < enemy_bul_max; i++)
  707. { //敌机4子弹
  708. enemy4_bullet[i].life = false;
  709. enemy4_bullet[i].x = -5;
  710. enemy4_bullet[i].y = -5;
  711. enemy4_bullet[i].atk = 30;
  712. enemy4_bullet[i].wide = 20;
  713. enemy4_bullet[i].high = 50;
  714. }
  715. for (i = 0; i < enemy_bul_max; i++)
  716. { //敌机5子弹
  717. enemy5_bullet[i].life = false;
  718. enemy5_bullet[i].x = -5;
  719. enemy5_bullet[i].y = -5;
  720. enemy5_bullet[i].atk = 30;
  721. enemy5_bullet[i].wide = 40;
  722. enemy5_bullet[i].high = 80;
  723. }
  724. for (i = 0; i < enemy_bul_max; i++)
  725. { //敌机6子弹
  726. enemy6_Sbullet[i].life = false;
  727. enemy6_Sbullet[i].x = -5;
  728. enemy6_Sbullet[i].y = -5;
  729. enemy6_Sbullet[i].atk = 30;
  730. enemy6_Sbullet[i].wide = 30;
  731. enemy6_Sbullet[i].high = 30;
  732. }
  733. for (i = 0; i < enemy_bul_max; i++)
  734. { //敌机6子弹
  735. enemy6_Lbullet[i].life = false;
  736. enemy6_Lbullet[i].x = -5;
  737. enemy6_Lbullet[i].y = -5;
  738. enemy6_Lbullet[i].atk = 30;
  739. enemy6_Lbullet[i].wide = 30;
  740. enemy6_Lbullet[i].high = 30;
  741. }
  742. for (i = 0; i < enemy_bul_max; i++)
  743. { //敌机6子弹
  744. enemy6_Rbullet[i].life = false;
  745. enemy6_Rbullet[i].x = -5;
  746. enemy6_Rbullet[i].y = -5;
  747. enemy6_Rbullet[i].atk = 30;
  748. enemy6_Rbullet[i].wide = 30;
  749. enemy6_Rbullet[i].high = 30;
  750. }
  751. }
  752. bool IsContain_my(int x,int y,bool life)
  753. { //x,y是敌机子弹或敌机的坐标
  754. double x1, x2, x3, y1, y2, y3;
  755. x1 = plane.x + plane.wide / 2, y1 = plane.y + plane.high;//飞机头
  756. x2 = plane.x, y2 = plane.y + 55;//左侧机翼
  757. x3 = plane.x + plane.wide + 25, y3 = plane.y + 55;//右侧机翼
  758. if (life == true)
  759. {
  760. double xx1 = x - x1; double yy1 = y - y1;//MA
  761. double xx2 = x - x2; double yy2 = y - y2;//MB
  762. double xx3 = x - x3; double yy3 = y - y3;//MC
  763. double a = xx1 * yy2 - yy1 * xx2;//MA*MB
  764. double c = xx2 * yy3 - yy2 * xx3;//MB*MC
  765. double b = yy1 * xx3 - xx1 * yy3;//MC*MA,注意这个地方调换了顺序
  766. if (a < 0 && b < 0 && c < 0)
  767. {
  768. return true;
  769. }
  770. if (a > 0 && b > 0 && c > 0)
  771. {
  772. return true;
  773. }
  774. }
  775. x2 = plane.x + plane.wide / 3, y2 = plane.y;//左侧机尾
  776. x3 = plane.x + plane.wide + 25 - plane.wide / 3, y3 = plane.y;//右侧机尾
  777. if (life == true)
  778. {
  779. double xx1 = x - x1; double yy1 = y - y1;//MA
  780. double xx2 = x - x2; double yy2 = y - y2;//MB
  781. double xx3 = x - x3; double yy3 = y - y3;//MC
  782. double a = xx1 * yy2 - yy1 * xx2;//MA*MB
  783. double c = xx2 * yy3 - yy2 * xx3;//MB*MC
  784. double b = yy1 * xx3 - xx1 * yy3;//MC*MA,注意这个地方调换了顺序
  785. if (a < 0 && b < 0 && c < 0)
  786. {
  787. return true;
  788. }
  789. else if (a > 0 && b > 0 && c > 0)
  790. {
  791. return true;
  792. }
  793. else
  794. {
  795. return false;
  796. }
  797. }
  798. }
  799. //用于判断敌方攻击是否攻击到我方飞机
  800. bool IsContain_enemy(int x, int y,bool life_my_bullet, int x1, int y1, int x2, int y2, int x3, int y3, bool life_enemy)
  801. {
  802. if (life_my_bullet == true && life_enemy == true)
  803. {
  804. double xx1 = x - x1; double yy1 = y - y1;//MA
  805. double xx2 = x - x2; double yy2 = y - y2;//MB
  806. double xx3 = x - x3; double yy3 = y - y3;//MC
  807. double a = xx1 * yy2 - yy1 * xx2;//MA*MB
  808. double c = xx2 * yy3 - yy2 * xx3;//MB*MC
  809. double b = yy1 * xx3 - xx1 * yy3;//MC*MA,注意这个地方调换了顺序
  810. if (a < 0 && b < 0 && c < 0)
  811. {
  812. return true;
  813. }
  814. else if (a > 0 && b > 0 && c > 0)
  815. {
  816. return true;
  817. }
  818. else
  819. {
  820. return false;
  821. }
  822. }
  823. }
  824. //用于判断我方攻击是否攻击到敌方飞机
  825. //我方飞机函数实现
  826. void AttackCreat()//创造子弹(这个地方要复习)
  827. {
  828. int i;
  829. for (i = 0; i < bul_max; i++)
  830. {
  831. if (bullet[i].life == false)//判断bullet数组里的第i个位置是否有空位
  832. //若没有,则访问i+1的位置,直到找到空位
  833. //若一直没找到空位则说明屏幕上的子弹已满
  834. {
  835. bullet[i].x = plane.x + plane.wide / 2;
  836. bullet[i].y = plane.y + plane.high;
  837. bullet[i].life = true;
  838. break;//一次发射一颗子弹
  839. }
  840. }
  841. }
  842. void AttackMove()
  843. {
  844. int i;
  845. for (i = 0; i < bul_max; i++)
  846. {
  847. if (bullet[i].life == true)
  848. {
  849. bullet[i].y += 3.5;
  850. if (bullet[i].y > highth + 20)
  851. {
  852. bullet[i].life = false;
  853. }
  854. }
  855. }
  856. }
  857. void Game()//玩家控制台
  858. {
  859. if (GetAsyncKeyState(VK_UP))
  860. {
  861. if (plane.y < highth - 50)
  862. {
  863. Plane_Move(0, 5);
  864. }
  865. }
  866. if (GetAsyncKeyState(VK_DOWN))
  867. {
  868. if (plane.y > 0)
  869. {
  870. Plane_Move(0, -5);
  871. }
  872. }
  873. if (GetAsyncKeyState(VK_RIGHT))
  874. {
  875. if (plane.x < width - 50)
  876. {
  877. Plane_Move(5, 0);
  878. }
  879. }
  880. if (GetAsyncKeyState(VK_LEFT))
  881. {
  882. if (plane.x > -50)
  883. {
  884. Plane_Move(-5, 0);
  885. }
  886. }
  887. if (GetAsyncKeyState(VK_SPACE) && Timer(140))
  888. {
  889. AttackCreat();
  890. }
  891. if (GetAsyncKeyState(VK_MENU) && Timer2(3000))
  892. {
  893. if (supply_count >= 1)
  894. {
  895. supply_count -= 1;
  896. Enemy_Clean();
  897. }
  898. }
  899. }
  900. void Plane_Move(int x, int y)//飞机接收玩家控制,进行移动
  901. {
  902. plane.x += x;
  903. plane.y += y;
  904. }
  905. void BulletCrush()
  906. {
  907. int i, j;
  908. for (i = 0; i < bul_max; i++)//子弹射敌机1后判断敌机生死
  909. {
  910. for (j = 0; j < 10; j++)
  911. {
  912. if (IsContain_enemy(bullet[i].x, bullet[i].y, bullet[i].life, enemy1[j].x + enemy1[j].wide / 2, enemy1[j].y, enemy1[j].x,enemy1[j].y+enemy1[j].high,enemy1[j].x+enemy1[j].wide, enemy1[j].y + enemy1[j].high,enemy1[j].life))
  913. {
  914. bullet[i].life = false;
  915. enemy1[j].hp -= bullet[i].atk;
  916. if (enemy1[j].hp <= 0)
  917. {
  918. score += enemy1_hp;
  919. //printf("%d\n", score);
  920. enemy1[j].life = false;
  921. }
  922. }
  923. }
  924. }
  925. for (i = 0; i < bul_max; i++)//子弹射敌机2后判断敌机生死
  926. {
  927. for (j = 0; j < 5; j++)
  928. {
  929. if (IsContain_enemy(bullet[i].x, bullet[i].y, bullet[i].life, enemy2[j].x + enemy2[j].wide / 2, enemy2[j].y, enemy2[j].x, enemy2[j].y + enemy2[j].high, enemy2[j].x + enemy2[j].wide, enemy2[j].y + enemy2[j].high, enemy2[j].life))
  930. {
  931. bullet[i].life = false;
  932. enemy2[j].hp -= bullet[i].atk;
  933. if (enemy2[j].hp <= 0)
  934. {
  935. score += enemy2_hp;
  936. //printf("%d\n", score);
  937. enemy2[j].life = false;
  938. }
  939. }
  940. }
  941. }
  942. for (i = 0; i < bul_max; i++)//子弹射击敌机3
  943. {
  944. for (j = 0; j < 3; j++)
  945. {
  946. if (IsContain_enemy(bullet[i].x, bullet[i].y, bullet[i].life, enemy3[j].x + enemy3[j].wide / 2, enemy3[j].y, enemy3[j].x, enemy3[j].y + enemy3[j].high, enemy3[j].x + enemy3[j].wide, enemy3[j].y + enemy3[j].high, enemy3[j].life))
  947. {
  948. bullet[i].life = false;
  949. enemy3[j].hp -= bullet[i].atk;
  950. if (enemy3[j].hp <= 0)
  951. {
  952. score += enemy3_hp;
  953. plane.hp += 10;
  954. //printf("%d\n", score);
  955. enemy3[j].life = false;
  956. }
  957. }
  958. }
  959. }
  960. for (i = 0; i < bul_max; i++)//子弹射击敌机4
  961. {
  962. for (j = 0; j < 3; j++)
  963. {
  964. if (IsContain_enemy(bullet[i].x, bullet[i].y, bullet[i].life, enemy4[j].x + enemy4[j].wide / 2, enemy4[j].y, enemy4[j].x, enemy4[j].y + enemy4[j].high, enemy4[j].x + enemy4[j].wide, enemy4[j].y + enemy4[j].high, enemy4[j].life))
  965. {
  966. bullet[i].life = false;
  967. enemy4[j].hp -= bullet[i].atk;
  968. if (enemy4[j].hp <= 0)
  969. {
  970. score += enemy4_hp;
  971. plane.hp += 3;
  972. //printf("%d\n", score);
  973. enemy4[j].life = false;
  974. }
  975. }
  976. }
  977. }
  978. for (i = 0; i < bul_max; i++)//子弹射击敌机5
  979. {
  980. for (j = 0; j < 1; j++)
  981. {
  982. if (IsContain_enemy(bullet[i].x, bullet[i].y, bullet[i].life, enemy5[j].x + enemy5[j].wide / 2, enemy5[j].y, enemy5[j].x, enemy5[j].y + enemy5[j].high, enemy5[j].x + enemy5[j].wide, enemy5[j].y + enemy5[j].high, enemy5[j].life))
  983. {
  984. bullet[i].life = false;
  985. enemy5[j].hp -= bullet[i].atk;
  986. if (enemy5[j].hp <= 0)
  987. {
  988. score += enemy5_hp;
  989. //printf("%d\n", score);
  990. enemy5[j].life = false;
  991. }
  992. }
  993. }
  994. }
  995. for (i = 0; i < bul_max; i++)//子弹射击敌机6
  996. {
  997. for (j = 0; j < 1; j++)
  998. {
  999. if (IsContain_enemy(bullet[i].x, bullet[i].y, bullet[i].life, enemy6[j].x + enemy6[j].wide / 2, enemy6[j].y, enemy6[j].x, enemy6[j].y + enemy6[j].high, enemy6[j].x + enemy6[j].wide, enemy6[j].y + enemy6[j].high, enemy6[j].life))
  1000. {
  1001. bullet[i].life = false;
  1002. enemy6[j].hp -= bullet[i].atk;
  1003. if (enemy6[j].hp <= 0)
  1004. {
  1005. score += enemy6_hp;
  1006. //printf("%d\n", score);
  1007. enemy6[j].life = false;
  1008. Judge();
  1009. }
  1010. }
  1011. }
  1012. }
  1013. }
  1014. void Supply_Creat()
  1015. {
  1016. if (score < 8000)
  1017. {
  1018. if (Timer_supply_creat(60000) && Boom[0].life == false && supply_count < 3)
  1019. {
  1020. Boom[0].life = true;
  1021. Boom[0].x = rand() % (width - 60);
  1022. Boom[0].y = rand() % highth + highth;
  1023. }
  1024. }
  1025. }
  1026. void Supply_Move()
  1027. {
  1028. if (Boom[0].life)
  1029. {
  1030. Boom[0].y -= 0.5;
  1031. if (Boom[0].y < -5)
  1032. {
  1033. Boom[0].life = false;
  1034. }
  1035. }
  1036. }
  1037. void Supply_Catch()
  1038. {
  1039. int x, y;
  1040. x = Boom[0].x + Boom[0].wide;
  1041. y = Boom[0].y;
  1042. if (IsContain_my(x,y, Boom[0].life))
  1043. {
  1044. Boom[0].life = false;
  1045. supply_count += 1;
  1046. }
  1047. }
  1048. //敌方飞机函数实现
  1049. void EnemyMove()
  1050. {
  1051. int i;
  1052. for (i = 0; i < 10; i++)//最小敌机前进,不发射子弹
  1053. {
  1054. if (enemy1[i].life == true)
  1055. {
  1056. enemy1[i].y -= 0.7;
  1057. if (enemy1[i].y < 0)
  1058. {
  1059. enemy1[i].life = false;
  1060. }
  1061. }
  1062. }
  1063. for (i = 0; i < 5; i++)//中飞机,缓慢前进,并发射子弹
  1064. {
  1065. if (enemy2[i].life == true)
  1066. {
  1067. enemy2[i].y -= 0.2;
  1068. if (enemy2[i].y < 0)
  1069. {
  1070. enemy2[i].life = false;
  1071. }
  1072. }
  1073. }
  1074. for (i = 0; i < 3; i++)//大飞机,左右移动,偶尔前进,并发射子弹
  1075. {
  1076. if (enemy3[i].life == true)
  1077. {
  1078. if (i == 0)//型号为0的飞机,奇数向左,偶数向右,且先向左
  1079. {
  1080. if (enemy3[i].y > highth - highth / 6)//先移动到画面中
  1081. {
  1082. enemy3[i].y -= 0.3;
  1083. }
  1084. else
  1085. {
  1086. if (enemy3_direct0 % 2 == 1)
  1087. {
  1088. enemy3[i].x -= 0.3;
  1089. if (enemy3[i].x < 0)
  1090. {
  1091. enemy3_direct0++;
  1092. }
  1093. }
  1094. if (enemy3_direct0 % 2 == 0)
  1095. {
  1096. enemy3[i].x += 0.3;
  1097. if (enemy3[i].x + enemy3[i].wide> width)
  1098. {
  1099. enemy3_direct0++;
  1100. }
  1101. }
  1102. }
  1103. }
  1104. if (i == 1)//型号为1的飞机,奇数向右,偶数向左,且先向右边
  1105. {
  1106. if (enemy3[i].y > highth - 2 * (highth / 6))//先移动到画面中
  1107. {
  1108. enemy3[i].y -= 0.3;
  1109. }
  1110. else
  1111. {
  1112. if (enemy3_direct1 % 2 == 0)
  1113. {
  1114. enemy3[i].x -= 0.3;
  1115. if (enemy3[i].x < 0)
  1116. {
  1117. enemy3_direct1++;
  1118. }
  1119. }
  1120. if (enemy3_direct1 % 2 == 1)
  1121. {
  1122. enemy3[i].x += 0.3;
  1123. if (enemy3[i].x + enemy3[i].wide > width)
  1124. {
  1125. enemy3_direct1++;
  1126. }
  1127. }
  1128. }
  1129. }
  1130. if (i == 2)//型号为2的飞机,奇数向左,偶数向右,且先向左
  1131. {
  1132. if (enemy3[i].y > highth - highth / 2)//先移动到画面中
  1133. {
  1134. enemy3[i].y -= 0.3;
  1135. }
  1136. else
  1137. {
  1138. if (enemy3_direct2 % 2 == 1)
  1139. {
  1140. enemy3[i].x -= 0.3;
  1141. if (enemy3[i].x < 0)
  1142. {
  1143. enemy3_direct2++;
  1144. }
  1145. }
  1146. if (enemy3_direct2 % 2 == 0)
  1147. {
  1148. enemy3[i].x += 0.3;
  1149. if (enemy3[i].x + enemy3[i].wide > width)
  1150. {
  1151. enemy3_direct2++;
  1152. }
  1153. }
  1154. }
  1155. }
  1156. if (enemy3[i].y < -3)
  1157. {
  1158. enemy3[i].life = false;
  1159. }
  1160. }
  1161. }
  1162. for (i = 0; i < 3; i++)//横行飞机,敌机4
  1163. {
  1164. if (enemy4[i].life)
  1165. {
  1166. enemy4[i].x += 0.5;
  1167. if (enemy4[i].x > width + 5)
  1168. {
  1169. enemy4[i].life = false;
  1170. }
  1171. }
  1172. }
  1173. for (i = 0; i < 1; i++)//敌机5
  1174. {
  1175. if (enemy5[i].life)
  1176. {
  1177. if (enemy5[i].y > highth - enemy5[i].high)
  1178. {
  1179. enemy5[i].y -= 0.5;
  1180. }
  1181. else
  1182. {
  1183. if (enemy5_direct0 % 2 == 1)
  1184. {
  1185. if (enemy5[i].hp > 2000)
  1186. {
  1187. enemy5[i].x -= 0.5;
  1188. }
  1189. else if (enemy5[i].hp > 2000 && enemy5[i].hp <= 3000)
  1190. {
  1191. enemy5[i].x -= 0.6;
  1192. }
  1193. else if (enemy5[i].hp > 1000 && enemy5[i].hp <= 2000)
  1194. {
  1195. enemy5[i].x -= 0.7;
  1196. }
  1197. else
  1198. {
  1199. enemy5[i].x -= 0.9;
  1200. }
  1201. if (enemy5[i].x + 20 < 0)
  1202. {
  1203. enemy5_direct0++;
  1204. }
  1205. }
  1206. if (enemy5_direct0 % 2 == 0)
  1207. {
  1208. if (enemy5[i].hp > 3000)
  1209. {
  1210. enemy5[i].x += 0.5;
  1211. }
  1212. else if (enemy5[i].hp > 2000 && enemy5[i].hp <= 3000)
  1213. {
  1214. enemy5[i].x += 0.6;
  1215. }
  1216. else if (enemy5[i].hp > 1000 && enemy5[i].hp <= 2000)
  1217. {
  1218. enemy5[i].x += 0.7;
  1219. }
  1220. else
  1221. {
  1222. enemy5[i].x += 0.9;
  1223. }
  1224. if (enemy5[i].x + enemy5[i].wide -20 > width)
  1225. {
  1226. enemy5_direct0++;
  1227. }
  1228. }
  1229. }
  1230. }
  1231. }
  1232. for (i = 0; i < 1; i++)
  1233. {
  1234. if (enemy6[i].life)
  1235. {
  1236. if (enemy6[i].y > highth - enemy6[i].high)
  1237. {
  1238. enemy6[i].y -= 0.5;
  1239. }
  1240. else
  1241. {
  1242. if (enemy6_direct0 % 2 == 1)
  1243. {
  1244. if (enemy6[i].hp > 2000)
  1245. {
  1246. enemy6[i].x -= 0.5;
  1247. }
  1248. else if (enemy6[i].hp > 2000 && enemy6[i].hp <= 3000)
  1249. {
  1250. enemy6[i].x -= 0.6;
  1251. }
  1252. else if (enemy6[i].hp > 1000 && enemy6[i].hp <= 2000)
  1253. {
  1254. enemy6[i].x -= 0.7;
  1255. }
  1256. else
  1257. {
  1258. enemy6[i].x -= 0.9;
  1259. }
  1260. if (enemy6[i].x + 20 < 0)
  1261. {
  1262. enemy6_direct0++;
  1263. }
  1264. }
  1265. if (enemy6_direct0 % 2 == 0)
  1266. {
  1267. if (enemy6[i].hp > 3000)
  1268. {
  1269. enemy6[i].x += 0.5;
  1270. }
  1271. else if (enemy6[i].hp > 2000 && enemy6[i].hp <= 3000)
  1272. {
  1273. enemy6[i].x += 0.6;
  1274. }
  1275. else if (enemy6[i].hp > 1000 && enemy6[i].hp <= 2000)
  1276. {
  1277. enemy6[i].x += 0.7;
  1278. }
  1279. else
  1280. {
  1281. enemy6[i].x += 0.9;
  1282. }
  1283. if (enemy6[i].x + enemy6[i].wide - 20 > width)
  1284. {
  1285. enemy6_direct0++;
  1286. }
  1287. }
  1288. }
  1289. }
  1290. }
  1291. }
  1292. void EnemyCreat_L1()
  1293. {
  1294. int i, j;
  1295. int count1 = 0, count2 = 0;
  1296. if (Timer_enemycreat(3000))
  1297. {
  1298. for (i = 0; i < 10; i++)//敌机1
  1299. {
  1300. if (enemy1[i].life == false)
  1301. {
  1302. enemy1[i].life = true;
  1303. enemy1[i].x = rand() % (width - 60);
  1304. enemy1[i].y = rand() % highth + highth;
  1305. enemy1[i].hp = 30;
  1306. //n~m,n+rand()%(m-n+1)
  1307. count1++;
  1308. if (count1 == 2)
  1309. {
  1310. count1 = 0;
  1311. break;
  1312. }
  1313. }
  1314. }
  1315. for (j = 0; j < 5; j++)//敌机2
  1316. {
  1317. if (enemy2[j].life == false)
  1318. {
  1319. enemy2[j].life = true;
  1320. enemy2[i].hp = 50;
  1321. enemy2[j].x = rand() % (width - 60);
  1322. enemy2[j].y = rand() % (highth / 3) + highth;
  1323. count2++;
  1324. if (count2 == 1)
  1325. {
  1326. count2 = 0;
  1327. break;
  1328. }
  1329. }
  1330. }
  1331. if (score > 2500)
  1332. {
  1333. for (j = 0; j < 3; j++)//敌机3
  1334. {
  1335. if (enemy3[j].life == false)
  1336. {
  1337. //printf("%d\n", count++);
  1338. enemy3[j].life = true;
  1339. enemy3[j].hp = 150;
  1340. enemy3[j].x = rand() % (width - 60);
  1341. enemy3[j].y = rand() % (highth / 3) + highth * 1.2;
  1342. break;
  1343. }
  1344. }
  1345. }
  1346. }
  1347. }
  1348. void EnemyCreat_L2()
  1349. {
  1350. int i, j;
  1351. if (Timer_enemycreat(3000))
  1352. {
  1353. if (score > 5000 && score <=8000)
  1354. {
  1355. for (i = 0; i < 10; i++)//敌机1
  1356. {
  1357. if (enemy1[i].life == false)
  1358. {
  1359. enemy1[i].life = true;
  1360. enemy1[i].x = rand() % (width - 60);
  1361. enemy1[i].y = rand() % highth + highth;
  1362. enemy1[i].hp = 30;
  1363. break;
  1364. }
  1365. }
  1366. for (j = 0; j < 3; j++)//敌机2,这个地方应该不会有问题
  1367. {
  1368. if (enemy2[j].life == false)
  1369. {
  1370. enemy2[j].life = true;
  1371. enemy2[i].hp = 50;
  1372. enemy2[j].x = rand() % (width - 60);
  1373. enemy2[j].y = rand() % (highth / 3) + highth;
  1374. break;
  1375. }
  1376. }
  1377. for (j = 0; j < 3; j++)//敌机4
  1378. {
  1379. if (enemy4[j].life == false)
  1380. {
  1381. enemy4[j].life = true;
  1382. enemy4[j].hp = 50;
  1383. enemy4[j].x = -enemy4[i].wide * 1.5;
  1384. enemy4[j].y = highth / 2 + rand() % (highth / 3);
  1385. break;
  1386. }
  1387. }
  1388. }
  1389. if (score > 8000)
  1390. {
  1391. Enemy_Clean();
  1392. supply_count = 0;
  1393. for (j = 0; j < 1; j++)//敌机5
  1394. {
  1395. if (enemy5[j].life == false)
  1396. {
  1397. enemy5[j].life = true;
  1398. enemy5[j].hp = 4000;
  1399. enemy5[j].x = width / 2 - enemy5[j].wide / 2;
  1400. enemy5[j].y = rand() % (highth / 3) + highth;
  1401. break;
  1402. }
  1403. }
  1404. }
  1405. }
  1406. }
  1407. void EnemyCreat_L3()
  1408. {
  1409. Enemy_Clean();
  1410. supply_count = 0;
  1411. int j;
  1412. if (score < 17000)
  1413. {
  1414. for (j = 0; j < 1; j++)//敌机6
  1415. {
  1416. if (enemy6[j].life == false)
  1417. {
  1418. enemy6[j].life = true;
  1419. enemy6[j].hp = 5000;
  1420. enemy6[j].x = width / 2 - enemy5[j].wide / 2;
  1421. enemy6[j].y = rand() % (highth / 3) + highth;
  1422. break;
  1423. }
  1424. }
  1425. }
  1426. }
  1427. void EnemyCrush()
  1428. {
  1429. int j;
  1430. int x, y;
  1431. for (j = 0; j < 10; j++)//敌机1碰撞玩家时玩家扣血
  1432. {
  1433. x = enemy1[j].x + enemy1[j].wide / 2;
  1434. y = enemy1[j].y;
  1435. if (IsContain_my( x, y,enemy1[j].life))
  1436. {
  1437. enemy1[j].life = false;
  1438. plane.hp -= enemy1[j].atk;
  1439. Judge();
  1440. }
  1441. }
  1442. for (j = 0; j < 5; j++)//敌机2碰撞玩家时玩家扣血
  1443. {
  1444. x = enemy2[j].x + enemy2[j].wide / 2;
  1445. y = enemy2[j].y;
  1446. if (IsContain_my( x, y,enemy2[j].life))
  1447. {
  1448. enemy2[j].life = false;
  1449. plane.hp -= enemy2[j].atk;
  1450. //printf("%d\n", plane.hp);
  1451. Judge();
  1452. }
  1453. }
  1454. for (j = 0; j < 3; j++)//敌机3碰撞玩家时玩家扣血
  1455. {
  1456. x = enemy3[j].x + enemy3[j].wide / 2;
  1457. y = enemy3[j].y;
  1458. if (IsContain_my(x, y, enemy3[j].life))
  1459. {
  1460. enemy3[j].life = false;
  1461. plane.hp -= enemy3[j].atk;
  1462. Judge();
  1463. }
  1464. }
  1465. for (j = 0; j < 3; j++)//敌机4碰撞玩家时玩家扣血
  1466. {
  1467. int x2, y2;
  1468. x = enemy4[j].x + enemy4[j].wide / 2;
  1469. y = enemy4[j].y;
  1470. x2 = enemy4[j].x + enemy4[j].wide / 2;
  1471. y2 = enemy4[j].y + enemy4[j].high;
  1472. if (IsContain_my(x, y, enemy4[j].life) == true || IsContain_my(x2, y2, enemy4[j].life))
  1473. {
  1474. enemy4[j].life = false;
  1475. plane.hp -= enemy4[j].atk;
  1476. //printf("%d\n", plane.hp);
  1477. Judge();
  1478. }
  1479. }
  1480. for (j = 0; j < 1; j++)//敌机5碰撞玩家时玩家扣血
  1481. {
  1482. int x2, y2, x3, y3, x4, y4;
  1483. x = enemy5[j].x + enemy5[j].wide / 2;
  1484. y = enemy5[j].y;
  1485. x2 = enemy5[j].x + enemy5[j].wide / 2;
  1486. y2 = enemy5[j].y + enemy5[j].high;
  1487. x3 = enemy5[j].x + 10;
  1488. y3 = enemy5[j].y + enemy5[j].high / 2;
  1489. x4 = enemy5[j].x + enemy5[j].wide - 10;
  1490. y4 = enemy5[j].y + enemy5[j].high / 2;
  1491. if (IsContain_my(x, y, enemy5[j].life) || IsContain_my(x2, y2, enemy5[j].life) || IsContain_my(x3, y3, enemy5[j].life) || IsContain_my(x4, y4, enemy5[j].life))
  1492. {
  1493. enemy5[j].life = false;
  1494. plane.hp -= enemy5[j].atk;
  1495. //printf("%d\n", plane.hp);
  1496. Judge();
  1497. }
  1498. }
  1499. for (j = 0; j < 1; j++)//敌机6碰撞玩家时玩家扣血
  1500. {
  1501. int x2, y2, x3, y3, x4, y4;
  1502. x = enemy6[j].x + enemy6[j].wide / 2;
  1503. y = enemy6[j].y;
  1504. x2 = enemy6[j].x + enemy6[j].wide / 2;
  1505. y2 = enemy6[j].y + enemy6[j].high;
  1506. x3 = enemy6[j].x + 10;
  1507. y3 = enemy6[j].y + enemy6[j].high / 2;
  1508. x4 = enemy6[j].x + enemy6[j].wide - 10;
  1509. y4 = enemy6[j].y + enemy6[j].high / 2;
  1510. if (IsContain_my(x, y, enemy6[j].life) || IsContain_my(x2, y2, enemy6[j].life) || IsContain_my(x3, y3, enemy6[j].life) || IsContain_my(x4, y4, enemy6[j].life))
  1511. {
  1512. enemy6[j].life = false;
  1513. plane.hp -= enemy6[j].atk;
  1514. //printf("%d\n", plane.hp);
  1515. Judge();
  1516. }
  1517. }
  1518. }
  1519. void Enemy_Bullet_Creat()
  1520. {
  1521. int i, j;
  1522. if (Timer_enemy2_bullet_creat(5000))//子弹发射频率
  1523. {
  1524. for (j = 0; j < 5; j++)
  1525. {
  1526. for (i = 0; i < enemy_bul_max; i++)
  1527. {
  1528. if (enemy2_bullet[i].life == false && enemy2[j].life == true)
  1529. {
  1530. enemy2_bullet[i].life = true;
  1531. enemy2_bullet[i].x = enemy2[j].x + enemy2[j].wide / 2 - 33;
  1532. enemy2_bullet[i].y = enemy2[j].y;
  1533. break;
  1534. }
  1535. }
  1536. }
  1537. }
  1538. int count3 = 1;
  1539. if (Timer_enemy3_bullet_creat(7000))
  1540. {
  1541. for (j = 0; j < 3; j++)
  1542. {
  1543. for (i = 0; i < enemy_bul_max; i++)
  1544. {
  1545. if (enemy3_bullet[i].life == false && enemy3[j].life == true)
  1546. {
  1547. if (count3 == 1)
  1548. {
  1549. enemy3_bullet[i].life = true;
  1550. enemy3_bullet[i].x = enemy3[j].x + enemy3[j].wide / 4 - 15;
  1551. enemy3_bullet[i].y = enemy3[j].y;
  1552. count3++;
  1553. continue;
  1554. //i += 1;
  1555. }
  1556. if (count3 == 2)
  1557. {
  1558. enemy3_bullet[i].life = true;
  1559. enemy3_bullet[i].x = enemy3[j].x + (enemy3[j].wide / 4) * 3 - 15;
  1560. enemy3_bullet[i].y = enemy3[j].y;
  1561. count3 = 1;
  1562. break;
  1563. }
  1564. }
  1565. }
  1566. }
  1567. }
  1568. if (Timer_enemy4_bullet_creat(3000))
  1569. {
  1570. for (j = 0; j < 3; j++)
  1571. {
  1572. for (i = 0; i < enemy_bul_max; i++)
  1573. {
  1574. if (enemy4_bullet[i].life == false && enemy4[j].life == true)
  1575. {
  1576. enemy4_bullet[i].life = true;
  1577. enemy4_bullet[i].x = enemy4[j].x + enemy4[j].wide / 2;
  1578. enemy4_bullet[i].y = enemy4[j].y;
  1579. break;
  1580. }
  1581. }
  1582. }
  1583. }
  1584. int count5 = 1;
  1585. if (Timer_enemy5_bullet_creat(400))
  1586. {
  1587. for (j = 0; j < 1; j++)
  1588. {
  1589. for (i = 0; i < enemy_bul_max; i++)
  1590. {
  1591. if (enemy5_bullet[i].life == false && enemy5[j].life == true)
  1592. {
  1593. enemy5_bullet[i].life = true;
  1594. if (count5 == 1)
  1595. {
  1596. enemy5_bullet[i].x = enemy5[j].x + 38;
  1597. enemy5_bullet[i].y = enemy5[j].y + 37;
  1598. count5 += 1;
  1599. continue;
  1600. }
  1601. if (count5 == 2)
  1602. {
  1603. count5 = 1;
  1604. enemy5_bullet[i].x = enemy5[j].x +enemy5[j].wide - 73;
  1605. enemy5_bullet[i].y = enemy5[j].y + 37;
  1606. break;
  1607. }
  1608. }
  1609. }
  1610. }
  1611. }
  1612. int count6 = 1;
  1613. if (Timer_enemy6_bullet_creat(2000))
  1614. {
  1615. for (j = 0; j < 1; j++)
  1616. {
  1617. for (i = 0; i < enemy_bul_max; i++)
  1618. {
  1619. if (enemy6_Sbullet[i].life == false && enemy6[j].life == true)
  1620. {
  1621. enemy6_Sbullet[i].life = true;
  1622. if (count6 == 1)
  1623. {
  1624. enemy6_Sbullet[i].x = enemy6[j].x + 38;
  1625. enemy6_Sbullet[i].y = enemy6[j].y + 37;
  1626. count6 += 1;
  1627. continue;
  1628. }
  1629. if (count6 == 2)
  1630. {
  1631. enemy6_Sbullet[i].x = enemy6[j].x + enemy6[j].wide - 73;
  1632. enemy6_Sbullet[i].y = enemy6[j].y + 37;
  1633. count6 = 1;
  1634. break;
  1635. }
  1636. }
  1637. }
  1638. for (i = 0; i < enemy_bul_max; i++)
  1639. {
  1640. if (enemy6_Lbullet[i].life == false && enemy6[j].life == true)
  1641. {
  1642. enemy6_Lbullet[i].life = true;
  1643. if (count6 == 1)
  1644. {
  1645. enemy6_Lbullet[i].x = enemy6[j].x + 38;
  1646. enemy6_Lbullet[i].y = enemy6[j].y + 37;
  1647. count6 += 1;
  1648. continue;
  1649. }
  1650. if (count6 == 2)
  1651. {
  1652. enemy6_Lbullet[i].x = enemy6[j].x + enemy6[j].wide - 73;
  1653. enemy6_Lbullet[i].y = enemy6[j].y + 37;
  1654. count6 = 1;
  1655. break;
  1656. }
  1657. }
  1658. }
  1659. for (i = 0; i < enemy_bul_max; i++)
  1660. {
  1661. if (enemy6_Rbullet[i].life == false && enemy6[j].life == true)
  1662. {
  1663. enemy6_Rbullet[i].life = true;
  1664. if (count6 == 1)
  1665. {
  1666. enemy6_Rbullet[i].x = enemy6[j].x + 38;
  1667. enemy6_Rbullet[i].y = enemy6[j].y + 37;
  1668. count6 += 1;
  1669. continue;
  1670. }
  1671. if (count6 == 2)
  1672. {
  1673. enemy6_Rbullet[i].x = enemy6[j].x + enemy6[j].wide - 73;
  1674. enemy6_Rbullet[i].y = enemy6[j].y + 37;
  1675. count6 = 1;
  1676. break;
  1677. }
  1678. }
  1679. }
  1680. }
  1681. }
  1682. }
  1683. void Enemy_Bullet_Move()
  1684. {
  1685. int i;
  1686. //敌机2
  1687. for (i = 0; i < enemy_bul_max; i++)
  1688. {
  1689. if (enemy2_bullet[i].life == true)
  1690. {
  1691. enemy2_bullet[i].y -= 0.6;
  1692. if (enemy2_bullet[i].y < -5)
  1693. {
  1694. enemy2_bullet[i].life = false;
  1695. }
  1696. }
  1697. }
  1698. //敌机3
  1699. for (i = 0; i < enemy_bul_max; i++)
  1700. {
  1701. if (enemy3_bullet[i].life == true)
  1702. {
  1703. enemy3_bullet[i].y -= 0.6;
  1704. if (enemy3_bullet[i].y < -3)
  1705. {
  1706. enemy3_bullet[i].life = false;
  1707. }
  1708. }
  1709. }
  1710. //敌机4
  1711. for (i = 0; i < enemy_bul_max; i++)
  1712. {
  1713. if (enemy4_bullet[i].life == true)
  1714. {
  1715. enemy4_bullet[i].y -= 0.7;
  1716. if (enemy4_bullet[i].y < -3)
  1717. {
  1718. enemy4_bullet[i].life = false;
  1719. }
  1720. }
  1721. }
  1722. //敌机5
  1723. for (i = 0; i < enemy_bul_max; i++)
  1724. {
  1725. if (enemy5_bullet[i].life == true)
  1726. {
  1727. enemy5_bullet[i].y -= 1;
  1728. if (enemy5_bullet[i].y < -3)
  1729. {
  1730. enemy5_bullet[i].life = false;
  1731. }
  1732. }
  1733. }
  1734. //敌机6
  1735. for (i = 0; i < enemy_bul_max; i++)
  1736. {
  1737. if (enemy6_Sbullet[i].life == true)
  1738. {
  1739. enemy6_Sbullet[i].y -= 1;
  1740. }
  1741. if (enemy6_Lbullet[i].life == true)
  1742. {
  1743. enemy6_Lbullet[i].y -= 1;
  1744. enemy6_Lbullet[i].x -= 0.5;
  1745. }
  1746. if (enemy6_Rbullet[i].life == true)
  1747. {
  1748. enemy6_Rbullet[i].y -= 1;
  1749. enemy6_Rbullet[i].x += 0.5;
  1750. }
  1751. if (enemy6_Sbullet[i].y < -3)
  1752. {
  1753. enemy6_Sbullet[i].life = false;
  1754. }
  1755. if (enemy6_Lbullet[i].y < -3)
  1756. {
  1757. enemy6_Lbullet[i].life = false;
  1758. }
  1759. if (enemy6_Rbullet[i].y < -3)
  1760. {
  1761. enemy6_Rbullet[i].life = false;
  1762. }
  1763. }
  1764. }
  1765. void Enemy_Bullet_Crush()
  1766. {
  1767. int i;
  1768. int x, y;
  1769. //敌机2子弹碰撞玩家扣血
  1770. for (i = 0; i < enemy_bul_max; i++)
  1771. {
  1772. x = enemy2_bullet[i].x + enemy2_bullet[i].wide / 2;
  1773. y = enemy2_bullet[i].y;
  1774. if (IsContain_my( x, y, enemy2_bullet[i].life))
  1775. {
  1776. enemy2_bullet[i].life = false;
  1777. plane.hp -= enemy2_bullet[i].atk;
  1778. Judge();
  1779. }
  1780. }
  1781. //敌机3子弹碰撞玩家扣血
  1782. for (i = 0; i < enemy_bul_max; i++)
  1783. {
  1784. x = enemy3_bullet[i].x + enemy3_bullet[i].wide / 2;
  1785. y = enemy3_bullet[i].y;
  1786. if (IsContain_my(x, y, enemy3_bullet[i].life))
  1787. {
  1788. enemy3_bullet[i].life = false;
  1789. plane.hp -= enemy3_bullet[i].atk;
  1790. Judge();
  1791. }
  1792. }
  1793. //敌机4子弹碰撞玩家扣血
  1794. for (i = 0; i < enemy_bul_max; i++)
  1795. {
  1796. x = enemy4_bullet[i].x + enemy4_bullet[i].wide / 2;
  1797. y = enemy4_bullet[i].y;
  1798. if (IsContain_my(x, y, enemy4_bullet[i].life))
  1799. {
  1800. enemy4_bullet[i].life = false;
  1801. plane.hp -= enemy4_bullet[i].atk;
  1802. Judge();
  1803. }
  1804. }
  1805. //敌机5子弹碰撞玩家扣血
  1806. for (i = 0; i < enemy_bul_max; i++)
  1807. {
  1808. x = enemy5_bullet[i].x + enemy5_bullet[i].wide / 2;
  1809. y = enemy5_bullet[i].y;
  1810. if (IsContain_my(x, y, enemy5_bullet[i].life))
  1811. {
  1812. enemy5_bullet[i].life = false;
  1813. plane.hp -= enemy5_bullet[i].atk;
  1814. Judge();
  1815. }
  1816. }
  1817. //敌机6子弹碰撞玩家扣血
  1818. for (i = 0; i < enemy_bul_max; i++)
  1819. {
  1820. x = enemy6_Sbullet[i].x + enemy6_Sbullet[i].wide / 2;
  1821. y = enemy6_Sbullet[i].y;
  1822. if (IsContain_my(x, y, enemy6_Sbullet[i].life))
  1823. {
  1824. enemy6_Sbullet[i].life = false;
  1825. plane.hp -= enemy6_Sbullet[i].atk;
  1826. Judge();
  1827. }
  1828. x = enemy6_Lbullet[i].x + enemy6_Lbullet[i].wide / 2;
  1829. y = enemy6_Lbullet[i].y;
  1830. if (IsContain_my(x, y, enemy6_Lbullet[i].life))
  1831. {
  1832. enemy6_Lbullet[i].life = false;
  1833. plane.hp -= enemy6_Lbullet[i].atk;
  1834. Judge();
  1835. }
  1836. x = enemy6_Rbullet[i].x + enemy6_Rbullet[i].wide / 2;
  1837. y = enemy6_Rbullet[i].y;
  1838. if (IsContain_my(x, y, enemy6_Rbullet[i].life))
  1839. {
  1840. enemy6_Rbullet[i].life = false;
  1841. plane.hp -= enemy6_Rbullet[i].atk;
  1842. Judge();
  1843. }
  1844. }
  1845. }
  1. #include <conio.h>
  2. #include<graphics.h>
  3. #include"game.h"
  4. #include <iostream>
  5. #include<stdio.h>
  6. #include<easyx.h>
  7. #include<windows.h>
  8. #include<mmsystem.h>
  9. #pragma comment(lib,"Winmm.lib")
  10. #define _CRT_SECURE_NO_WARNINGS
  11. #define width 624
  12. #define highth 960
  13. #define bul_max 100//屏幕上同时出现的子弹上限
  14. IMAGE Start;
  15. IMAGE loading;
  16. int count = 1;
  17. int main()
  18. {
  19. if (count == 1)
  20. {
  21. BeginMenu(10, 20);
  22. }
  23. srand((unsigned int)time(NULL));
  24. initgraph(width, highth);
  25. setaspectratio(1, -1);
  26. setorigin(0, highth);
  27. if (count == 1)
  28. {
  29. loadimage(&Start, L"E:\\飞机大战素材\\begin.jpg");
  30. loadimage(&loading, L"E:\\飞机大战素材\\load(1).jpg");
  31. putimage(0, 0, &Start);
  32. putimage(160, highth / 7, &loading);
  33. //Sleep(2000);
  34. count += 1;
  35. }
  36. GameInit();
  37. //LoadBgm();
  38. LoadImg();
  39. BeginBatchDraw();//双缓冲绘图
  40. while (1)
  41. {
  42. level_change();
  43. if (level() == 1)
  44. {
  45. EnemyCreat_L1();
  46. }
  47. if (level() == 2)
  48. {
  49. EnemyCreat_L2();
  50. }
  51. if (level() == 3)
  52. {
  53. EnemyCreat_L3();
  54. }
  55. EnemyMove();
  56. AttackMove();
  57. BulletCrush();
  58. EnemyCrush();
  59. Enemy_Bullet_Creat();
  60. Enemy_Bullet_Move();
  61. Enemy_Bullet_Crush();
  62. Supply_Creat();
  63. Supply_Move();
  64. Supply_Catch();
  65. GameDraw();
  66. Game();
  67. FlushBatchDraw();
  68. }
  69. EndBatchDraw();
  70. closegraph();
  71. return 0;
  72. }
  1. #pragma once
  2. #define _CRT_SECURE_NO_WARNINGS
  3. void LoadImg();
  4. bool Timer(int ms);
  5. void GameDraw();
  6. void EnemyMove();
  7. void EnemyCreat_L1();
  8. void EnemyCreat_L2();
  9. void EnemyCreat_L3();
  10. void Plane_Move(int x, int y);
  11. void GameInit();
  12. bool IsContain(int j);
  13. void BulletCrush();
  14. void EnemyCrush();
  15. void AttackCreat();
  16. void Game();
  17. void AttackMove();
  18. //void LoadBgm();
  19. void Enemy_Bullet_Creat();
  20. void Enemy_Bullet_Move();
  21. void Enemy_Bullet_Crush();
  22. void BeginMenu(int x, int y);
  23. void Judge();
  24. int level();
  25. void level_change();
  26. void Enemy_Bullet_Move();
  27. void Supply_Creat();
  28. void Supply_Move();
  29. void Supply_Catch();
  30. void EndMenu();

记得要把属性从Unicode改为多字节

以上是源代码,且需要用到easyx图形库,飞机大战素材包的原图以及掩码图可以私信找我要,有什么不懂也可以私信,以下是游戏的一些截图

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/358951
推荐阅读
相关标签
  

闽ICP备14008679号