Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 4th, 2008, 4:02 PM   #11
Arnack
Programmer
 
Join Date: Jul 2005
Posts: 66
Rep Power: 3 Arnack is on a distinguished road
Re: Simple if statement question :(

Hey, cool! Thanks a lot, that was very helpful. I couldn't help but catch the "bool" an and then the variable bCont after it.
What exactly is bool? I thought I would use "string" for that, simply because I was holding text characters in it.

I'm also creating a small text based role playing game in C++ as for a a bit of practice. Will it be a problem posting the source in this thread as well?
__________________
Ack Network
*UNDER CONSTRUCTION*
Now hiring staff of all sorts.
Arnack is offline   Reply With Quote
Old May 4th, 2008, 4:52 PM   #12
Arnack
Programmer
 
Join Date: Jul 2005
Posts: 66
Rep Power: 3 Arnack is on a distinguished road
Re: Simple if statement question :(

C++ Syntax (Toggle Plain Text)
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4. #include <iostream>
  5. #include <cctype>
  6. #include <windows.h>
  7. //"Mage Wars" copyright Crimson Games 2007. All rights reserved.
  8. //Created by Arnack, distributing this source is permited, as long
  9. //as ownership is shown.
  10.  
  11. using namespace std;
  12. int always = 1;
  13. int gold = 10;
  14. int level = 1;
  15. int health = 10;
  16. string city;
  17. int check = 1;
  18. string area;
  19.  
  20. void stats()
  21. {
  22. cout << "|------------------------------|\n";
  23. cout << "| ~STATS BAR~ |\n";
  24. cout << "|------------------------------|\n";
  25. cout << " You are level " << level << "! \n";
  26. cout << " You have " << gold << " gold!\n";
  27. cout << " Current Area: " << area<< " \n";
  28. cout << " Current City: " << city <<"\n";
  29. cout << "|------------------------------|\n\n";
  30. }
  31.  
  32.  
  33.  
  34.  
  35. void start()
  36. {
  37.  
  38. city = "Paradon";
  39.  
  40. cout << "\nHello, and welcome to the world of Coloren. ";
  41. cout << "This land is ruled by evil, twisted creatures coined \"Lethars\". \n";
  42. cout << "They have corrupted the world with their evil. The land screams of an hero, and I have selected you. \n";
  43. cout << "Good luck, stranger.\n\n";
  44. system("PAUSE");
  45. check = 2;
  46. }
  47. void maingame()
  48. {
  49. system("CLS");
  50. void stats();
  51. city = "Paradon";
  52. area = "Outside StoneKeg Inn";
  53.  
  54. cout << "Elder Herald: \"There are many things to do before you will become recognized.";
  55. cout << "You may buy and sell items at the town shoppe. Also, you can go out in the wilderness and fight enemies.";
  56. cout << "Come see me when you are level 5 or higher.\"" << endl;
  57. system("PAUSE");
  58.  
  59. }
  60.  
  61.  
  62. int main()
  63. {
  64. while (always == 1)
  65. {
  66. system("CLS");
  67. stats();
  68. if (check == 1)
  69. {
  70. start();
  71. }
  72. else
  73. {
  74. maingame();
  75.  
  76. }
  77.  
  78. }}
My problem is that after I get past the first void and go onto the second void, the stats void does not even come up.
__________________
Ack Network
*UNDER CONSTRUCTION*
Now hiring staff of all sorts.
Arnack is offline   Reply With Quote
Old May 4th, 2008, 9:31 PM   #13
peaceofpi
hi: for(;;) goto hi;
 
peaceofpi's Avatar
 
Join Date: Jun 2006
Posts: 83
Rep Power: 2 peaceofpi is on a distinguished road
Send a message via AIM to peaceofpi Send a message via MSN to peaceofpi
Re: Simple if statement question :(

Quote:
Originally Posted by Arnack View Post
Hey, cool! Thanks a lot, that was very helpful. I couldn't help but catch the "bool" an and then the variable bCont after it.
What exactly is bool? I thought I would use "string" for that, simply because I was holding text characters in it.

I'm also creating a small text based role playing game in C++ as for a a bit of practice. Will it be a problem posting the source in this thread as well?
bool is short for the boolean type which holds either a true or false value. bCont is always true unless the user fails to enter "Y" (or "y") in which case the loop stops.

As for the function problem: in maingame() you've put stats() in as a prototype and not a regular call. Take out the void part and it'll work. I love abusing this icode tag.

I highly recommend you tackle some more learning materials for C++ before starting something like an RPG. Since this is C++, I'll tell you now before someone else does that you probably want to learn about classes. Also you should consider a code-oriented text editor; your wacky spacing (no offense) will probably become the source of some issues that are hard to solve.
__________________
How do you play Religious Roulette?
Stand around in a circle and blaspheme till someone gets struck by lightning.
peaceofpi is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
very simple question. make button change number in edit box nickm Delphi 2 Apr 29th, 2006 10:47 PM
A simple programming question punter C# 8 Jan 5th, 2006 4:04 PM
A simple question Master C++ 9 Dec 24th, 2005 2:20 PM
Simple c# question nez C# 8 Jul 1st, 2005 6:29 PM
Simple (stupid cause I don't know it) basic question massive-war C++ 17 Apr 11th, 2005 11:03 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:29 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC