here''s my code:
#include <iostream>#include <conio.h>#include <stdlib.h>#include <string.h>using namespace std;inline int Cls(){ system("cls"); return 0;}inline int Locate(int x, int y){ return 0;}struct Character{ int maxmana, maxhp, strength, defence, magic, agility; int mana, hp; int experience, level; int damage; int damageestimate[2]; int location[3]; int equipped[7]; int inventory[10]; float battleinterval; char name[20]; char race[7]; char characterclass[15];}; Character player;Character enemy;int GameLoop(){ return 0;}char CharacterResults(){ char yn; bool done = false; do { Cls(); cout << "Name: " << player.name; cout << "\nRace: " << player.race; cout << "\nClass: " << player.characterclass; cout << "\n\nStrength: " << player.strength; cout << "\nDefence: " << player.defence; cout << "\nMagic: " << player.magic; cout << "\nAgility: " << player.agility; cout << "\n\nMaximum Mana: " << player.maxmana; cout << "\nMaximum HP: " << player.maxhp; cout << "\n\nBattle Interval: " << player.battleinterval; cout << "\n\nWould you like to keep these stats and continue?(y/n)"; cout << flush; yn = getch(); if (yn != ''y'' && yn != ''Y'' && yn != ''n'' && yn != ''N'') { cout << "\n\nNot a valid choice.\n\n"; cout << "Press any key to continue..."; cout << flush; getch(); } else done = true; } while (done == false); return yn;}int CharacterMenu(){ bool done; char result; char choice; do { Cls(); cout << "What is your name?\n"; cin.getline (player.name,21); do { done = true; Cls(); cout << "Please choose a race for your character:\n\n"; cout << "1. Human: A strong physical race, in offence and defence.\n\n"; cout << "2. Goblin: Another physical race, with a powerful attack, but little grasp of" << "\n magic.\n\n"; cout << "3. Elf: A less physical race, with its roots in magic.\n\n"; cout << "4. Faerie: A very agile race.\n\n"; cout << "5. Dragon: The most well-rounded of all races.\n\n"; cout << flush; choice = getch(); switch(choice) { case ''1'': strcpy(player.race,"Human\0"); player.strength = 30; player.defence = 30; player.magic = 10; player.agility = 15; break; case ''2'': strcpy(player.race,"Goblin\0"); player.strength = 40; player.defence = 30; player.magic = 5; player.agility = 10; break; case ''3'': strcpy(player.race,"Elf\0"); player.strength = 15; player.defence = 10; player.magic = 45; player.agility = 15; break; case ''4'': strcpy(player.race,"Faerie\0"); player.strength = 5; player.defence = 20; player.magic = 25; player.agility = 35; break; case ''5'': strcpy(player.race,"Dragon\0"); player.strength = 20; player.defence = 25; player.magic = 20; player.agility = 20; break; default: cout << "Not a valid choice.\n\n"; cout << "Press any key to continue..."; cout << flush; getch(); done = false; break; } } while (!done) ; do { done = true; Cls(); cout << "Please choose a class for your character:\n\n"; cout << "1. Blood Mage: A sorceror class with powerful but sometimes suicidal spells.\n\n"; cout << "2. Thief: A nimble class that attacks with agility, and steals various things.\n\n"; cout << "3. Elemental Mage: A sorceror class that can control the elements.\n\n"; cout << "4. Ninja: A strong and agile physical class that uses martial arts spells.\n\n"; cout << "5. Gladiator: Another strong physical class that uses close-range weapons.\n\n"; cout << "6. Warlord: An agile class that uses long-range weapons.\n\n"; cout << flush; choice = getch(); switch(choice) { case ''1'': strcpy(player.characterclass,"Blood Mage\0"); player.strength += 20; player.defence += 20; player.magic += 20; player.agility += 20; break; case ''2'': strcpy(player.characterclass,"Thief\0"); player.strength += 15; player.defence += 15; player.magic += 20; player.agility += 30; break; case ''3'': strcpy(player.characterclass,"Elemental Mage\0"); player.strength += 10; player.defence += 15; player.magic += 35; player.agility += 20; break; case ''4'': strcpy(player.characterclass,"Ninja\0"); player.strength += 30; player.defence += 10; player.magic += 15; player.agility += 25; break; case ''5'': strcpy(player.characterclass,"Gladiator\0"); player.strength += 30; player.defence += 30; player.magic += 10; player.agility += 10; break; case ''6'': strcpy(player.characterclass,"Warlord\0"); player.strength += 20; player.defence += 20; player.magic += 10; player.agility += 30; break; default: cout << "Not a valid choice.\n\n"; cout << "Press any key to continue..."; cout << flush; getch(); done = false; break; } } while (!done); player.level = 0; player.experience = 0; player.maxmana = 2 * player.magic; player.mana = player.maxmana; player.maxhp = 2 * player.defence; player.hp = player.maxhp; player.battleinterval = 1000.0f / (float)player.agility; result = CharacterResults(); if (result == ''n'' || result == ''N'') { Cls(); cout << "You may now choose again, press any key..."; cout << flush; getch(); done = false; } } while (!done); return 0;}int Story(){ Cls(); cout << "Story:\n\n" << "Welcome to the land of Relourin, young warrior. You have been selected by the\n" << "King himself for this mission.\n\n" << "This land is in grave danger. Something has emerged into the depths of the\n" << "Great Volcano. Many strange things have been happening. Strange unfriendly\n" << "creatures have been roaming the countryside, looking for a fight. The local\n" << "villages have been sabotaged. There are far too many of them for us to ward\n" << "off without you. You are our only hope.\n\n" << "Leave with haste, and rid this land of evil before it''s too late.\n\n" << "Press any key to continue..."; cout << flush; getch(); CharacterMenu(); GameLoop(); Cls(); return 0;}int main(){ char choice; bool done; do { done = true; Cls(); cout << "RPG\n\n" << "What would you like to do?\n\n"; cout << "1. New Game\n" << "2. Resume Game\n" << "3. Exit\n\n"; cout << flush; choice = getch(); switch(choice) { case ''1'': Story(); break; case ''2'': Cls(); cout << "Not yet available\n\n"; cout << "Press any key to reset..."; cout << flush; getch(); done = false; break; case ''3'': Cls(); break; default: cout << "Not a valid choice.\n\n"; cout << "Press any key to continue..."; cout << flush; getch(); done = false; break; } } while (!done); cout << "Press any key to exit..." << flush; getch(); return 0;}
If I don''t use /0, whenever the user chooses a long Character Class and Race, in CharacterResults(), the Race line displays the race and class all stuck together, try it out. How do I remove /0 and make it not do this?
Also, how do I use SetConsoleCursorPosition?
I replaced iostream.h with just iostream. Can I do this for all my headers? If so, how?
Lastly, how can I make the user move around. Should I use an int[3] to represent level, x and y?
Please help me!