Κυριακή 9 Οκτωβρίου 2011

C++ Simple RPGame - New Game & Exit



These are the latest changes in the game, I added a New Game function, now you can choose to create a new player, the program will ask for your character's name and it will create a file which contains all the information about your player (level, hp, mp, gold, etc).

Source Code:

#include <iostream>
#include <cstdlib>
#include <fstream>
using namespace std;
void new_game(char name[40]);

int main()
{
cout << "\t \t Welcome to My-Game!" << endl;
cout << "\t Please choose one of the options below: " << endl;
cout << "\t 1)New Game " << endl;
cout << "\t 2)Load Game " << endl;
cout << "\t 0)Exit " << endl << endl;
cout << "Choice: ";
int answer=0;
cin >> answer;

if (answer == 1)
{
system("cls");
cout << "\t Please Type in your character's Name (Max. 40 chars)" <> name;
new_game(name);
}
else if (answer == 0)
{
return 0;
}

return 0;
}

void new_game(char name[40])
{
ofstream file;
file.open(name);
file << "1 1 100 100 250 1"; //r potions,blue potions,hp,mp,gold,lvl
file.close();
return;
}


Δεν υπάρχουν σχόλια:

Δημοσίευση σχολίου