Public Group

# I am so Happy.

This topic is 4874 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I am so happy. After reading a little more on Function I though about making a game and working on it as I go along in c++. I the next char I come to is Arrays I cant wait, I know there are a lot fo different thign I could do with the code I have made so far but I am only showing you what i have learned so far. I hope you all enjoy it as much as I enjoed making it.
#include <iostream>
using namespace std;

void IntroStory();
int AlchemyHelper(int &Hp, int &Defense, int &Strength, int &Agility, int &Ap);
int UpgradeShop(int Hp, int Defense, int Strength, int Agility, int AP, int Credits);
int HpUpgrade( int &Hp, int &Credits);
int StrengthUpgrade ( int &Strength, int &Credits);
int AgilityUpgrade ( int &Agility, int &Credits);
int APUpgrade( int &AP, int &Credits);

int main ()
{
int Hp;
Hp = 20;
int Defense;
Defense = 10;
int Strength;
Strength = 9;
int Agility;
Agility = 13;
int AP;
AP = 40;
int Credits;
Credits = 1000;

cout << " Hello and welcome to the Mastering the forgotten power!\n";
cout << " Please choose what option you want to do.\n";
cout << " 1 - NewGame.\n";
cout << " 2 - Exit.\n";
int choice;
cout << " Choice.\n";
cin >> choice;

switch ( choice )
{
case 1:
IntroStory();
system ("cls");
cout << " As you awaken in your room, You hear a ancoument over the pa.\n\n";
cout << " All new Alchemist please report to the Alchemy trainer.\n\n";
cout << " As you grab your clothes and everthing you also take your credit stick.\n\n";
cout << " As you touch you Credit stick it displays how much Credits you have " << Credits << endl;
system ("PAUSE");
system ("cls");
cout << " Ah Welcome to the Alchemy Trainer, my name is Jane.\n\n";
cout << " So we are here to determin what Alchemy type you want to be.\n\n";
cout << " 1 - Earth Alchemist.\n";
cout << " 2 - Water Alchemist.\n";
cout << " 3 - Fire Alchemist.\n";
cout << " 4 - Air Alchemist.\n\n";
int choice2;
cout << " Choice.\n";
cin >> choice2;

switch ( choice2 )
{
case 1:
cout << " You have Chosen Earth Alchemy!.\n";
cout << " All your Skill will be earth Based.\n\n";
cout << " Now that we know your Alchemy type, please report to the captin for a mission.\n\n";
system ("PAUSE");
system ("cls");
cout << " As you enter the captin chambers, He turn towards you and says welcome.\n\n";
cout << " Well I am glad you found out what Type of Alchemist you are.\n\n";
cout << " Well before I send you on a misson you will need something are r & d deparment.\n\n";
cout << " Worked on it is called a menu system. It will let you do the Following.\n\n";
cout << " View your current stats such as Lv, Strength, Defense, Agility, AP, Credits.\n\n";
cout << " It Will let you save your progress from anywhere in the world. This is still \n\n being worked on.\n\n";
cout << " It Also display what Skills you have.\n\n";
system ("PAUSE");
system ("cls");
cout << " O now for your mission info. The town people of Pish have reported that a Demon \n\n.";
cout << " Has been eating and Killing the towns people.\n\n";
cout << " So Please go and help them and report back to me one your findings.\n\n";
cout << " O before you go please go to the Alchemy Helper to learn About how Alchemy \n\n works. \n\n";
int choice3;
cout << " Do you wish to go see the Alchemy Helper.\n";
cout << " 1 - Yes.\n";
cout << " 2 - No.\n";
cout << " choice.\n";
cin >> choice3;
if ( choice3 == 1 )
AlchemyHelper(Hp, Defense, Strength, Agility, AP );
else
cout << " Ok well ger ready for you Mission then!\n\n";
break;
case 2:
cout << " You have chosen Water Alchemy!.\n";
cout << " All your skills will be water based.\n\n";
cout << " Now that we know your Alchemy type, please report to the captin for a mission.\n\n";
system ("PAUSE");
system ("cls");
cout << " As you enter the captin chambers, He turn towards you and says welcome.\n\n";
cout << " Well I am glad you found out what Type of Alchemist you are.\n\n";
cout << " Well before I send you on a misson you will need something are r & d deparment.\n\n";
cout << " Worked on it is called a menu system. It will let you do the Following.\n\n";
break;
case 3:
cout << " You have chosen Fire Alchemy!.\n";
cout << " All your skills will be Fire Based.\n\n";
cout << " Now that we know your Alchemy type, please report to the captin for a mission.\n\n";
system ("PAUSE");
system ("cls");
cout << " As you enter the captin chambers, He turn towards you and says welcome.\n\n";
cout << " Well I am glad you found out what Type of Alchemist you are.\n\n";
cout << " Well before I send you on a misson you will need something are r & d deparment.\n\n";
cout << " Worked on it is called a menu system. It will let you do the Following.\n\n";
break;
case 4:
cout << " You have chosen Air Alchemy!.\n";
cout << " All your skills will be Air Based.\n\n";
cout << " Now that we know your Alchemy type, please report to the captin for a mission.\n\n";
system ("PAUSE");
system ("cls");
cout << " As you enter the captin chambers, He turn towards you and says welcome.\n\n";
cout << " Well I am glad you found out what Type of Alchemist you are.\n\n";
cout << " Well before I send you on a misson you will need something are r & d deparment.\n\n";
cout << " Worked on it is called a menu system. It will let you do the Following.\n\n";
break;
default :
cout << " That is not a choice.\n\n";
}
system ("PAUSE");
break;

case 2:
cout << " Please come back and Play again.\n";
break;
}
return 0;
}

