C++ game?

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

Join Date: Mar 2004
Posts: 219
Reputation: BountyX is an unknown quantity at this point 
Solved Threads: 8
BountyX's Avatar
BountyX BountyX is offline Offline
Code Guru

Re: C++ game?

 
0
  #11
Apr 13th, 2004
thnx for posting it pretty cool, but use the [ C O D E ] [ / C O D E ] tags next time plz I had to school for almost an hour on my laptops little 800x600 resolution lol
A Hacker's Mind:
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes..." - J.D.Salinger
Reply With Quote Quick reply to this message  
Join Date: Mar 2004
Posts: 28
Reputation: Bleek is an unknown quantity at this point 
Solved Threads: 0
Bleek Bleek is offline Offline
Light Poster

Re: C++ game?

 
0
  #12
Apr 14th, 2004
i shall do that...
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 1
Reputation: Cercetasu is an unknown quantity at this point 
Solved Threads: 0
Cercetasu Cercetasu is offline Offline
Newbie Poster

Re: C++ game?

 
0
  #13
Apr 19th, 2004
hi, i'm a beginner in programming
i've tried to compile your game but it doesn't work. i used Borland C++ 4.52.
it says "declaration sintax error" for "using namespace std"; what does this line do??
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 573
Reputation: Dark_Omen is an unknown quantity at this point 
Solved Threads: 6
Dark_Omen Dark_Omen is offline Offline
Posting Pro

Re: C++ game?

 
0
  #14
Apr 19th, 2004
You should read "Sams Teach Yourself Game Programming in 24 Hours." It is a very good book with a lot of examples. It uses C++.
The Program compiled for me. Pretty cool program.
Reply With Quote Quick reply to this message  
Join Date: Mar 2004
Posts: 28
Reputation: Bleek is an unknown quantity at this point 
Solved Threads: 0
Bleek Bleek is offline Offline
Light Poster

Re: C++ game?

 
0
  #15
Apr 22nd, 2004
the using directive is almost like the #include command. it is using the namespace std (or standard) held in the iostream header file. what it does is it lets you use the line:

  1. cout << "Hello";
  2.  
  3. instead of needing
  4.  
  5. std::cout << "Hello";

it's just more convenient...
i do recommend the SAMS book...
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 44
Reputation: lotsofsloths is an unknown quantity at this point 
Solved Threads: 0
lotsofsloths lotsofsloths is offline Offline
Light Poster

Re: C++ game?

 
0
  #16
Jan 1st, 2007
That dice game look awsome and i compiled and played it on my computer, using dev-c++.
though i had a question: How does the computer randomize the dice roll
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: C++ game?

 
1
  #17
Jan 1st, 2007
Originally Posted by lotsofsloths View Post
That dice game look awsome and i compiled and played it on my computer, using dev-c++.
though i had a question: How does the computer randomize the dice roll
What's Google? And also look in your previous thread; it's answered there too. Bumping old threads is generally discouraged, if you have a new question, post it in its own thread.
"Technological progress is like an axe in the hands of a pathological criminal."
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 11
Reputation: virus.exe is an unknown quantity at this point 
Solved Threads: 0
virus.exe virus.exe is offline Offline
Newbie Poster

Re: C++ game?

 
0
  #18
