943,972 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 1235
  • C++ RSS
Oct 25th, 2009
0

GA.exe has encountered an error and needs to close

Expand Post »
Hi.
Firstly, I am a complete noob, and cannot understand complicated answers.

OK. I'm making a noobish space game, called Galactic Armageddon.
I'm just testing the variables right now (for getting hit by lasers, missiles, etc.).

I'm compiling using Dev-C++ and the default compiler. The program is written using the Allegro game library (see cppgameprogramming.com)

When I run the executable, I get an error saying:

GA.exe has encountered a problem and needs to close.

It says this straight away, without even opening a window or anything.

Here is the code so far:

C++ Syntax (Toggle Plain Text)
  1. #include <cstdlib>
  2. #include <iostream>
  3. #include <allegro.h>
  4.  
  5. using namespace std;
  6.  
  7. int bullethit = 0;
  8. int health = 100;
  9. int shield = 10;
  10. int maxshield = 10;
  11. int armour = 10;
  12. int maxarmour = 10;
  13. int dir = 0;
  14. int weapon = 0;
  15. bool shieldsup = true;
  16. bool armourup = true;
  17. bool dead = false;
  18. bool running = true;
  19.  
  20. void ship(){
  21.  
  22. if (dir < 0)
  23. {
  24. dir=360;
  25. }
  26.  
  27. else if (dir > 360)
  28. {
  29. dir=0;
  30. }
  31.  
  32. if (bullethit==1 && shieldsup==false && armourup==false)
  33. {
  34. health = health - 10;
  35. bullethit = false;
  36. }
  37.  
  38. if (bullethit==1 && shieldsup==false && armourup==true)
  39. {
  40. armour = armour - 5;
  41. bullethit = false;
  42. }
  43.  
  44. if (bullethit==1 && shieldsup==true)
  45. {
  46. shield = shield - 4;
  47. bullethit = false;
  48. }
  49.  
  50. if (bullethit==2 && shieldsup==false && armourup==false)
  51. {
  52. health = health - 20;
  53. bullethit = false;
  54. }
  55.  
  56. if (bullethit==2 && shieldsup==false && armourup==true)
  57. {
  58. armour = armour - 10;
  59. bullethit = false;
  60. }
  61.  
  62. if (bullethit==2 && shieldsup == true)
  63. {
  64. shield = shield - 8;
  65. bullethit = false;
  66. }
  67.  
  68. if (bullethit==3 && shieldsup==false && armourup==false)
  69. {
  70. health = health - 30;
  71. bullethit = false;
  72. }
  73.  
  74. if (bullethit==3 && shieldsup==false && armourup==true)
  75. {
  76. armour = armour - 15;
  77. bullethit = false;
  78. }
  79.  
  80. if (bullethit==3 && shieldsup==true)
  81. {
  82. shield = shield - 12;
  83. bullethit = false;
  84. }
  85.  
  86. if (bullethit==4 && shieldsup==false&&armourup==false)
  87. {
  88. health = health - 40;
  89. bullethit = false;
  90. }
  91.  
  92. if (bullethit==4 && shieldsup==false&&armourup==true)
  93. {
  94. armour = armour - 20;
  95. bullethit = false;
  96. }
  97.  
  98. if (bullethit==4 && shieldsup)
  99. {
  100. shield = shield - 17;
  101. bullethit = false;
  102. }
  103.  
  104.  
  105. if (bullethit==5 && shieldsup==false&&armourup==false)
  106. {
  107. health = health - 45;
  108. bullethit = false;
  109. }
  110.  
  111. if (bullethit==5 && shieldsup==false&&armourup==true)
  112. {
  113. armour = armour - 22;
  114. bullethit = false;
  115. }
  116.  
  117. if (bullethit==5 && shieldsup==true)
  118. {
  119. shield = shield - 20;
  120. }
  121.  
  122. if (bullethit==6)
  123. {
  124. shield =0;
  125. armour =0;
  126. health =0;
  127. }
  128.  
  129. if (health==0)
  130. {
  131. dead=true;
  132. }
  133.  
  134. if (armour==0)
  135. {
  136. armourup = false;
  137. }
  138.  
  139. if (shield==0)
  140. {
  141. shieldsup = false;
  142. }
  143.  
  144. if (dead==true)
  145. {
  146. clear_to_color( screen, makecol( 0, 0, 0));
  147. textout_ex( screen, font, "You are dead!", 320, 240, makecol( 255, 0, 0), makecol( 0, 0, 0));;
  148. }
  149.  
  150. if (armourup==false)
  151. {
  152. clear_to_color( screen, makecol( 0, 0, 0));
  153. textout_ex( screen, font, "No more armour!", 320, 240, makecol( 255, 0, 0), makecol( 0, 0, 0));;
  154. }
  155.  
  156. if (shieldsup==false)
  157. {
  158. clear_to_color( screen, makecol( 0, 0, 0));
  159. textout_ex( screen, font, "No more shields!", 320, 240, makecol( 255, 0, 0), makecol(0, 0, 0));;
  160. }
  161.  
  162. while (!key[KEY_ESC]){
  163. clear_to_color( screen, makecol(0, 0, 0));
  164. textout_ex( screen, font, "Shields: " + shield, 320, 240, makecol(255, 0, 0), makecol(0, 0, 0));;
  165. textout_ex( screen, font, "Armour : " + armour, 320, 230, makecol(255, 0, 0), makecol(0, 0, 0));;
  166. textout_ex( screen, font, "Health: " + health, 320, 220, makecol(255, 0, 0), makecol(0, 0, 0));;
  167. }
  168. }
  169.  
  170. void testattack(){
  171. int weapon;
  172. cout<<"1=laser 2=cannon 3=part 4=missile 5=homing 6=NUKE"<<endl;
  173. cin>>weapon;
  174. bullethit=weapon;
  175. ship();
  176. }
  177.  
  178. #undef main
  179.  
  180. int main(int argc, char* argv[]){
  181. while(running==true)
  182. {
  183. testattack();
  184. }
  185. return 0;
  186. }

Please help me!

Thanks
Mark
Similar Threads
Featured Poster
Reputation Points: 68
Solved Threads: 85
Veteran Poster
SgtMe is offline Offline
1,188 posts
since Oct 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC