943,463 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 64207
  • C++ RSS
You are currently viewing page 1 of this multi-page discussion thread
Apr 6th, 2004
1

C++ game?

Expand Post »
Is it possible to make a very simple game with C++? any good sites to read up on how to do it? I have a program called Dev-C++. any kind of tips or code that i should know? I'm am just a noob at C++. I wish to play with it before I attend a computer programing camp during this summer. thanks
Similar Threads
Reputation Points: 29
Solved Threads: 1
Junior Poster
viperman224 is offline Offline
183 posts
since Dec 2003
Apr 6th, 2004
1

Re: C++ game?

Of course it is possible. I've been thinking about making a command-line (text) based RPG with C++. What you could do is say, create some bad guys, create a menu of what the user can do to them, randomize some attacks and etc... It will take a lot of function work but yes it could be done. I don't know of any good sites that provide basic game info. But there are lots of OpenGL sites and advanced sites. But you won't make a 3D game by this summer so I'd stick with command line stuff.
Reputation Points: 12
Solved Threads: 0
Newbie Poster
Creator is offline Offline
5 posts
since Mar 2004
Apr 6th, 2004
0

Re: C++ game?

C/C++ is a fully functional language, you make the computer do virtually ANYTHING you want. The limitations of the language can be overcome with experience and skills.

BTW: 73.2 % of all games on the market are created in C/C++ in cluding popular titles such as Warcraft 3, and Diablo 2.
Reputation Points: 28
Solved Threads: 9
Posting Whiz in Training
BountyX is offline Offline
222 posts
since Mar 2004
Apr 7th, 2004
0

Re: C++ game?

I just wrote a small game in C++. I also have the source code to a few RPG games. It actually isn't that hard to make a console RPG. And as BountyX said, funny you should ask if games could be made in C++ because almost all games are. So you've picked the right language! You wouldn't want Java or C# as much because they are slower languages.
Reputation Points: 12
Solved Threads: 0
Newbie Poster
Creator is offline Offline
5 posts
since Mar 2004
Apr 7th, 2004
1

Re: C++ game?

You can now get the original Quake source files (C++) and see what a full game looks like.

Check the website for it. Its released under the GNU rules.
Reputation Points: 11
Solved Threads: 0
Newbie Poster
Tempus is offline Offline
2 posts
since Apr 2004
Apr 8th, 2004
1

Re: C++ game?

i have my first game code of a dice game you can look at if you would like. ill post it if you reply back, it displays the dice using characters... its simple but i like it.
Reputation Points: 45
Solved Threads: 0
Light Poster
Bleek is offline Offline
28 posts
since Mar 2004
Apr 8th, 2004
0

Re: C++ game?

I would be glad to take a look at it
Reputation Points: 29
Solved Threads: 1
Junior Poster
viperman224 is offline Offline
183 posts
since Dec 2003
Apr 9th, 2004
0

Re: C++ game?

post is please
Reputation Points: 28
Solved Threads: 9
Posting Whiz in Training
BountyX is offline Offline
222 posts
since Mar 2004
Apr 13th, 2004
0

Re: C++ game?

Honestly, you really should use C#. Its alot more fun.
Reputation Points: 11
Solved Threads: 0
Newbie Poster
Tempus is offline Offline
2 posts
since Apr 2004
Apr 13th, 2004
0

Re: C++ game?

i wrote it a while ago but anyways...
Dice Game