//function Def.

void IntroStory()
{
cout << " The Year is 2012, and the earth is a Disolite Planet.\n\n";
cout << " After the war 21 + 1 happened, the earth was brought to ruins.\n\n";
cout << " Demons and monster still roam the planet, Terror the people of the land.\n\n";
cout << " Some of the Surivers of the war still are fighting the fight, against the \n\n demons and monsters.\n\n";
cout << " They are know as ShadowStalkers. And they use a very old and \n\n Powerfull magic know was Alchemy.\n\n";
cout << " And this is where you story beginnes.\n\n";
system ("PAUSE");
return ;
}
int AlchemyHelper(int &Hp, int &Defense, int &Strength, int &Agility, int &AP)
{

cout << " Hello and welcome to the My area.\n\n";
cout << " Well Let me Explain a little about Alchemy.\n\n";
cout << " Alchemy is the method of deconstructing and,\n\n recreating matter by understanding its inherent laws and its place in nature.\n\n";
cout << " The base law of Alchemy is.\n\n";
cout << " 'Equivalent Exchange.' In order to gain something, an equivalent price must be paid.\n\n";
system ("PAUSE");
system ("cls");
cout << " Well lets look at some examples of Equivalent Exchange.\n\n";
cout << " Lets say you are a earth Alchemist,\n\n";
cout << " And you want to make a use you skill EarthShield.\n\n";
cout << " To make the Skill work you might have to destory a Stone to make the Shield.\n\n";
cout << " Ok let say you where a Fire Alchemist.\n\n";
cout << " And you wanted to use the Skill Fire Strike.\n\n";
cout << " To make the Skill Work, you might have to Put out a Fire With a Strong Strike.\n\n";
cout << " Ok lets say you where a Water Alchemist.\n\n";
cout << " And you want to use the skill WaterBall.\n\n";
cout << " You might have to be standing in a pool of water, to use the skill.\n\n";
cout << " Ok lets say you are a Air Alchemist.\n\n";
cout << " And you want to use the skill Breath Of Life.\n\n";
cout << " You might have to Kill a monster to bring some thing back to life.\n\n";
cout << " Ok well thank you for Listening to my talk.\n\n";
system ("PAUSE");
system ("cls");
cout << " Well this is for Listen to me explain Alchemy.\n\n";
cout << " Let me Gift you with this Blessing.\n\n";
Hp += 1;
Defense += 2;
Strength += 1;
Agility += 1;
AP += 1;
cout << " Your Hp after the Blessing is " << Hp << endl;
cout << " Your Defense after the Blessing is " << Defense << endl;
cout << " Your Strength after the Blessing is " << Strength << endl;
cout << " Your Agility after the Blessing is " << Agility << endl;
cout << " Your AP after the Blessing is " << AP << endl;

return 0;
}

int UpgradeShop(int Hp, int Defense, int Strength, int Agility, int AP, int Credits)
{
cout << " Hello and welcome to the upgrade shop.\n";
cout << " 1 - Hp, it will cost 500 credits for 1 point of hp.\n";
cout << " 2 - Defense, it will cost 900 credits for 1 point of Defense.\n";
cout << " 3 - Strength, it will cost 1000 credits for 1 point of Strength.\n";
cout << " 4 - Agility, it will cost 750 credits for 1 point of Agility.\n";
cout << " 5 - AP, it will cost 2000 credits for 1 point of AP.\n";
int choice;
cout << " choice.\n";
cin >> choice;

switch (choice)
{
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
break;
}
int pick;
cout << " 1 - Yes.\n";
cout << " 2 - No.\n";
cin >> pick;

if ( pick == 1 )
UpgradeShop(Hp, Defense, Strength, Agility, AP, Credits);
else
cout << " Have a nice Day.\n";
return 0;
}

int HpUpgrade ( int &Hp, int &Credits)
{
if ( Credits >= 500 )
{
cout << " Aye thank you for the credits.\n\n";
Credits -= 500;
cout << " After paying your credits are " << Credits << endl;
Hp += 1;
}
else
cout << " Please come back when you have the money!\n\n";

return 0;
}

int DefenseUpgrade ( int &Defense, int &Credits)
{
if ( Credits >= 900 )
{
cout << " Aye Thank you for the Credits.\n\n";
Credits -= 900;
cout << " Your credits after paying the man is " << Credits << endl;
Defense += 1;
cout << " Your Defense after the upgrade is " << Defense << endl;
}
else
cout << " Please come back when you have the money.\n";
return 0;
}

{
if ( Credits >= 1000 )
{
cout << " Aye thank you for the Credits.\n\n";
Credits -= 1000;
cout << " Your Credits after paying the man is " << Credits << endl;
Strength += 1;
cout << " Your Strength after the upgrade is " << Strength << endl;
}
else
cout << " Please come back when you have the Credits!\n\n";
return 0;
}

int AgilityUpgrade ( int &Agility, int &Credits)
{
if ( Credits >= 750 )
{
cout << " Aye Thank you for the Credits!\n\n";
Credits -= 750;
cout << " Your credits after paying the man is " << Credits << endl;
Agility += 1;
cout << " Your Agility after the upgrade is " << Agility << endl;
}
else
cout << " Please come back when you have the money.\n";
return 0;
}

int APUpgrade ( int &AP, int &Credits)
{

if ( Credits >= 2000 )
{
cout << " Aye thank you for the credits!\n\n";
Credits -= 2000;
cout << " After paying the man your credits are " << Credits << endl;
AP += 1;
cout << " After the upgrade your AP is " << AP << endl;
}
else
cout << " Please come back when you have the money!\n";
return 0;
}


I know it is alot of code and when i get i to class and data strucres I can make it smaller but I am happy with it as it is right now.

##### Share on other sites
Good work so far, but why don't you have main as the last function so you don't need all those function predeclarations. Another thing, why do you have a comment saying you're doing a function definition. [grin]

##### Share on other sites
yes ewww I cant stand main() as the first function. Though, a lot of people still like having there prototypes even though main() is last. But yea gj and keep it up.

##### Share on other sites
Just a little nitpicky thing:

<source>
int Credits;
Credits = 1000;</source>

Why dont you just make it one line???:
<source>
int Credits = 1000;</source>

I think that that makes it look more readable and sexy because you have all your data types lined up.

##### Share on other sites
Personally, I like main first since it's more logical. You wouldn't read a book from the back to the front, would you?

~~~~IGNORE~~~~
And not that it makes a difference, but alchemists are usually character types of their own. Elementalists work with elements. ^_^
~~~~IGNORE~~~~

##### Share on other sites
Are you sure your UpgradeShop function is correct? If you plan on using it how I think you plan on using it, the arguments should be references - int& - instead of regular ints.

Good job, though. As future work you might want to try and figure out how to store all the text in a seperate text file, and load it in and print bits out instead of hardcoding it all - that way you can load the text file up in Word and spellcheck it, and stuff like that.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 13
• 9
• 9
• 15
• 14
• ### Forum Statistics

• Total Topics
634070
• Total Posts
3015332
×