Game Programming



Visit Base Classics - Gaming Chairs

 
game programming
Game Programming :: Programming :: General Programming :: Code Examples :: [C++]Unreal Text Based RPG source code - View Topic
Topic Rating: *****
Printable View
Andy
Administrator
*****

Posts: 40
Status: Offline
Gender: Male
Joined:  
pm

Reputation: 0%

[C++]Unreal Text Based RPG source code (11th Jan 08 at 1:47am UTC)
Here is the source code to a text based MSDOS game i was making called Unreal the souce code will complie and run you are free to do what you want with it this code base is very old and has a lot of old programming habbits

Code:
 
  1. /*
  2. Disclaimer of Warranty.
  3.  
  4. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
  5. APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
  6. HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
  7. OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
  8. THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  9. PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
  10. IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
  11. ALL NECESSARY SERVICING, REPAIR OR CORRECTION
  12. */
  13.  
  14. /*
  15. Limitation of Liability.
  16.  
  17. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
  18. WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
  19. THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
  20. GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
  21. USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
  22. DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
  23. PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
  24. EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
  25. SUCH DAMAGES.
  26. */
  27.  
  28. /*
  29. (Unreal) Copyright (C) <2007> <Andrew aka Andy>
  30. This program comes with ABSOLUTELY NO WARRANTY;
  31. This is free software, and you are welcome to redistribute it
  32. under certain conditions of the GNU
  33. */
  34.  
  35. /*
  36. incldue the iostream header file to be able to use
  37. cout and cin cout meaning console out and cin
  38. mening consloe in
  39. */
  40. #include <iostream>
  41.  
  42. /*
  43. include the string header file to be able to use the
  44. string types
  45. */
  46. #include <string>
  47.  
  48. /*
  49. include the ctime header file to be able to use
  50. for the time in game
  51. */
  52. #include <ctime>
  53.  
  54. /*
  55. include the cstdlib header file to be bale to use
  56. rand() and srand() functions
  57. */
  58. #include <cstdlib>
  59.  
  60. /*
  61. Main_Menu_LayOut();
  62. functions
  63. accepts no arguements
  64. and returns no values
  65. */
  66. void Main_Menu_LayOut();
  67.  
  68.  
  69. /*
  70. Purchase_Weapon_Menu();
  71. takes no arguments and
  72. returns no values
  73. */
  74. void Purchase_Weapon_Menu();
  75.  
  76. /*
  77. Purchase_Weapon_Menu();
  78. takes no arguments and
  79. returns no values
  80. */
  81. void Purchase_Weapon_List();
  82.  
  83.  
  84. /*
  85. Purchase_Aror_List();
  86. takes no arguments and
  87. returns no values
  88. */
  89. void Purchase_Armor_List();
  90.  
  91. /*
  92. Purchase_Armour();
  93. function
  94. accetps no arguments
  95. and returns no values
  96. */
  97. void Purchase_Armor_Menu();
  98.  
  99. /*
  100. define function
  101. purchase weapon
  102. used to store list
  103. of avliables items
  104. */
  105. void Purchase_Weapon_Menu()
  106. {
  107. char f;
  108.  
  109. std::cout << "===============n";
  110. std::cout << "Purchase Weaponn";
  111. std::cout << "===============n";
  112. std::cout << "COMING SOON nn";
  113.  
  114. std::cout << "Please Press [R] to return to main menu screen n";
  115.  
  116. std::cin >> f;
  117.  
  118. system("cls");
  119.  
  120. switch (f)
  121. {
  122. case 'r':
  123. case 'R':
  124. Main_Menu_LayOut();
  125. break;
  126.  
  127. }
  128.  
  129.  
  130.  
  131. }
  132.  
  133. /*
  134. define function
  135. Purchase_Armor_List
  136. used to store the
  137. information for the
  138. list of Armor
  139. */
  140. void Purchase_Armor_List()
  141. {
  142. char d;
  143.  
  144. std::cout << "Unarmored AC: +0 Max Dex: INFn";
  145. std::cout << "Padded Armor AC: +1 Max Dex: +8 5gn";
  146. std::cout << "Leather Armor AC: +2 Max Dex: +6 10gn";
  147. std::cout << "Hide Armor AC: +3 Max Dex: +4 15gn";
  148. std::cout << "Studded Leather AC: +3 Max Dex: +5 25gnn";
  149.  
  150. std::cout << "More Items To be Added Soon nn";
  151.  
  152. std::cout << "Press [R] to return to the main menu screen: n";
  153.  
  154. std::cin >> d;
  155.  
  156. system ("cls");
  157.  
  158. switch (d)
  159. {
  160. case 'r':
  161. case 'R':
  162. Main_Menu_LayOut();
  163. break;
  164.  
  165. }
  166.  
  167.  
  168.  
  169.  
  170.  
  171. }
  172.  
  173. /*
  174. define function
  175. purchase armor
  176. used to store list
  177. of avliables items
  178. */
  179. void Purchase_Armor_Menu()
  180. {
  181. std::cout << "============== n";
  182. std::cout << "Purchase Armor n";
  183. std::cout << "============== n";
  184. /*
  185. call function armor list
  186. to display the list of
  187. armor avliable
  188. */
  189. Purchase_Armor_List();
  190.  
  191. }//end of purchase_armor function
  192.  
  193. /*
  194. P_Equip();
  195. functions
  196. accepts no arguements
  197. and returns no values
  198. */
  199. void Purchase_Equipment();
  200.  
  201. /*
  202. defining function
  203. P_Equip();
  204. system use to by
  205. stuff in game
  206. */
  207. void Purchase_Equipment()
  208. {
  209. /*
  210. used for user
  211. input for when
  212. selection from the
  213. menu using the variable
  214. for input (c)
  215. */
  216. char c;
  217.  
  218. std::cout << "========================== n";
  219. std::cout << " Purchase Equipment n";
  220. std::cout << "========================== n";
  221. std::cout << "a. Purchase Armor n";
  222. std::cout << "b. Purchase Weapon n";
  223. std::cout << "R. Return to previous menu n";
  224. std::cout << "========================== n";
  225.  
  226. //take input from user
  227. //user (c) input variable
  228. std::cin >> c;
  229.  
  230. //clears screen
  231. system ("cls");
  232.  
  233. /*
  234. switch statment
  235. to take input given
  236. and will return a
  237. value based upon
  238. the user input
  239. */
  240. switch (c)
  241. {
  242. case 'a':
  243. case 'A':
  244. Purchase_Armor_Menu();
  245. break;
  246. case 'b':
  247. case 'B':
  248. Purchase_Weapon_Menu();
  249. break;
  250. case 'r':
  251. case 'R':
  252. Main_Menu_LayOut();
  253. break;
  254.  
  255. }//end of switch
  256.  
  257. }
  258.  
  259. /*
  260. Create_Character();
  261. function
  262. accetps no arguments
  263. and returns no values
  264. */
  265. void Create_Character();
  266.  
  267. /*
  268. Create_Character_Menu();
  269. function
  270. accetps no arguments
  271. and returns no values
  272. */
  273. void Create_Character_Menu();
  274.  
  275.  
  276. /*
  277. defining function
  278. Create_Chracter();
  279. system use to name
  280. your character for
  281. the game
  282. */
  283. void Create_Character()
  284. {
  285. /*
  286. Store the name of
  287. the users character in
  288. a string variable
  289. */
  290. std::string name;
  291.  
  292. char e;
  293.  
  294. std::cout << "================================ n";
  295. std::cout << " Create Your Characters Name n";
  296. std::cout << "================================ n";
  297.  
  298. //prompt user to enter there character name
  299. std::cout << "Please enter your character name: ";
  300.  
  301. //take user input/characters name
  302. std::cin >> name;
  303.  
  304. /*
  305. make new line
  306. to addjust formatting
  307. */
  308. std::cout << "n";
  309.  
  310. //once characters name has been entered print name back to user
  311. std::cout << "Your character name is " << name << "nn";
  312.  
  313. std::cout << "Please Press [R] to return to the main menu screen: n";
  314.  
  315. std::cin >> e;
  316.  
  317. system ("cls");
  318.  
  319. std::cout << "================================ n";
  320.  
  321. switch (e)
  322. {
  323. case 'r':
  324. case 'R':
  325. Main_Menu_LayOut();
  326. break;
  327. }
  328.  
  329.  
  330.  
  331.  
  332. }//end of Create_Character(); function
  333.  
  334.  
  335. /*
  336. Defiening function
  337. Create_Character_Menu();
  338. displays the Main Menu
  339. to the user
  340. */
  341. void Create_Character_Menu()
  342. {
  343.  
  344. /*
  345. use for user input for
  346. the Create Character menu
  347. as defined
  348. by a character variable
  349. */
  350. char b;
  351.  
  352. std::cout << "========================== n";
  353. std::cout << " Create Character n";
  354. std::cout << "========================== n";
  355. std::cout << "a. Name Character n";
  356. std::cout << "b. Roll for Stats n";
  357. std::cout << "R. Return to previous menu n";
  358. std::cout << "========================== n";
  359.  
  360. /*
  361. Take input
  362. from the user
  363. using the character
  364. variable (b)
  365. */
  366. std::cin >> b;
  367.  
  368. /*
  369. clear screen and
  370. load up the relevent
  371. screen from the user
  372. input
  373. */
  374. system("cls");
  375.  
  376. /*
  377. switch statment
  378. to take input given
  379. and will return a
  380. value based upon
  381. the user input
  382. */
  383. switch(b)
  384. {
  385. case 'a':
  386. case 'A':
  387. Create_Character();
  388. break;
  389. case 'b':
  390. case 'B':
  391. break;
  392. case 'r':
  393. case 'R':
  394. Main_Menu_LayOut();
  395. break;
  396.  
  397. }//end of switch statement
  398.  
  399.  
  400.  
  401.  
  402. }//end of Create_Character_Menu(); function
  403.  
  404.  
  405.  
  406. /*
  407. Defiening function
  408. Main_Menu_LayOut();
  409. displays the Main Menu
  410. to the user
  411. */
  412. void Main_Menu_LayOut()
  413. {
  414. /*
  415. use for user input for
  416. the main menue
  417. as defined
  418. by a character variable
  419. */
  420. char a;
  421.  
  422. std::cout << "======================== n";
  423. std::cout << " UNREAL RPG n";
  424. std::cout << "======================== n";
  425. std::cout << "a.Create Character n";
  426. std::cout << "b.Enter World n";
  427. std::cout << "c.View Stats n";
  428. std::cout << "d.Purchase Equipment n";
  429. std::cout << "Q.Quit n";
  430. std::cout << "======================== n";
  431.  
  432. /*
  433. Take input for the
  434. user using the
  435. character
  436. variable (a)
  437. */
  438. std::cin >> a;
  439.  
  440. /*
  441. clear screen and
  442. load up the relevent
  443. screen from the user
  444. input
  445. */
  446. system("cls");
  447.  
  448. /*
  449. switch statment
  450. to take input given
  451. by the user
  452. and will return a
  453. value based upon
  454. the user input
  455. */
  456. switch(a)
  457. {
  458. case 'a':
  459. case 'A':
  460. Create_Character_Menu();
  461. break;
  462. case 'b':
  463. case 'B':
  464. break;
  465. case 'c':
  466. case 'C':
  467. break;
  468. case 'd':
  469. case 'D':
  470. Purchase_Equipment();
  471. break;
  472. case 'q':
  473. case 'Q':
  474. exit(0);
  475. break;
  476.  
  477. }//end of switch statment for character variable (a)
  478.  
  479. }//end of Main_Menu_LayOut(); function
  480.  
  481. /*
  482. start of the main()
  483. fucntion here
  484. */
  485. int main()
  486. {
  487. /*
  488. call Main_Menu_LayOut();
  489. fucntion
  490. */
  491. Main_Menu_LayOut();
  492.  
  493. //pause application
  494. std::cin.get();
  495.  
  496. //discard buffer overflow
  497. std::cin.ignore(100, 'n');
  498.  
  499. /*
  500. return 0 to indicate no
  501. probelms found
  502. if problems found
  503. do not complie
  504. */
  505. return 0;
  506.  
  507.  
  508. }//end of main
  509.  
  510.  
 


Enjoy
 Printable View

All times are GMT+0 :: The current time is 9:12pm
Page generated in 0.7414 seconds
Purchase Ad-Free Credits
This Forum is Powered By vForums (v2.4)
Create a Forum for Free | Find Forums