PDA

View Full Version : Starting up a game.


Maulth
10-02-2008, 12:02 AM
Don't get too excited and blow a load because it's going to be console only, Command Prompt. I've only got the very beginning's of the code worked out, but I should have it completed, or at least playable, in the next couple of weeks. If you're looking for a game with graphics, go away, this is going to be the ultimate shitty msdos game. Remember pong? Yeah, there we go. Basically I'm making an RPG just to prove to myself I can do it before I move onto windows native graphics library and totally fuck up my brain by doing that, anyway, here is the code, i'll upload a .exe of it in a few weeks as it becomes more complete.

#include <cstdlib>
#include <apstring.h>
#include <apstring.cpp>
#include <iostream>
#include <stdlib.h>
#include <windows.h>
//How am I going to do experience?
//Beginning game flow Menu, load, new, exit. If you pick new, choose name, then race and class. Then taken to
//introduction function that will take you through a tutorial battle.
//Idea for inventory. Only have 6 items in the inventory, Head, Chest, Boots, Weapon, ring, and amulet. (Dual weapons if needed)
//Character can discover items from bosses, or purchase them from merchants.
void Merchant(int level, int money, apstring ClassName);
//to-do: Need to create money system, game world, events, quests, class specifics, race specifics.
void CalculateDmg( int damage, int armor, char type, int resistance);
void CreateCharacter();
void BeginGame();
void Introduction(apstring CharName, int race);
void MainScreen(apstring CharName, int Money, apstring race, int health, int mana, apstring ClassName, int level, int money);//Main screen, need to figure out how to refresh screen, maybe a for loop, or do-while?
void MainScreenUpdate(int money, int health, int mana, int level);
//void BossBattle();
//void RandomEvent();
void CharacterDeath(apstring CharName, apstring ClassName, int level);
//void inventory();
void CreateWarrior(apstring CharName, apstring race);
void CreateEngineer(apstring CharName, apstring race);
void CreateMage(apstring CharName, apstring race);
void CreateAssassin(apstring CharName, apstring race);
void CreateMonk(apstring CharName, apstring race);
void CreateRanger(apstring CharName, apstring race);
void levelup(int level, apstring CharName);
//Void SaveGame(apstring CharName, int money, int agility, int intelligence, int strength, int armor, apstring race, apstring class);
int main()
{
//Title Screen
int choice, titlePrevent=2;
do{
cout<<"Version 1.0 written by Trevor Hallgrimson, A.K.A. Maulth"<<endl;
cout<<endl<<endl<<endl<<endl<<endl;
cout<<" __ _ __ __ ____ ___ ______ __ __ ___ _____"<<endl;
cout<<"| l/ ]| T T / T| T | T| T T / \ / ___/"<<endl;
cout<<"| ' / | l |Y o || | | || l |Y Y( \_ "<<endl;
cout<<"| \ | _ || || l___ l_j l_j| _ || O | \__ T"<<endl;
cout<<"| Y| | || _ || T | | | | || | / \ |"<<endl;
cout<<"| . || | || | || | | | | | |l ! \ |"<<endl;
cout<<"l__j\_jl__j__jl__j__jl_____j l__j l__j__j \___/ \___j"<<endl;


cout<<endl<<endl;
cout<<"(1) New Game "<<endl;
cout<<"(2) Continue "<<endl;
cout<<"(3) Exit "<<endl;
cout<<endl<<endl;
cout<<"Enter Choice: ";
cin>>choice;

if(choice==1)
{
CreateCharacter();
}

else if(choice==2)
{
//ContinueGame(savefilename);
cout<<"This option is currently unavailable in this game version."<<endl;
}

else if(choice==3)
{
return(0);
}

else
{
cout<<"Incorrect choice entered, please try again!"<<endl;
titlePrevent=2;
}
}while(titlePrevent!=2);
return(0);

}


void CreateCharacter()
{
apstring race;
int RacePrevent=1;/*Prevents from exiting Race pick loop unless correct race specified*/
apstring ClassName; int ClassPrevent=1;/*Prevents from exiting Class Pick loop unless correct class specified*/
apstring CharName;
cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
cout<<"Welcome Hero, to the world of Khalthos!"<<endl;
cout<<endl<<endl;
cout<<"Please enter a name for your character: ";
cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
cin>>CharName;
cout<<endl<<endl;
cout<<"Please choose a race!"<<endl;
cout<<endl<<endl<<endl<<endl;
cout<<"You may choose from the following: "<<endl;
cout<<"Elf, Dwarf, Human "<<endl;
cout<<endl;
cout<<"Please enter the name of the race you would like: ";
cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
cin>>race;
cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
do
{
if(race=="Elf")
{
cout<<"You have chosen the elf"<<endl;
RacePrevent=2;
cout<<endl;
}
else if(race=="Dwarf")
{
cout<<"You have chosen the Dwarf"<<endl;
RacePrevent=2;
cout<<endl;
}
else if(race=="Human")
{
cout<<"you have chosen the Human"<<endl;
RacePrevent=2;
cout<<endl;
}
else
cout<<"You did not pick any valid race, please try again!"<<endl;
}
while(RacePrevent!=2);
cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
cout<<"In the world of Khalthos there are many types of adventurers, choose yours"<<endl;
cout<<endl<<endl;
cout<<"Ranger, Warrior, Mage, Assassin, Monk, Engineer "<<endl;
cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
cout<<"Please enter the name of the class as it appears above: ";
cin>>ClassName;
do
{
if(ClassName=="Ranger")
{
cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
cout<<"You have chosen the path of the Ranger! May your arrow fly true!"<<endl;
ClassPrevent=2;
cout<<endl<<endl;
CreateRanger(CharName, race);
}

else if(ClassName=="Warrior")
{
cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
cout<<"You have chosen the way of the Warrior! May your blade stay sharp!"<<endl;
ClassPrevent=2;
cout<<endl<<endl;
CreateWarrior(CharName, race);
}

else if(ClassName=="Mage")
{
cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
cout<<"You have chosen the life of the wizard. May your knowledge prevail!"<<endl;
ClassPrevent=2;
cout<<endl<<endl;
CreateMage(CharName, race);
}

else if(ClassName=="Assassin")
{
cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
cout<<"You have chosen the assassins path. May the shadows hide you"<<endl;
ClassPrevent=2;
cout<<endl<<endl;
CreateAssassin(CharName, race);
}
else if(ClassName=="Monk")
{
cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
cout<<"You have chosen the Monk. May your fortitude guide you!"<<endl;
ClassPrevent=2;
cout<<endl<<endl;
CreateAssassin(CharName, race);
}

else if(ClassName=="Engineer")
{
cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
cout<<"You have chosen the path of the engineer. May your craft prove you."<<endl;
ClassPrevent=2;
cout<<endl<<endl;
CreateEngineer(CharName, race);
}

else
cout<<"You have chosen an invalid class. Please choose again."<<endl;

}
while(ClassPrevent!=2);

}
void CreateWarrior(apstring CharName, apstring race)
{
int strength, intelligence, agility, defence, health, mana, level;
strength=25;
intelligence=10;
agility=15;
health=(double)strength*1.75;
mana=(double)intelligence*3.25;
//For defence somehow incorporate the users currently worn armor into defence calculation.
defence=(double)agility*8.35/*+armor*/;
cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
level=1;
cout<<"Creating warrior.";
//insert wait function
cout<<".";
//insert wait function
cout<<".";
//insert wait function
cout<<endl<<endl;
system("Pause");//"Press any key to continue..."
cout<<"."<<endl<<endl<<endl<<endl;
cout<<"Warrior Name: "<<CharName<<endl<<endl;
cout<<"Warrior Stats: "<<endl;
cout<<"Strength: "<<strength<<endl;
cout<<"Intelligence: "<<intelligence<<endl;
cout<<"Agility: "<<agility<<endl;
cout<<"Health: "<<health<<endl;
cout<<"Mana: "<<mana<<endl;
cout<<endl<<endl;
system("Pause");
cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
cout<<"Warrior created sucessfully!"/*"Would you like to save? (Yes/No): "*/;
}

void CreateAssassin(apstring CharName, apstring race)//agility dictates attack
{
int strength, intelligence, agility, defence, health, mana, level;
strength=15;
intelligence=15;
agility=25;
health=(double)strength*1.75;
mana=(double)intelligence*3.25;
//For defence somehow incorporate the users currently worn armor into defence calculation.
defence=(double)agility*8.35/*+armor*/;
cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
level=1;
cout<<"Creating Assassin.";
//insert wait function
cout<<".";
//insert wait function
cout<<".";
//insert wait function
cout<<endl<<endl;
system("Pause");//"Press any key to continue..."
cout<<"."<<endl<<endl<<endl<<endl;
cout<<"Assassin Name: "<<CharName<<endl<<endl;
cout<<"Assassin Stats: "<<endl;
cout<<"Strength: "<<strength<<endl;
cout<<"Intelligence: "<<intelligence<<endl;
cout<<"Agility: "<<agility<<endl;
cout<<"Health: "<<health<<endl;
cout<<"Mana: "<<mana<<endl;
cout<<endl<<endl;
system("Pause");
cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
cout<<"Assassin created sucessfully!"/*"Would you like to save? (Yes/No): "*/;
}


void CreateEngineer(apstring CharName, apstring race)
{
int strength, intelligence, agility, defence, health, mana, level;
strength=20;
intelligence=15;
agility=15;
health=(double)strength*1.75;
mana=(double)intelligence*3.25;
//For defence somehow incorporate the users currently worn armor into defence calculation.
defence=(double)agility*8.35/*+armor*/;
cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
level=1;
cout<<"Creating warrior.";
//insert wait function
cout<<".";
//insert wait function
cout<<".";
//insert wait function
cout<<endl<<endl;
system("Pause");//"Press any key to continue..."
cout<<"."<<endl<<endl<<endl<<endl;
cout<<"Engineer Name: "<<CharName<<endl<<endl;
cout<<"Engineer Stats: "<<endl;
cout<<"Strength: "<<strength<<endl;
cout<<"Intelligence: "<<intelligence<<endl;
cout<<"Agility: "<<agility<<endl;
cout<<"Health: "<<health<<endl;
cout<<"Mana: "<<mana<<endl;
cout<<endl<<endl;
system("Pause");
cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
cout<<"Engineer created sucessfully!"/*"Would you like to save? (Yes/No): "*/;
}


void CreateMage(apstring CharName, apstring race)
{
int strength, intelligence, agility, defence, health, mana, level;
strength=10;
intelligence=25;
agility=15;
health=(double)strength*1.75;
mana=(double)intelligence*3.25;
//For defence somehow incorporate the users currently worn armor into defence calculation.
defence=(double)agility*8.35/*+armor*/;
cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
level=1;
cout<<"Creating Mage.";
//insert wait function
cout<<".";
//insert wait function
cout<<".";
//insert wait function
cout<<endl<<endl;
system("Pause");//"Press any key to continue..."
cout<<"."<<endl<<endl<<endl<<endl;
cout<<"Mage Name: "<<CharName<<endl<<endl;
cout<<"Mage Stats: "<<endl;
cout<<"Strength: "<<strength<<endl;
cout<<"Intelligence: "<<intelligence<<endl;
cout<<"Agility: "<<agility<<endl;
cout<<"Health: "<<health<<endl;
cout<<"Mana: "<<mana<<endl;
cout<<endl<<endl;
system("Pause");
cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
cout<<"Mage created sucessfully!"/*"Would you like to save? (Yes/No): "*/;
}


void CreateMonk(apstring CharName, apstring race)
{
int strength, intelligence, agility, defence, health, mana, level;
strength=20;
intelligence=20;
agility=20;
health=(double)strength*1.75;
mana=(double)intelligence*3.25;
//For defence somehow incorporate the users currently worn armor into defence calculation.
defence=(double)agility*8.35/*+armor*/;
cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
level=1;
cout<<"Creating Monk.";
//insert wait function
cout<<".";
//insert wait function
cout<<".";
//insert wait function
cout<<endl<<endl;
system("Pause");//"Press any key to continue..."
cout<<"."<<endl<<endl<<endl<<endl;
cout<<"Monk Name: "<<CharName<<endl<<endl;
cout<<"Monk Stats: "<<endl;
cout<<"Strength: "<<strength<<endl;
cout<<"Intelligence: "<<intelligence<<endl;
cout<<"Agility: "<<agility<<endl;
cout<<"Health: "<<health<<endl;
cout<<"Mana: "<<mana<<endl;
cout<<endl<<endl;
system("Pause");
cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
cout<<"Monk created sucessfully!"/*"Would you like to save? (Yes/No): "*/;
}


void CreateRanger(apstring CharName, apstring race)
{
int strength, intelligence, agility, defence, health, mana, level;
strength=25;
intelligence=10;
agility=15;
health=(double)strength*1.75;
mana=(double)intelligence*3.25;
//For defence somehow incorporate the users currently worn armor into defence calculation.
defence=(double)agility*8.35/*+armor*/;
cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
level=1;
cout<<"Creating Ranger.";
//insert wait function
cout<<".";
//insert wait function
cout<<".";
//insert wait function
cout<<endl<<endl;
system("Pause");//"Press any key to continue..."
cout<<"."<<endl<<endl<<endl<<endl;
cout<<"Ranger Stats: "<<CharName<<endl<<endl;
cout<<"Ranger Stats: "<<endl;
cout<<"Strength: "<<strength<<endl;
cout<<"Intelligence: "<<intelligence<<endl;
cout<<"Agility: "<<agility<<endl;
cout<<"Health: "<<health<<endl;
cout<<"Mana: "<<mana<<endl;
cout<<endl<<endl;
system("Pause");//"Press any key to continue..."
cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
cout<<"Ranger created sucessfully!"/*"Would you like to save? (Yes/No): "*/;
}

void levelup(int level, apstring CharName)
{
level++;
cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
cout<<CharName<<" has reached level "<<level<<endl;

}

void MainScreen(apstring CharName, apstring race, int health, int mana, apstring ClassName, int level, int money)
{
cout<<endl<<endl<<cout<<endl<<endl<<cout<<endl<<endl<<cout<<endl<<endl<<cout<<endl<<endl<<cout<<endl<<endl<<endl;
cout<<" _________________________ "<<endl;
cout<<" | Name: "<<CharName<<" |"<<endl;
cout<<" | Class: "<<ClassName<<" |"<<endl;
cout<<" | Health: "<<health<<" |"<<endl;
cout<<" | Mana: "<<mana<<" |"<<endl;
cout<<" | Money: "<<money<<" |"<<endl;
cout<<" | Level: "<<level<<" |"<<endl;
cout<<" ---------------------------"<<endl;
//MainScreenUpdate(int money, int health, int mana, int level);
}
void CharacterDeath(apstring CharName, apstring ClassName, int level)
{
cout<<CharName<<" the level "<<level<<" "<<ClassName<<" has died."<<endl;
cout<<"The game will now exit, hopefully you saved recently."<<endl;
system("Pause");
system("Exit");
}

void MainScreenUpdate(int money, int health, int mana, int level)
{
//what the fuck, how am i going to update this?
}

void Merchant(int level, int money, apstring ClassName)
{
apstring choice;
/*
srand((0));
int rand;
do random numbers to decide what merchant will say, so it doesn't get repetitive.*/
cout<<"Welcome to Maybal's Gear Emporium. What would you like to purchase?"<<endl;
cout<<endl<<endl<<endl<<endl;
cout<<"Buy"<<endl;
cout<<"Sell"<<endl;
cout<<"Exit"<<endl;
cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
}


By the way, it's in C++. Last updated on October 6th.

Jeggo
10-02-2008, 12:30 AM
Holy fucking shit. Maulth. Where you been nigger? Anywho looks good, but I like mah pictures.

Uni_Sol
10-02-2008, 12:45 AM
Looks cool, I'd try it out when it's in more complete state, well when ever you say it's rdy lol.

KrazyBone
10-02-2008, 10:50 AM
looks pretty sexy, htats gonna be alot of wurk tho

Maulth
10-06-2008, 10:37 PM
*Updated Code*

And yeah, about my inactivity. My dad got divorced..again.. so I am living at a relatives house with the slowest fucking internet ever. Anyway, I am moving into my new house october 25th and should be online then on both these forums and server.

Israel | MySpace Editor | Loans | Debt Consolidation | Advertising