IMPORTANT.. need help asap please!

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2006
Posts: 8
Reputation: shadowmoon is an unknown quantity at this point 
Solved Threads: 0
shadowmoon shadowmoon is offline Offline
Newbie Poster

IMPORTANT.. need help asap please!

 
0
  #1
Dec 12th, 2006
ok.. my problem is..
my midterm source code is due tomorw.. unfortunatly i cant get thsi music to play... my group REALLy wants the music and i thin itll boost my chances of an a... when i ran this music in the original(just the music) it runs fine.. when i put it in the iff statement in my code... i get 7000 errors... most complain about mmsystem.h

if i take out the mmsystem.h i get no errors for the most part and it runs like normal.. but no music.,...:cry:

i have left out mmsystem.h in this version.. if u run dev-c++ u have to add linker winlibmm.a using project options>>parameters>> add linker.



  1. #include <iostream.h>
  2. #include <iomanip.h>
  3. #include <cstdlib>
  4. #include <windows.h>
  5. using namespace std;
  6. int main()
  7. {
  8. char gender;
  9. char option;
  10. char race;
  11. int hp = 100;
  12. int ehp = 100;
  13. int str;
  14. int intel;
  15. int suck = 10;
  16. int mp;
  17. int armor;
  18. int weapon;
  19. int armor2;
  20. cout << "Please choose your gender(M/F). ";
  21. cin >> gender;
  22. switch(gender)
  23. {
  24. case 'm':
  25. case 'M':
  26. cout << "You have chosen a male character. \n";
  27. cout << "Please choose your class.(Mage,Fighter,Archer.[M,F,A]) ";
  28. cin >> race;
  29. switch(race)
  30. { //start of male race switch
  31. case 'm':
  32. case 'M':
  33. cout << "You have chosen the Mage. ";
  34. hp = 75;
  35. str = 5;
  36. intel = 15;
  37. armor = 2;
  38. mp = intel * 10;
  39. break;
  40. case 'f':
  41. case 'F':
  42. cout << "You have chosen the Fighter. ";
  43. hp = 120;
  44. str = 15;
  45. intel = 5;
  46. armor = 5;
  47. mp = intel * 10;
  48. break;
  49. case 'a':
  50. case 'A':
  51.  
  52. cout << "You have chosen the Archer. ";
  53. hp = 100;
  54. str = 10;
  55. intel = 10;
  56. armor = 3;
  57. mp = intel * 10;
  58. break;
  59.  
  60. }//end of male race switch
  61. break;
  62. case 'f':
  63. case 'F':
  64. cout << "You have chosen a female character.\n ";
  65. cout << "Please choose your class.(Mage,Fighter,Archer.[M,F,A]) ";
  66. cin >> race;
  67. switch(race)
  68. {//start of female race switch
  69. case 'm':
  70. case 'M':
  71. cout << "You have chosen the Mage. ";
  72. hp = 75;
  73. str = 5;
  74. intel = 15;
  75. armor = 2;
  76. mp = intel * 10;
  77. break;
  78. case 'f':
  79. case 'F':
  80. cout << "You have chosen the Fighter. ";
  81. hp = 120;
  82. str = 15;
  83. intel = 5;
  84. armor = 5;
  85. mp = intel * 10;
  86. break;
  87. case 'a':
  88. case 'A':
  89. cout << "You have chosen the Archer. ";
  90. hp = 100;
  91. str = 10;
  92. intel = 10;
  93. armor = 3;
  94. mp = intel * 10;
  95. break;
  96.  
  97. }//end of F race switch
  98. break;
  99. }//end of Gender
  100. cout << "Choose your weapon.\n";
  101. cout << "Katana(1). \n";
  102. cout << "Great sword(2). \n";
  103. cout << "Battle Staff(3). \n";
  104. cout << "Silver bow(4). \n";
  105. cout << "Winged Staff(5). \n";
  106. cin >> weapon;
  107. switch(weapon)
  108. {
  109. case 1:
  110. cout << "You have chosen the Katana. \n";
  111. str = str + 3;
  112. break;
  113. case 2:
  114. cout << "You have chosen the Great sword. \n";
  115. str = str + 5;
  116. armor = armor - 2;
  117. break;
  118. case 3:
  119. cout << "You have chosen the Battle Staff. \n";
  120. str = str + 2;
  121. intel = intel - 2;
  122. break;
  123. case 4:
  124. cout << "You have chosen the Silver Bow. \n";
  125. str = str + 2;
  126. armor = armor + 2;
  127. break;
  128. case 5:
  129. cout << "You have chosen the Winged Staff. \n";
  130. intel = intel + 4;
  131. armor = armor + 1;
  132. break;
  133. }
  134.  
  135. cout << "Choose your armor.\n";
  136. cout << "Chain armor(1). \n";
  137. cout << "Leather armor(2). \n";
  138. cin >> armor;
  139. switch(armor)
  140. {
  141. case 1:
  142. cout << "You have chosen Chain armor.\n";
  143. armor = armor + 4;
  144. intel = intel - 2;
  145. break;
  146. case 2:
  147. cout << "You have chosen Leather armor.\n";
  148. armor = armor + 2;
  149. break;
  150. }
  151. cout << "An Oppel attacks! \n \n";
  152. while(ehp > 0 && hp > 0)
  153. {
  154. cout << "Choose an option. Attack,Magic,Items,Run. \n";
  155. cin >> option;
  156. switch(option)
  157. {
  158. case 'a':
  159. case 'A':
  160. ehp = ehp - str;
  161. hp = hp - (suck - armor);
  162. suck++;
  163. cout << "Your hp is " << hp << ". \n";
  164. cout << "The Oppel's hp is " << ehp << ". \n";
  165. cout << "Your mp is " << mp << ". \n";
  166. if(ehp < 0)
  167. {
  168.  
  169. ehp = 0;
  170. }
  171. break;
  172. case 'm':
  173. case 'M':
  174.  
  175. ehp = ehp - intel;
  176. hp = hp - (suck - armor);
  177. suck++;
  178. mp = mp - 10;
  179. if(ehp < 0)
  180. {
  181.  
  182. ehp = 0;
  183. }
  184. cout << "Your hp is " << hp << ". \n";
  185. cout << "The Oppel's hp is " << ehp << ". \n";
  186. cout << "Your mp is " << mp << ". \n";
  187. break;
  188. case 'i':
  189. case 'I':
  190. cout << "You have no items! \n";
  191. break;
  192. case 'r':
  193. case 'R':
  194. cout << "You flee the Oppel in shame. \n";
  195. hp = 0;
  196.  
  197. break;
  198. }
  199.  
  200. }
  201.  
  202. if(ehp <= 0)
  203. {
  204.  
  205. cout << "VICTORY! \n";
  206. cout << "Please wait...";
  207.  
  208.  
  209. mciSendString("play E:\ff7vict2.midi",NULL,0,NULL);
  210.  
  211.  
  212. cout << "\n\nPress Enter to stop ...";
  213. cin.get();
  214.  
  215. mciSendString("stop E:\ff7vict2.midi",NULL,0,NULL);
  216. }
  217. if(hp <= 0)
  218. {
  219. cout << "You have lost. \n";
  220. cout << "GAME OVER!! \n";
  221. }
  222.  
  223. system("PAUSE");
  224. return 0;
  225. }
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 5,051
Reputation: John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold 
Solved Threads: 332
Team Colleague
John A's Avatar
John A John A is offline Offline
Vampirical Lurker

