Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,179 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,017 people online right now. Registration is fast and FREE... Join Now!




Problem with my RPG game

 
Reply to this topicStart new topic

Problem with my RPG game, This is probably something easy to fix but i have been at it for a whi

ilandra
3 Aug, 2007 - 10:06 PM
Post #1

New D.I.C Head
*

Joined: 3 Aug, 2007
Posts: 13


My Contributions
I have been playing an online MUD since 2002 and some of the things have gotten so that I don't like to be on alot anymore and I have decided that I needed to learn code so that I could make a game that my husband and I could play together.
I have been teaching myself through online tutorials and whatnot and have been doing basic coding for a couple of weeks. Things such as "Hello world" Type programs and thought that it might be fun to try and do a basic RPG game. Well I have found myself to have gotten stuck.
I can't get race or class to change from a single letter to the full word, here is the code:

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <time.h>
#include <stdlib.h>
#include <dos.h>
#include <mem.h>
#include <conio.h>
#include <ctime>
#include <windows.h>
#include <string>
using namespace std;
char PlayerName[20];
char PlayerInput;
char Class;
char Fighter; /* I am guessing I need to void this or something??? */
int main()
{
system("color 0A");
cout<<"______________________________________\n";
cout<<"| |\n";
cout<<"| NO NAME YET RPG |\n";
cout<<"|____________________________________|\n";
cout<<""Welcome to my first RPG game. I hope that you enjoy it.\n";
cout << "Perhaps I should explain to you a few things first.\n";
cout << "First off you need to have your capslock on for everything \n";
cout << "in this game as I do not know how to change that but I will \n";
cout << "be working on that as this game progresses. \n";
cout << "Secondly be patient not all areas may be working at the time \n";
cout << "but I will eventually have them up and running. Also I have not \n";
cout << "implimented anything for you to save your character with yet sad.gif \n";
cout << "Sorry for the inconvienience. So shall we get started? Y/N \n\n";
cin>>PlayerInput;
if(PlayerInput == 'N')
{
cout <<"Alright you have a nice day then.";
system ("pause");}
else
{
if(PlayerInput == 'Y')

cout <<"Please enter your name: ";
cin>>PlayerName;
cout <<"Great "<<PlayerName<<" now the first thing that we must do\n";
cout <<"is to decide what class you are going to be. To do that \n";
cout <<"please pick from one of the following: \n";
system ("color 03");
cout <<"__________________________________________________________"<<endl;
cout <<"| |"<<endl;
cout <<"| (F)ighter |"<<endl;
cout <<"| ®ogue |"<<endl;
cout <<"| (M)age |"<<endl;
cout <<"| ©leric |"<<endl;
cout <<"|________________________________________________________ |"<<endl;
cin>>Class;
if (Class == 'F')
{
cout<<PlayerName<<" you have chose to become a fighter.\n\n";
}
else
if (Class == 'R')
{
cout<<PlayerName<<" you have chose to become a rogue.\n\n";
}
else
if (Class == 'M')
{
cout<<PlayerName<<" you have chose to become a mage.\n\n";
}
else
if (Class == 'C')
{
cout<<PlayerName<<" you have chose to become a cleric.\n\n";
}
system("color 0A");
system("pause");
system("cls");
cout<<PlayerName<<""<<Class<<" we have now come to the time when you must"<<endl;
cout<<" choose which race you are. Your race will determine your stats."<<endl;

system ("pause");
system ("color 0A");
}

};




User is offlineProfile CardPM
+Quote Post

Trake
RE: Problem With My RPG Game
4 Aug, 2007 - 12:57 AM
Post #2

D.I.C Head
**

Joined: 29 Jun, 2007
Posts: 60


My Contributions
Hi, I'm pretty new at this too, but I would do something like add a string className, then change the code to:
CODE

if (Class == 'F')
{
className = fighter;
cout<<PlayerName<<" you have chose to become a fighter.\n\n";
}

User is offlineProfile CardPM
+Quote Post

PennyBoki
RE: Problem With My RPG Game
4 Aug, 2007 - 01:06 AM
Post #3

system("revolution");
Group Icon

Joined: 11 Dec, 2006
Posts: 2,009



Thanked: 5 times
Dream Kudos: 500
Expert In: Java,C++,C

My Contributions
Hi, well since this is c++ you can use the string type, I see you've tried a char array, but you'll find that with string things are much easier.
HERE is an example on how to use strings.
User is offlineProfile CardPM
+Quote Post

ilandra
RE: Problem With My RPG Game
4 Aug, 2007 - 01:10 AM
Post #4

New D.I.C Head
*

Joined: 3 Aug, 2007
Posts: 13


My Contributions
Thanks for the help guys. I knew it would be a simple fix I have just been looking at the same code for the past couple of days and I am sure everyone knows how that can be. Easily stuck. *shrug*
Thanks it is much appreciated

User is offlineProfile CardPM
+Quote Post

ilandra
RE: Problem With My RPG Game
4 Aug, 2007 - 08:34 AM
Post #5

New D.I.C Head
*

Joined: 3 Aug, 2007
Posts: 13


My Contributions
Okay so I put:
if (Class == 'F')
{
ClassName = Fighter;
cout<<PlayerName<<" you have chose to
become "<<ClassName<<".\n\n";
}

And I get this error which I don't want:
PlayerName you have chose to become a 0.

I still am not getting what I am doing wrong.....
User is offlineProfile CardPM
+Quote Post

PennyBoki
RE: Problem With My RPG Game
4 Aug, 2007 - 08:40 AM
Post #6

system("revolution");
Group Icon

Joined: 11 Dec, 2006
Posts: 2,009



Thanked: 5 times
Dream Kudos: 500
Expert In: Java,C++,C

My Contributions
QUOTE(ilandra @ 4 Aug, 2007 - 09:34 AM) *

Okay so I put:
if (Class == 'F')
{
ClassName = Fighter;
cout<<PlayerName<<" you have chose to
become "<<ClassName<<".\n\n";
}

And I get this error which I don't want:
PlayerName you have chose to become a 0.

I still am not getting what I am doing wrong.....


If ClassName is of type string then the value should be assigned like this:
ClassName = "Fighter";
User is offlineProfile CardPM
+Quote Post

ilandra
RE: Problem With My RPG Game
4 Aug, 2007 - 08:47 AM
Post #7

New D.I.C Head
*

Joined: 3 Aug, 2007
Posts: 13


My Contributions
QUOTE(PennyBoki @ 4 Aug, 2007 - 09:40 AM) *

QUOTE(ilandra @ 4 Aug, 2007 - 09:34 AM) *

Okay so I put:
if (Class == 'F')
{
ClassName = Fighter;
cout<<PlayerName<<" you have chose to
become "<<ClassName<<".\n\n";
}

And I get this error which I don't want:
PlayerName you have chose to become a 0.

I still am not getting what I am doing wrong.....


If ClassName is of type string then the value should be assigned like this:
ClassName = "Fighter";



Lol okay now I see what my problem was. Wow it is going to be a long process doing this I see now.
User is offlineProfile CardPM
+Quote Post

Pontus
RE: Problem With My RPG Game
5 Aug, 2007 - 12:23 AM
Post #8

Dreaming Coder / Coding Dreamer
Group Icon

Joined: 28 Dec, 2006
Posts: 529



Thanked: 2 times
Dream Kudos: 275
My Contributions
Replace this:
CODE

if (Class == 'F')
{
//the stuf
}

with this:
CODE

if (Class == 'F'||Class == 'f')//his will accept both capital letters and small letters
{
//the stuf
}

User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/2/08 01:07AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month