Mar 20th, 2007
I made a pretty sweet Number Hang Man Game. Im really noob but it wasnt hard.

  1.  
  2. // Number HangMan
  3. // By: David Seviour
  4. #include <iostream>
  5. #include <string>
  6. #include <sstream>
  7. #include <cstdlib>
  8. #include <iostream>
  9. #include <time.h>
  10. #include <windows.h>
  11. #include <string>
  12. #include <cstdlib>
  13. #include <ctime>
  14.  
  15. using namespace std;
  16. int main ()
  17. {
  18.  
  19.  
  20. int c;
  21. int w=8;
  22. int s=0;
  23. int l=0;
  24.  
  25.  
  26.  
  27. int d;
  28. int e;
  29. int f;
  30. int g;
  31. int h;
  32. int i;
  33. int j;
  34. int k;
  35.  
  36. startover:
  37. srand((unsigned)time(0));
  38. int b;
  39. for(int index=0; index<1; index++){
  40. b = (rand()%100)+1; }
  41.  
  42.  
  43. cout << "\n\n\n\n\n\n\n\n\n\n\n\n";
  44. cout << " Loading.";
  45. Sleep(1000);
  46. system("cls");
  47. cout << "\n\n\n\n\n\n\n\n\n\n\n\n";
  48. cout << " Loading..";
  49. Sleep(1000);
  50. system("cls");
  51. cout << "\n\n\n\n\n\n\n\n\n\n\n\n";
  52. cout << " Loading...";
  53. Sleep(1000);
  54. system("cls");
  55. cout << "\n\n\n\n\n\n\n\n\n\n\n\n";
  56. cout << " Loading....Ready!" << endl;
  57. Sleep(1000);
  58. cout << "\n\n\n\n\n\n\n\n\n\n\n\n";
  59. system("PAUSE");
  60. system("cls");
  61.  
  62. system("title Numb4rs Hang Man");
  63. cout << "NUMB4RS HANG MAN" << endl;
  64. cout << "By: David Seviour\n\n\n\n\n\n\n\n\n\n\n\n";
  65. cout << " Press Alt+Enter for Full screen.";
  66. cout << "\n\n\n\n\n\n\n\n\n\n" << endl;
  67. system("PAUSE");
  68. system("cls");
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78. system("color 08");
  79. system("title Numb4rs Hang Man");
  80. c = 0;
  81. cout << "Number Hang Man!\n" << endl;
  82. cout << "So far You have " << l << " deaths and " << s << " survivors";
  83. cout << "\n\n\n";
  84. cout << "-------|" << endl;
  85. cout << "|" << endl;
  86. cout << "|" << endl;
  87. cout << "|" << endl;
  88. cout << "|" << endl;
  89. cout << "|" << endl;
  90. cout << "|" << endl;
  91. cout << "-----" << endl;
  92. cout << " Im a number Between 1-100" << endl;
  93. cout << "\n\n" << endl;
  94.  
  95. cout << "Guess What number I Am..." << endl;
  96. cin >> d;
  97.  
  98. if (d < b) { cout << "Go Higher!\n"; system("PAUSE"); goto loophigherlower;}
  99. else if (d > b) { cout << "Go Lower!\n"; system("PAUSE"); goto loophigherlower;}
  100. else if (d = b) {goto loopwin;}
  101.  
  102. return 0;
  103.  
  104.  
  105. // _____________________________________________________________________________________________
  106.  
  107.  
  108. loophigherlower:
  109. system("cls");
  110. system("color 02");
  111. system("title Numb4rs Hang Man");
  112. c = c + 1;
  113. cout << "Try number " << c << " of 6";
  114. if (c == w) goto LOSE;
  115. cout << "\n\n\n";
  116. cout << "-------|" << endl;
  117. cout << "| O" << endl;
  118. cout << "|" << endl;
  119. cout << "|" << endl;
  120. cout << "|" << endl;
  121. cout << "|" << endl;
  122. cout << "|" << endl;
  123. cout << "-----" << endl;
  124. cout << " Im a number Between 1-100\n" << endl;
  125. cout << " You have selected the following numbers so far: " << d;
  126. cout << "\n\n" << endl;
  127.  
  128. cout << "Guess What number I Am..." << endl;
  129. cin >> e;
  130.  
  131. if (e < b) { cout << "Go Higher!\n"; system("PAUSE"); goto loophigherlower2;}
  132. else if (e > b) { cout << "Go Lower!\n"; system("PAUSE"); goto loophigherlower2;}
  133. else if (e = b) {goto loopwin;}
  134.  
  135. return 0;
  136.  
  137. //________________________________________________________________________________________________
  138.  
  139. loophigherlower2:
  140.  
  141. system("cls");
  142. system("color 09");
  143. system("title Numb4rs Hang Man");
  144. c = c + 1;
  145. cout << "Try number " << c << " of 6";
  146. if (c == w) goto LOSE;
  147. cout << "\n\n\n";
  148. cout << "-------|" << endl;
  149. cout << "| O" << endl;
  150. cout << "| |" << endl;
  151. cout << "|" << endl;
  152. cout << "|" << endl;
  153. cout << "|" << endl;
  154. cout << "|" << endl;
  155. cout << "-----" << endl;
  156. cout << " Im a number Between 1-100\n" << endl;
  157. cout << " You have selected the following numbers so far: " << d << "," << e;
  158. cout << "\n\n" << endl;
  159. cout << "Guess What number I Am..." << endl;
  160. cin >> f;
  161.  
  162. if (f < b) { cout << "Go Higher!\n"; system("PAUSE"); goto loophigherlower3;}
  163. else if (f > b) { cout << "Go Lower!\n"; system("PAUSE"); goto loophigherlower3;}
  164. else if (f = b) {goto loopwin;}
  165.  
  166. //__________________________________________________________________________________________
  167. loophigherlower3:
  168.  
  169. system("cls");
  170. system("color 04");
  171. system("title Numb4rs Hang Man");
  172. c = c + 1;
  173. cout << "Try number " << c << " of 6";
  174. if (c == w) goto LOSE;
  175. cout << "\n\n\n";
  176. cout << "-------|" << endl;
  177. cout << "| O" << endl;
  178. cout << "| -|" << endl;
  179. cout << "|" << endl;
  180. cout << "|" << endl;
  181. cout << "|" << endl;
  182. cout << "|" << endl;
  183. cout << "-----" << endl;
  184. cout << " Im a number Between 1-100\n" << endl;
  185. cout << " You have selected the following numbers so far: " << d << "," << e << "," << f;
  186. cout << "\n\n" << endl;
  187.  
  188. cout << "Guess What number I Am..." << endl;
  189. cin >> g;
  190.  
  191. if (g < b) { cout << "Go Higher!\n"; system("PAUSE"); goto loophigherlower4;}
  192. else if (g > b) { cout << "Go Lower!\n"; system("PAUSE"); goto loophigherlower4;}
  193. else if (g = b) {goto loopwin;}
  194.  
  195. //_______________________________________________________________________________________________
  196.  
  197. loophigherlower4:
  198.  
  199. system("cls");
  200. system("color 05");
  201. system("title Numb4rs Hang Man");
  202. c = c + 1;
  203. cout << "Try number " << c << " of 6";
  204. if (c == w) goto LOSE;
  205. cout << "\n\n\n";
  206. cout << "-------|" << endl;
  207. cout << "| O" << endl;
  208. cout << "| -|-" << endl;
  209. cout << "|" << endl;
  210. cout << "|" << endl;
  211. cout << "|" << endl;
  212. cout << "|" << endl;
  213. cout << "-----" << endl;
  214. cout << " Im a number Between 1-100\n" << endl;
  215. cout << " You have selected the following numbers so far: " << d << "," << e << "," << f << "," << g;
  216. cout << "\n\n" << endl;
  217.  
  218. cout << "Guess What number I Am..." << endl;
  219. cin >> h;
  220.  
  221. if (h < b) { cout << "Go Higher!\n"; system("PAUSE"); goto loophigherlower5;}
  222. else if (h > b) { cout << "Go Lower!\n"; system("PAUSE"); goto loophigherlower5;}
  223. else if (h = b) {goto loopwin;}
  224.  
  225. //___________________________________________________________________________________________
  226. loophigherlower5:
  227.  
  228. system("cls");
  229. system("color 02");
  230. system("title Numb4rs Hang Man");
  231. c = c + 1;
  232. cout << "Try number " << c << " of 6";
  233. if (c == w) goto LOSE;
  234. cout << "\n\n\n";
  235. cout << "-------|" << endl;
  236. cout << "| O" << endl;
  237. cout << "| -|-" << endl;
  238. cout << "| |" << endl;
  239. cout << "|" << endl;
  240. cout << "|" << endl;
  241. cout << "|" << endl;
  242. cout << "-----" << endl;
  243. cout << " Im a number Between 1-100\n" << endl;
  244. cout << " You have selected the following numbers so far: " << d << "," << e << "," << f << "," << g << "," << h;
  245. cout << "\n\n" << endl;
  246.  
  247. cout << "Guess What number I Am..." << endl;
  248. cin >> i;
  249.  
  250. if (i < b) { cout << "Go Higher!\n"; system("PAUSE"); goto loophigherlower6;}
  251. else if (i > b) { cout << "Go Lower!\n"; system("PAUSE"); goto loophigherlower6;}
  252. else if (i = b) {goto loopwin;}
  253.  
  254.  
  255. //_______________________________________________________________________________________________
  256. loophigherlower6:
  257.  
  258. system("cls");
  259. system("color 09");
  260. system("title Numb4rs Hang Man");
  261. c = c + 1;
  262. cout << "Try number " << c << " of 6";
  263. if (c == w) goto LOSE;
  264. cout << "\n\n\n";
  265. cout << "-------|" << endl;
  266. cout << "| O" << endl;
  267. cout << "| -|-" << endl;
  268. cout << "| |" << endl;
  269. cout << "| o" << endl;
  270. cout << "|" << endl;
  271. cout << "|" << endl;
  272. cout << "-----" << endl;
  273. cout << " A number Between 1-100\n" << endl;
  274. cout << " You have selected the following numbers so far: " << d << "," << e << "," << f << "," << g << "," << h << "," << i;
  275. cout << "\n\n" << endl;
  276.  
  277. cout << "Guess What number I Am... Last Try!!!" << endl;
  278. cin >> j;
  279.  
  280. if (j < b) { cout << "\nHaHaHa!\n\n"; cout << "The Number Was " << b << "\n\n"; system("PAUSE"); goto loophigherlower7;}
  281. else if (j > b) { cout << "\nHeHeHe!\n\n"; cout << "The Number Was " << b << "\n\n"; system("PAUSE"); goto loophigherlower7;}
  282. else if (j = b) {goto loopwin;}
  283.  
  284. return 0;
  285.  
  286. //__________________________________________________________________________________________________
  287. loophigherlower7:
  288.  
  289. system("cls");
  290. system("title Numb4rs Hang Man");
  291. cout << "\n\n\n";
  292. cout << "-------|" << endl;
  293. cout << "| O" << endl;
  294. cout << "| -|-" << endl;
  295. cout << "| |" << endl;
  296. cout << "| o o" << endl;
  297. cout << "|" << endl;
  298. cout << "|" << endl;
  299. cout << "-----" << endl;
  300.  
  301. system("color fc");
  302. system("color cf");
  303. system("color fc");
  304. system("color fc");
  305. Sleep(100);
  306. system("color cf");
  307. Sleep(100);
  308. system("color fc");
  309. Sleep(100);
  310. system("color fc");
  311. Sleep(100);
  312. system("color cf");
  313. Sleep(500);
  314. system("color fc");
  315. Sleep(500);
  316. system("color fc");
  317. Sleep(1000);
  318. system("color cf");
  319. Sleep(1000);
  320. system("color fc");
  321. Sleep(200);
  322. system("cls");
  323.  
  324. cout << "\n\n\n";
  325. cout << "-------|" << endl;
  326. cout << "| [" << endl;
  327. cout << "| O" << endl;
  328. cout << "| -|-" << endl;
  329. cout << "| |" << endl;
  330. cout << "| o o" << endl;
  331. cout << "|" << endl;
  332. cout << "-----" << endl;
  333.  
  334. Sleep(200);
  335. system("cls");
  336. cout << "\n\n\n";
  337. cout << "-------|" << endl;
  338. cout << "| [" << endl;
  339. cout << "| ]" << endl;
  340. cout << "| O" << endl;
  341. cout << "| -|-" << endl;
  342. cout << "| |" << endl;
  343. cout << "| o o" << endl;
  344. cout << "-----" << endl;
  345.  
  346. Sleep(3000);
  347.  
  348. if (c == w) goto LOSE;
  349. //___________________________________________________________________________________________________
  350.  
  351.  
  352.  
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391. //____________________________________________________________________________________________________________
  392.  
  393. LOSE:
  394.  
  395. system("cls");
  396. cout << "\n\n";
  397. cout << "You were Hung!\n\n";
  398. system("PAUSE");
  399. system("cls\n\n");
  400. l = l + 1;
  401. goto startover;
  402.  
  403. return 0;
  404.  
  405. //_______________________________________________________________________________________________________________
  406. loopwin:
  407.  
  408.  
  409. system("title WINNER!!!");
  410.  
  411.  
  412.  
  413. system("cls");
  414. cout << "\n\n\n\n\n\n\n\n\n\n";
  415. cout << " * * * * * * | " << endl;
  416. cout << " * * * * * * * * | " << endl;
  417. cout << " * * * * * * * * | " << endl;
  418. cout << " ** ** * * * O " << endl;
  419. system("color fc");
  420. system("color 0f");
  421. system("color e6");
  422. system("color c3");
  423. system("color ae");
  424. system("color e3");
  425. system("color 4c");
  426. system("color a1");
  427. system("color d2");
  428. system("color fc");
  429. system("color 0f");
  430. system("color e6");
  431. system("color c3");
  432. system("color ae");
  433. system("color e3");
  434. system("color 4c");
  435. system("color a1");
  436. system("color d2");
  437. system("color fc");
  438. system("color 0f");
  439. system("color e6");
  440. system("color c3");
  441. system("color ae");
  442. system("color e3");
  443. system("color 4c");
  444. system("color a1");
  445. system("color d2");
  446. system("color fc");
  447. system("color 0f");
  448. system("color e6");
  449. system("color c3");
  450. system("color ae");
  451. system("color e3");
  452. system("color 4c");
  453. system("color a1");
  454. system("color d2");
  455. system("color fc");
  456. system("color 0f");
  457. system("color e6");
  458. system("color c3");
  459. system("color ae");
  460. system("color e3");
  461. system("color 4c");
  462. system("color a1");
  463. system("color d2");
  464.  
  465.  
  466. cout << "\n\n\n\n\n\n\n";
  467. system("PAUSE");
  468. system("cls\n\n");
  469. s = s + 1;
  470. goto startover;
  471.  
  472. return 0;
  473.  
  474. }

lol it's kinda fun, anywayz add me on msn for any help with noob stuff.

<snip email>

peace
Last edited by Ancient Dragon; Nov 27th, 2007 at 9:56 am. Reason: snipped email
Reply With Quote Quick reply to this message  
Join Date: Oct 2005
Posts: 287
Reputation: Clinton Portis is an unknown quantity at this point 
Solved Threads: 28
Clinton Portis's Avatar
Clinton Portis Clinton Portis is offline Offline
Posting Whiz in Training

Re: C++ game?

 
0
  #19
Mar 20th, 2007
  1. //Preprocessor Directives
  2. #include<iostream>
  3. #include<string>
  4. #include<cstdlib>
  5. #include<cctype>
  6. #include<ctime>
  7.  
  8. using namespace std;
  9.  
  10. //Function Prototypes
  11. void SeedRandom();
  12. void PrintHeader();
  13. void PlayOneMatch(int&, int&, int&, int&, int&);
  14. int GetPlayerChoice();
  15. int DrawNum(int);
  16. void PrintMove(int, int, int&, int&);
  17. void WonAGame(char, int&, int&, int&);
  18. void PrintFinalResults(int, int, int, int);
  19. void Reset(int&, int&, int&, int&, int&, int&, int&);
  20.  
  21. //Main Driver
  22. int main()
  23. {
  24. char WinnerNumber = '0';
  25. int GamesWon = 0,
  26. WinnerMoney = 0,
  27. LoserMoney = 0,
  28. Player1Money = 100,
  29. Player2Money = 100,
  30. Games1Won = 0,
  31. Games2Won = 0,
  32. TieCount = 0,
  33. MatchCounter = 0,
  34. TotalGames = 0;
  35.  
  36. SeedRandom();
  37.  
  38. do{
  39. Reset(GamesWon, WinnerMoney, LoserMoney, Games1Won, Games2Won, TieCount, MatchCounter);
  40. PrintHeader();
  41. PlayOneMatch(Games1Won, Games2Won, TieCount, Player1Money, Player2Money);
  42. PrintFinalResults(Games1Won, Games2Won, TieCount, TotalGames+=3);
  43.  
  44. }while(TotalGames < 20 || !Player1Money || !Player2Money);
  45.  
  46. return 0;
  47. }
  48.  
  49.  
  50. //Function Definitions
  51. void SeedRandom()
  52. {
  53. srand(time(NULL));
  54. }
  55.  
  56. void PrintHeader()
  57. {
  58. cout << "\n\t----------=====******=====----------"
  59. << "\n\tRock, Paper, and Scissors:"
  60. << "\n\t----------=====******=====----------"
  61. << "\n\n\tThis program plays the EXCITING game of Rock, Paper,"
  62. << "\n\tand Scissors. Two players choose either Rock, Paper or Scissors,"
  63. << "\n\tand the results of their picks are compared. Each match is"
  64. << "\n\tdetermined as follows:"
  65. << "\n\n\tPlayer 1 Player 2 Result"
  66. << "\n\t-------- -------- ------"
  67. << "\n\t--- --- Any matching combo. A tie!"
  68. << "\n\n\tNow you are about to play against world-class computer"
  69. << "\n\tchampion Dr. Windows. You are Player 1, and the computer"
  70. << "\n\tis Player 2. Player 2's moves are randomly chosen by the computer."
  71. << "\n\tBoth players start with $100 and the game is finished when either one player"
  72. << "\n\treaches $0 or there have been 3 matches played. The bet per metch is $5.";
  73. }
  74.  
  75. void PlayOneMatch(int& Games1Won, int& Games2Won, int& TieCount,
  76. int& Player1Money, int& Player2Money)
  77. {
  78. int playerchoice = 0,
  79. computerchoice = 0,
  80. MatchCounter = 0;
  81.  
  82. do{
  83.  
  84. cout << "\n\n\tPlayer 1, Enter your choice of"
  85. << "\n\t 1 Rock"
  86. << "\n\t 2 Paper"
  87. << "\n\t 3 Scissors -> ";
  88.  
  89. playerchoice = GetPlayerChoice();
  90. computerchoice = DrawNum(3);
  91.  
  92. if(playerchoice == computerchoice)
  93.  
  94. TieCount++;
  95.  
  96. else if(playerchoice > computerchoice ||
  97. playerchoice == 1 && computerchoice == 3)
  98. {
  99. ++Games1Won;
  100. WonAGame('1', Games1Won, Player1Money, Player2Money);
  101. }
  102.  
  103. else
  104. {
  105. ++Games2Won;
  106. WonAGame('2', Games2Won, Player2Money, Player1Money);
  107. }
  108.  
  109. PrintMove(playerchoice, computerchoice, Player2Money, Player1Money);
  110. MatchCounter++;
  111.  
  112. }while(MatchCounter < 3 || !Player1Money || !Player2Money);
  113. }
  114.  
  115. int GetPlayerChoice()
  116. {
  117. char choice = '0';
  118.  
  119. cin.get(choice);
  120. cin.ignore(1000,'\n');
  121.  
  122. while(!isdigit(choice) || choice < '1' || choice > '3')
  123. {
  124. cout << "\n\t\aThat was not a valid entry. Please try again -> ";
  125. cin.get(choice);
  126. cin.ignore(1000,'\n');
  127. }
  128.  
  129. return atoi(&choice);
  130. }
  131.  
  132. int DrawNum(int max)
  133. {
  134. double x = RAND_MAX + 1.0;
  135. int y = 0;
  136.  
  137. y = static_cast<int> (1 + rand() * (max / x));
  138.  
  139. return (y);
  140. }
  141.  
  142. void PrintMove(int Move1, int Move2, int& Player1Money, int& Player2Money)
  143. {
  144. string action[] = {"rock", "paper", "scissors"};
  145.  
  146. cout << "\n\n\tRESULTS OF THIS MOVE"
  147. << "\n\t=-=-=-=-=-=-=-=-=-=-"
  148. << "\n\t Player 1 Player 2 Player 1's Player 2's"
  149. << "\n\tNumber Action Number Action Winner Money Money"
  150. << "\n\t------ ------ ------ ------ ------ ----- -----"
  151. << "\n\t " << Move1 << " " << action[Move1-1]
  152. << " " << Move2 << " " << action[Move2-1] << " ";
  153.  
  154. if(Move1 == Move2)
  155.  
  156. cout << "A tie!";
  157.  
  158. else if(Move1 > Move2 || Move1 == 1 && Move2 == 3)
  159.  
  160. cout << "Player 1!";
  161.  
  162. else
  163.  
  164. cout << "Player 2!";
  165.  
  166. cout << " $" << Player1Money << " $" << Player2Money;
  167. }
  168.  
  169. void WonAGame(char WinnerNumber, int& GamesWon, int& WinnerMoney, int& LoserMoney)
  170. {
  171. switch(WinnerNumber)
  172. {
  173. case '1': WinnerMoney-=5;
  174. LoserMoney+=5;
  175. break;
  176.  
  177. case '2': LoserMoney+=5;
  178. WinnerMoney-=5;
  179. break;
  180. }
  181. }
  182.  
  183. void PrintFinalResults(int Games1Won, int Games2Won, int TieCount, int TotalGames)
  184. {
  185. cout << "\n\n\n\tAnd there you have it folks, the final match between our two"
  186. << "\n\tcontestants. The final results for tonight's game are as follows:"
  187. << "\n\n\t Player 1 Player 2"
  188. << "\n\t ======== ========"
  189. << "\n\tGames Won: " << Games1Won << " " << Games2Won
  190. << "\n\tPercent Won: " << static_cast<int>(((double)Games1Won/3)*100)
  191. << "% " << static_cast<int>(((double)Games2Won/3)*100) << '%'
  192. << "\n\n\t\tTotal games tied: " << TieCount
  193. << "\n\t\tTotal games played: " << TotalGames
  194. << "\n\t\tThe overall winner is ";
  195.  
  196. if(Games1Won == Games2Won)
  197.  
  198. cout << "Both!";
  199.  
  200. else if(Games1Won > Games2Won)
  201.  
  202. cout << "Player 1!";
  203.  
  204. else
  205.  
  206. cout << "Player 2!";
  207.  
  208. cout << "\n\n\tStop in again soon to play another exciting match!!!\n\n\n\n\n\n";
  209. }
  210.  
  211. void Reset(int& GamesWon, int& WinnerMoney, int& LoserMoney, int& Games1Won,
  212. int& Games2Won, int& TieCount, int& MatchCounter)
  213. {
  214. GamesWon = 0;
  215. WinnerMoney = 0;
  216. LoserMoney = 0;
  217. Games1Won = 0;
  218. Games2Won = 0;
  219. TieCount = 0;
  220. MatchCounter = 0;
  221. }
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 1
Reputation: kannan420bar is an unknown quantity at this point 
Solved Threads: 0
kannan420bar kannan420bar is offline Offline
Newbie Poster

Re: C++ game?

 
-1
  #20
Nov 26th, 2007
oh cool
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