Re: IMPORTANT.. need help asap please!

 
0
  #2
Dec 12th, 2006
Most likely due to the fact that most of the objects referenced in mmsystem.h are actually defined in winmm.lib -- a library you need to link your program with, or you'll get a ton of errors. In the compiler configuration, look for a list of .libs, then add winmm.lib to the end.

Hope this helps
"Technological progress is like an axe in the hands of a pathological criminal."
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 8
Reputation: shadowmoon is an unknown quantity at this point 
Solved Threads: 0
shadowmoon shadowmoon is offline Offline
Newbie Poster

Re: IMPORTANT.. need help asap please!

 
0
  #3
Dec 12th, 2006
well this code now has mmsystem.h in it BUT still no sounds... strange how i did nothing but add itin today ande im not getting errors frmo yesterday.

also. programmer isnt adding libwinmm.a thru project options>> parameters the same thing??(dev-C++)










  1. #include <iostream.h>
  2. #include <iomanip.h>
  3. #include <cstdlib>
  4. #include <windows.h>
  5. #include <mmsystem.h>
  6. using namespace std;
  7. int main()
  8. {
  9. char gender;
  10. char option;
  11. char race;
  12. int hp = 100;
  13. int ehp = 100;
  14. int str;
  15. int intel;
  16. int suck = 10;
  17. int mp;
  18. int armor;
  19. int weapon;
  20. int armor2;
  21. cout << "Please choose your gender(M/F). ";
  22. cin >> gender;
  23. switch(gender)
  24. {
  25. case 'm':
  26. case 'M':
  27. cout << "You have chosen a male character. \n";
  28. cout << "Please choose your class.(Mage,Fighter,Archer.[M,F,A]) ";
  29. cin >> race;
  30. switch(race)
  31. { //start of male race switch
  32. case 'm':
  33. case 'M':
  34. cout << "You have chosen the Mage. ";
  35. hp = 75;
  36. str = 5;
  37. intel = 15;
  38. armor = 2;
  39. mp = intel * 10;
  40. break;
  41. case 'f':
  42. case 'F':
  43. cout << "You have chosen the Fighter. ";
  44. hp = 120;
  45. str = 15;
  46. intel = 5;
  47. armor = 5;
  48. mp = intel * 10;
  49. break;
  50. case 'a':
  51. case 'A':
  52.  
  53. cout << "You have chosen the Archer. ";
  54. hp = 100;
  55. str = 10;
  56. intel = 10;
  57. armor = 3;
  58. mp = intel * 10;
  59. break;
  60.  
  61. }//end of male race switch
  62. break;
  63. case 'f':
  64. case 'F':
  65. cout << "You have chosen a female character.\n ";
  66. cout << "Please choose your class.(Mage,Fighter,Archer.[M,F,A]) ";
  67. cin >> race;
  68. switch(race)
  69. {//start of female race switch
  70. case 'm':
  71. case 'M':
  72. cout << "You have chosen the Mage. ";
  73. hp = 75;
  74. str = 5;
  75. intel = 15;
  76. armor = 2;
  77. mp = intel * 10;
  78. break;
  79. case 'f':
  80. case 'F':
  81. cout << "You have chosen the Fighter. ";
  82. hp = 120;
  83. str = 15;
  84. intel = 5;
  85. armor = 5;
  86. mp = intel * 10;
  87. break;
  88. case 'a':
  89. case 'A':
  90. cout << "You have chosen the Archer. ";
  91. hp = 100;
  92. str = 10;
  93. intel = 10;
  94. armor = 3;
  95. mp = intel * 10;
  96. break;
  97.  
  98. }//end of F race switch
  99. break;
  100. }//end of Gender
  101. cout << "Choose your weapon.\n";
  102. cout << "Katana(1). \n";
  103. cout << "Great sword(2). \n";
  104. cout << "Battle Staff(3). \n";
  105. cout << "Silver bow(4). \n";
  106. cout << "Winged Staff(5). \n";
  107. cin >> weapon;
  108. switch(weapon)
  109. {
  110. case 1:
  111. cout << "You have chosen the Katana. \n";
  112. str = str + 3;
  113. break;
  114. case 2:
  115. cout << "You have chosen the Great sword. \n";
  116. str = str + 5;
  117. armor = armor - 2;
  118. break;
  119. case 3:
  120. cout << "You have chosen the Battle Staff. \n";
  121. str = str + 2;
  122. intel = intel - 2;
  123. break;
  124. case 4:
  125. cout << "You have chosen the Silver Bow. \n";
  126. str = str + 2;
  127. armor = armor + 2;
  128. break;
  129. case 5:
  130. cout << "You have chosen the Winged Staff. \n";
  131. intel = intel + 4;
  132. armor = armor + 1;
  133. break;
  134. }
  135.  
  136. cout << "Choose your armor.\n";
  137. cout << "Chain armor(1). \n";
  138. cout << "Leather armor(2). \n";
  139. cin >> armor;
  140. switch(armor)
  141. {
  142. case 1:
  143. cout << "You have chosen Chain armor.\n";
  144. armor = armor + 4;
  145. intel = intel - 2;
  146. break;
  147. case 2:
  148. cout << "You have chosen Leather armor.\n";
  149. armor = armor + 2;
  150. break;
  151. }
  152. cout << "An Oppel attacks! \n \n";
  153. while(ehp > 0 && hp > 0)
  154. {
  155. cout << "Choose an option. Attack,Magic,Items,Run. \n";
  156. cin >> option;
  157. switch(option)
  158. {
  159. case 'a':
  160. case 'A':
  161. ehp = ehp - str;
  162. hp = hp - (suck - armor);
  163. suck++;
  164. cout << "Your hp is " << hp << ". \n";
  165. cout << "The Oppel's hp is " << ehp << ". \n";
  166. cout << "Your mp is " << mp << ". \n";
  167. if(ehp < 1)
  168. {
  169.  
  170. ehp = 0;
  171. }
  172. break;
  173. case 'm':
  174. case 'M':
  175.  
  176. ehp = ehp - intel;
  177. hp = hp - (suck - armor);
  178. suck++;
  179. mp = mp - 10;
  180. if(ehp < 0)
  181. {
  182.  
  183. ehp = 0;
  184. }
  185. cout << "Your hp is " << hp << ". \n";
  186. cout << "The Oppel's hp is " << ehp << ". \n";
  187. cout << "Your mp is " << mp << ". \n";
  188. break;
  189. case 'i':
  190. case 'I':
  191. cout << "You have no items! \n";
  192. break;
  193. case 'r':
  194. case 'R':
  195. cout << "You flee the Oppel in shame. \n";
  196. hp = 0;
  197.  
  198. break;
  199. }
  200.  
  201. }
  202.  
  203. if(ehp <= 0)
  204. {
  205.  
  206. cout << "VICTORY! \n";
  207. cout << "Please wait...";
  208.  
  209.  
  210. mciSendString("play E:\ff7vict2.mid",NULL,0,NULL);
  211.  
  212.  
  213. cout << "\n\nPress Enter to stop ...";
  214. cin.get();
  215.  
  216. mciSendString("stop E:\ff7vict2.mid",NULL,0,NULL);
  217. }
  218. if(hp <= 0)
  219. {
  220. cout << "You have lost. \n";
  221. cout << "GAME OVER!! \n";
  222. }
  223.  
  224. system("PAUSE");
  225. return 0;
  226. }
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 5,051
Reputation: John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold 
Solved Threads: 332
Team Colleague
John A's Avatar
John A John A is offline Offline
Vampirical Lurker

Re: IMPORTANT.. need help asap please!

 
0
  #4
Dec 12th, 2006
> also. programmer isnt adding libwinmm.a thru project options>> parameters the same thing??(dev-C++)

Yes, it is. I didn't mention libwinmm.a as an alternative option to winmm.lib if you're using Dev-C++.

It'll be kind of hard for me to debug your program though, as I'm not on a Windows machine, and I won't be able to compile/run your code. Just a thought, aren't you supposed to run
  1. mciSendString("open C:\\path");
before you you try to play it. If I'm wrong, sorry because I've never actually used mmsystem.h, I just read that you have to do that in some online guide.

Another thing: in your paths, you're supposed to use double \\s to indicate that it's not an escape charecter! That could be the problem right there.
"Technological progress is like an axe in the hands of a pathological criminal."
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,609
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 464
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: IMPORTANT.. need help asap please!

 
0
  #5
Dec 12th, 2006
Originally Posted by joeprogrammer View Post
Another thing: in your paths, you're supposed to use double \\s to indicate that it's not an escape charecter! That could be the problem right there.
You can do the same thing with a single forward slash (/), its more portable.
I don't accept change; I don't deserve to live.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC