i am learning c++ and i think so far i am doing pretty well. i think i learn better when i have an objective so i decided to make a little game, kinda an old single user dungeon style game cos i like those. anyway i have a bunch of parts made up some problem have come up i have managed to get through them and fix all the major bugs and snags. but i have come to one part and i have a bug in it and i just cant get the damn thing to work right. here is the code.
Code:
#include <iostream>
using namespace std;
int monhealth=20;
int health=30;
int monster;//the monster you are fighting
int you;//the player
int monarmor = 14;
int yourarmor = 16;
int monstr = 2;
int ystr = 2;
int mondamage;
int damage;
int attack;
int main()
{
cout<<"you are in combat?! what the hell!!!"<<endl;
cout<<endl;
system("pause");
do {
srand(static_cast<unsigned int>(time(0)));
monster = rand()%20+1;
mondamage = rand()%6+1;
damage = rand()%6+1;
attack = rand()%20+1;
cout<<endl;
cout<<endl;
cout<<"----------------------------------------------------"<<endl;
cout<<"monsters attack is "<< monster + monstr<<endl;
cout << "the monster swings an attack at you and ";// will change for other monsters
if (monster > yourarmor)
{
cout <<"and racks it across your leg "<<endl;//will add other stuff for other monsters
health = health - mondamage;
cout<<endl;
}
else if (monster + monstr < yourarmor || monster + monstr == yourarmor)
{
cout<<"you manage to dodge the monsters attack"<<endl;
cout <<endl;
}
else if (monster == 1)
{
cout <<"the monster hits himself in the leg"<<endl;
monhealth = monhealth - mondamage;
}
cout<<endl;
cout<<endl;
cout<<"----------------------------------------------------"<<endl;
cout<<"your health is currently " <<health<<" and it is now time for your attack."<<endl;
cout<<"press anykey to roll your attack"<<endl;
cout<<endl;
system("pause");
cout<<endl;
cout<<endl;
cout<<"you swing your sword at the beast and ";
if (attack + ystr > monarmor)
{
cout<<"you strike him square in the cheast"<<endl;
monhealth = monhealth - damage;
}
else if (attack + ystr < monarmor)
{
cout<<"you miss, shit..."<<endl;
}
else if (attack = 1)
{
cout<<"you smash yourself in the leg"<<endl;
health =health - damage;
}
}while ( health > 0 || monhealth > 0 );
if (health < 0)
{
cout<<"you are dead, shity hu?"<<endl;
}
else if (monhealth < 0)
{
cout<<"you have killed the monster ^^, you should be proud."<<endl;
}
else if (monhealth < 0 && health < 0)
{
cout<<"you swing a mighty blow at the monster and sink it deep into its";
cout<<"chest, but it stabs you in the belly at she same time. you are both";
cout<<"dead"<<endl;
}
cout<<endl;
cout<<endl;
cout<<endl;
system("pause");
return 0;
}
also i have one more question that maybe some one could awcer for me. so far i am only making the templets for things like random encounters, combat systems, traveling, random loot, tand things like that. but i want to know the best way to connect them. should i make them into a project or as one huge *** single code monster. and if the acwer == use the project thing could you please give me a little hint on how the hell that works... thanks.
...locksmith...


