Brock.cpp
上传用户:semy2100
上传日期:2013-01-22
资源大小:3633k
文件大小:3k
源码类别:

射击游戏

开发平台:

Visual C++

  1. /********************************************************************
  2. *                        空运爆发                                    *
  3. *                       Version 2.0                                  *
  4. * 本游戏全部代码由:                                                 *
  5. *                   冲天实验室   梁锋 编写                           *
  6. *                    邮箱:lenwine@126.com                           *
  7. *                bbs: http://free2.e-168.cn/lenwind (正在开发中...)  *
  8. **********************************************************************/
  9. #include "stdafx.h"
  10. Brock::Brock(Manager *mgr,int xv,int yv):ShootPlane(mgr,xv,yv)
  11. {
  12. Work=true;
  13. spx=0;
  14. spy=0;
  15. }
  16. void Brock::Update()
  17. {
  18. ShootPlane::Update();
  19. if(leaveline()&&y>=Manager::Imgtall)
  20. Work=false;
  21. }
  22. void Brock::Shoot()
  23. {
  24. if(mManager->Time-EndShoot<Bomb::GetShoot(bombStyle))
  25. return;
  26. mManager->EnermyShoot(this);
  27. EndShoot=mManager->Time;
  28. }
  29. BrockA::BrockA(Manager *mgr,int xv,int yv):Brock(mgr,xv,yv)
  30. {
  31. bx=421;
  32. by=0;
  33. Bitlong=55;
  34. Bittall=78;
  35. rx=2;
  36. ry=3;
  37. rlong=58;
  38. rtall=81;
  39. alive=10;
  40. spy=2;
  41. AWork=WF;
  42. bombStyle=Bomb::ENERMY_BOMBO;
  43.     SetEndShoot();
  44. ChangePlace();
  45. }
  46. void BrockA::RunOther()
  47. {
  48. AWork=(AWORK)(rand()%2);
  49. }
  50. void BrockA::Update()
  51. {
  52. Brock::Update();
  53. if(alive<=0)return;
  54. switch(AWork)
  55. {
  56. case WL:
  57. x--;
  58. if(x<0)
  59. {
  60. x=0;
  61. AWork=WF;
  62. }
  63. break;
  64. case WR:
  65. x++;
  66. if(x+Bitlong>Manager::Imglong)
  67. {
  68. x=Manager::Imglong-Bitlong;
  69. AWork=WF;
  70. }
  71. break;
  72. }
  73. if(rand()<300)
  74.     RunOther();
  75. }
  76. BrockB::BrockB(Manager *mgr,int xv,int yv):Brock(mgr,xv,yv)
  77. {
  78. bx=537;//机身
  79. by=3;
  80. Bitlong=43;
  81. Bittall=43;
  82. rx=2;//碰撞检测,所有都一样
  83. ry=3;
  84. rlong=46;
  85. rtall=48;
  86. /*这些都是新增了飞机*/
  87. alive=2;
  88. spy=5;
  89. bombStyle=Bomb::ENERMY_BOMBS;
  90.     SetEndShoot();
  91.     ChangePlace();
  92. }
  93. BrockC::BrockC(Manager *mgr,int xv,int yv):Brock(mgr,xv,yv)
  94. {
  95. bx=2;
  96. by=417;
  97. Bitlong=96;
  98. Bittall=123;
  99. rx=3;
  100. ry=5;
  101. rlong=100;
  102. rtall=129;
  103. alive=5;
  104. spy=3;
  105.    bombStyle=Bomb::ENERMY_BOMBT;
  106.    SetEndShoot();
  107.    ChangePlace();
  108. }
  109. BrockD::BrockD(Manager *mgr,int xv,int yv) : Brock(mgr,xv,yv)
  110. {
  111. bx=348;
  112. by=0;
  113. Bitlong=40;
  114. Bittall=50;
  115. /*这些都是新增了飞机*/
  116. rx=7;
  117. ry=5;
  118. rlong=30;
  119. rtall=35;
  120. alive=2;
  121. spy=3;
  122. bombStyle=Bomb::ENERMY_BOMBF;
  123. SetEndShoot();
  124. ChangePlace();
  125. }
  126. BrockE::BrockE(Manager *mgr,int xv,int yv) : Brock(mgr,xv,yv)
  127. {
  128. bx=261;
  129. by=424;
  130. Bitlong=67;
  131. Bittall=120;
  132. /*第一个 敌机王*/
  133. rx=3;
  134. ry=2;
  135. rlong=70;
  136. rtall=125;
  137. alive=8;
  138. spy=3;
  139.     bombStyle=Bomb::ENERMY_BOMBG;
  140. SetEndShoot();
  141. ChangePlace();
  142. }
  143. BrockF::BrockF(Manager *mgr,int xv,int yv) : Brock(mgr,xv,yv)
  144. {
  145. bx=388;
  146. by=0;
  147. Bitlong=31;
  148. Bittall=50;
  149. /*碰撞的X,Y*/
  150. rx=3;
  151. ry=5;
  152. rlong=35;
  153. rtall=56;
  154. alive=3;
  155. spy=2;
  156.     bombStyle=Bomb::ENERMY_BOMBI;
  157. SetEndShoot();
  158. ChangePlace();
  159. }