C++ Syntax (Toggle Plain Text)
  1. /*
  2.   Name: Dice Game
  3.   Author: Bleek
  4.   Description: Game
  5.   Date: N/A
  6.   Copyright: N/A
  7. */
  8.  
  9. #include <iostream>
  10. #include <time.h>
  11. #include <cstdlib>
  12. #include <windows.h>
  13. using namespace std;
  14. void one();
  15. void two();
  16. void three();
  17. void four();
  18. void five();
  19. void six();
  20. //Declare Functions used
  21. int main()
  22. {
  23. short unsigned int score = 0;
  24. short unsigned int compScore = 0;
  25. short unsigned int num = 0;
  26. short unsigned int num2 = 0;
  27. short unsigned int compNum = 0;
  28. short unsigned int compNum2 = 0;
  29. short unsigned int sum = 0;
  30. short unsigned int compSum = 0;
  31. char letter;
  32. //Declare Variables
  33. srand(time(NULL));
  34. //Initialize random number generator
  35. system("title Joe's Dice Game");
  36. while (letter != 'q')
  37. {
  38. cout << "Your Score: " << score << endl;
  39. cout << "computer's Score: " << compScore << endl << endl;
  40. cout << "Press r to roll or q to quit: ";
  41. cin >> letter;
  42. num = 1 + rand() % (6 - 1 + 1);
  43. num2 = 1 + rand() % (6 - 1 + 1);
  44. compNum = 1 + rand() % (6 - 1 + 1);
  45. compNum2 = 1 + rand() % (6 - 1 + 1);
  46.  
  47. //Random numbers
  48.  
  49. sum = num + num2;
  50. compSum = compNum + compNum2;
  51.  
  52. //Calculate Sums
  53.  
  54. if (letter == 'q')
  55. break;
  56. if (letter != 'r')
  57. {
  58. system("cls");
  59. continue;
  60. }
  61.  
  62. switch (num)
  63. {
  64. case 1:
  65. one();
  66. break;
  67. case 2:
  68. two();
  69. break;
  70. case 3:
  71. three();
  72. break;
  73. case 4:
  74. four();
  75. break;
  76. case 5:
  77. five();
  78. break;
  79. case 6:
  80. six();
  81. break;
  82. default:
  83. cout << "Error...";
  84. break;
  85. } //end switch
  86.  
  87. switch (num2)
  88. {
  89. case 1:
  90. one();
  91. break;
  92. case 2:
  93. two();
  94. break;
  95. case 3:
  96. three();
  97. break;
  98. case 4:
  99. four();
  100. break;
  101. case 5:
  102. five();
  103. break;
  104. case 6:
  105. six();
  106. break;
  107. default:
  108. cout << "Error...";
  109. break;
  110. } //end switch
  111.  
  112. cout << endl << "Yours: " << num << ", " << num2 << endl;
  113. cout << "Computer's: " << compNum << ", " << compNum2 << "\n\n";
  114.  
  115. //Display dice and numbers
  116.  
  117. if (sum > compSum)
  118. {
  119. cout << "You won!!" << endl << endl;
  120. score++;
  121. }
  122. else
  123. {
  124. compScore++;
  125. cout << "you lost..." << endl << endl;
  126. }
  127.  
  128. //Calculate score
  129.  
  130. system("pause");
  131. system("cls");
  132.  
  133. if (score == 12)
  134. {
  135. MessageBox(0, "You Won!!!", "Results:", MB_ICONEXCLAMATION);
  136. break;
  137. }
  138. if (compScore == 12)
  139. {
  140. MessageBox(0, "You lost...", "Results:", MB_ICONEXCLAMATION);
  141. break;
  142. }
  143. }
  144. return 0;
  145. }
  146.  
  147. void one()
  148. {
  149. cout << " -----" << endl;
  150. cout << "| |" << endl;
  151. cout << "| O |" << endl;
  152. cout << "| |" << endl;
  153. cout << " -----" << endl;
  154. }
  155. void two()
  156. {
  157. cout << " -----" << endl;
  158. cout << "| O|" << endl;
  159. cout << "| |" << endl;
  160. cout << "|O |" << endl;
  161. cout << " -----" << endl;
  162. }
  163. void three()
  164. {
  165. cout << " -----" << endl;
  166. cout << "| O|" << endl;
  167. cout << "| O |" << endl;
  168. cout << "|O |" << endl;
  169. cout << " -----" << endl;
  170. }
  171. void four()
  172. {
  173. cout << " -----" << endl;
  174. cout << "|O O|" << endl;
  175. cout << "| |" << endl;
  176. cout << "|O O|" << endl;
  177. cout << " -----" << endl;
  178. }
  179. void five()
  180. {
  181. cout << " -----" << endl;
  182. cout << "|O O|" << endl;
  183. cout << "| O |" << endl;
  184. cout << "|O O|" << endl;
  185. cout << " -----" << endl;
  186. }
  187. void six()
  188. {
  189. cout << " -----" << endl;
  190. cout << "|O O|" << endl;
  191. cout << "|O O|" << endl;
  192. cout << "|O O|" << endl;
  193. cout << " -----" << endl;
  194. }
<< moderator edit: added [code][/code] tags >>
Reputation Points: 45
Solved Threads: 0
Light Poster
Bleek is offline Offline
28 posts
since Mar 2004

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:
Previous Thread in C++ Forum Timeline: Dynamic array of object pointers segfaulting
Next Thread in C++ Forum Timeline: Patching/Reading Files: stdio or fstream?





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


Follow us on Twitter


© 2011 DaniWeb® LLC