#include <iostream.h>
#include <ctype.h>
#include <stdlib.h>
#include <windows.h>
#include <conio.h>
#include <time.h>
#include <math.h>
char direction;
char direction2;
int battle;
int Hp = 20;
int EnemyHp1 = 5;
int EnemyHp2 = 5;
int EnemyHp3 = 5;
int EnemyHp4 = 5;
int fight;
int def = 0;
int attack;
int Enemyattack;
int a;
int b;
int c = EnemyHp2 - attack;
int d = EnemyHp3 - attack;
int e = EnemyHp4 - attack;
int run;
class Locations
{
public:
Locations() {}
~Locations() {}
void Load_Area1();
void Load_Area2();
void Load_Area3();
void Load_Area4();
void Load_Area5();
};
void Locations::Load_Area1()
{
if(EnemyHp1 <= 0 && EnemyHp2 <=0 && EnemyHp3 <= 0 && EnemyHp4 <= 0)
{
cout << "you win" << endl;
exit(0);
}
else
{
cout << "you see 4 rooms" << endl;
cout << "one to the north" << endl;
cout << "one to the south" << endl;
cout << "one to the east" << endl;
cout << "and one to the west" << endl;
cout << "(press 'q' to exit)" << endl;
cout << "<NSEW>" << endl;
Locations Load;
cin >> direction;
switch(direction)
{
case 'N' :
case 'n' :
Load.Load_Area2();
break;
case 'S' :
case 's' :
Load.Load_Area3();
break;
case 'W' :
case 'w' :
Load.Load_Area4();
break;
case 'E' :
case 'e' :
Load.Load_Area5();
break;
case 'Q' :
case 'q' :
exit(0);
break;
}
}
};
void Locations::Load_Area2()
{
srand((unsigned) time(NULL));
attack = rand() % 6;
Enemyattack = rand() % 4 - def;
a = EnemyHp1 - attack;
b = Hp - Enemyattack;
if(EnemyHp1 <= 0)
{
do
{
cout << endl << endl << "you see an empty room, thats another one down..." << endl;
cout << "do you want to go back to the senter square? y/n:" << endl;
cout << "<Senter Square>" << endl;
cin >> direction2;
switch(direction2)
{
case 'Y' :
case 'y' :
Locations Load;
Load.Load_Area1();
break;
}
}while(1);
}
else
{
do
{
if(EnemyHp1 > 0)
{
do
{
cout << endl << endl << "A beast attacks you..." << endl << "What do u do: " << endl;
cout << "(1)...Run" << endl;
cout << "(2)...Fight" << endl;
cout << "(3)...Defend" << endl;
cin >> fight;
if(fight == 1)
{
cout << endl << endl << "you try and run..." << endl;
run = rand() % 11;
if(run <= 6)
{
cout << endl << endl << "you succed to exape the monster and are back at the senter square..." << endl;
Locations Load;
Load.Load_Area1();
}
else
{
if(run > 6)
{
cout << endl << endl << "you fail to exape the monster..." << endl;
}
}
break;
}
else
{
if(fight == 2)
{
cout << endl << endl << "you attack the monster hurting him " << attack << " points worth of dammage" << endl;
cout << "the monster now has " << a << " points worth of hp" << endl;
cout << "the monster clubs you cousing " << Enemyattack << " points worth of dammage" << endl;
cout << "you now have " << b << " points worth of hp" << endl;
getche();
EnemyHp1 = a;
Hp = b;
Locations Load;
Load.Load_Area2();
}
else
{
if(fight == 3)
{
def = rand() % 5;
cout << endl << endl << "the monster clubs you cousing " << Enemyattack << " points worth of dammage" << endl;
cout << "you now have " << b << " points worth of hp" << endl;
def = 0;
}
}
}
EnemyHp2 = a;
Hp = b;
}while(run > 6 && EnemyHp1 > 0 && Hp > 0);
}
}while(EnemyHp2 <= 0);
}
};
void Locations::Load_Area3()
{
srand((unsigned) time(NULL));
attack = rand() % 6;
Enemyattack = rand() % 4 - def;
c = EnemyHp2 - attack;
b = Hp - Enemyattack;
if(EnemyHp2 <= 0)
{
do
{
cout << endl << endl << "you see an empty room, thats another one down..." << endl;
cout << "do you want to go back to the senter square? y/n:" << endl;
cout << "<Senter Square>" << endl;
cin >> direction2;
switch(direction2)
{
case 'Y' :
case 'y' :
Locations Load;
Load.Load_Area1();
break;
}
}while(1);
}
else
{
do
{
if(EnemyHp2 > 0)
{
do
{
cout << endl << endl << "A beast attacks you..." << endl << "What do u do: " << endl;
cout << "(1)...Run" << endl;
cout << "(2)...Fight" << endl;
cout << "(3)...Defend" << endl;
cin >> fight;
if(fight == 1)
{
cout << endl << endl << "you try and run..." << endl;
run = rand() % 11;
if(run <= 6)
{
cout << endl << endl << "you succed to exape the monster and are back at the senter square..." << endl;
Locations Load;
Load.Load_Area1();
}
else
{
if(run > 6)
{
cout << endl << endl << "you fail to exape the monster..." << endl;
}
}
break;
}
else
{
if(fight == 2)
{
cout << endl << endl << "you attack the monster hurting him " << attack << " points worth of dammage" << endl;
cout << "the monster now has " << c << " points worth of hp" << endl;
cout << "the monster clubs you cousing " << Enemyattack << " points worth of dammage" << endl;
cout << "you now have " << b << " points worth of hp" << endl;
getche();
EnemyHp2 = c;
Hp = b;
Locations Load;
Load.Load_Area3();
}
else
{
if(fight == 3)
{
def = rand() % 5;
cout << endl << endl << "the monster clubs you cousing " << Enemyattack << " points worth of dammage" << endl;
cout << "you now have " << b << " points worth of hp" << endl;
def = 0;
}
}
}
EnemyHp2 = c;
Hp = b;
}while(run > 6 && EnemyHp2 > 0 && Hp > 0);
}
}while(EnemyHp2 <= 0);
}
};
void Locations::Load_Area4()
{
srand((unsigned) time(NULL));
attack = rand() % 6;
Enemyattack = rand() % 4 - def;
d = EnemyHp3 - attack;
b = Hp - Enemyattack;
if(EnemyHp3 <= 0)
{
do
{
cout << endl << endl << "you see an empty room, thats another one down..." << endl;
cout << "do you want to go back to the senter square? y/n:" << endl;
cout << "<Senter Square>" << endl;
cin >> direction2;
switch(direction2)
{
case 'Y' :
case 'y' :
Locations Load;
Load.Load_Area1();
break;
}
}while(1);
}
else
{
do
{
if(EnemyHp3 > 0)
{
do
{
cout << endl << endl << "A beast attacks you..." << endl << "What do u do: " << endl;
cout << "(1)...Run" << endl;
cout << "(2)...Fight" << endl;
cout << "(3)...Defend" << endl;
cin >> fight;
if(fight == 1)
{
cout << endl << endl << "you try and run..." << endl;
run = rand() % 11;
if(run <= 6)
{
cout << endl << endl << "you succed to exape the monster and are back at the senter square..." << endl;
Locations Load;
Load.Load_Area1();
}
else
{
if(run > 6)
{
cout << endl << endl << "you fail to exape the monster..." << endl;
}
}
break;
}
else
{
if(fight == 2)
{
cout << endl << endl << "you attack the monster hurting him " << attack << " points worth of dammage" << endl;
cout << "the monster now has " << d << " points worth of hp" << endl;
cout << "the monster clubs you cousing " << Enemyattack << " points worth of dammage" << endl;
cout << "you now have " << b << " points worth of hp" << endl;
getche();
EnemyHp3 = d;
Hp = b;
Locations Load;
Load.Load_Area4();
}
else
{
if(fight == 3)
{
def = rand() % 5;
cout << endl << endl << "the monster clubs you cousing " << Enemyattack << " points worth of dammage" << endl;
cout << "you now have " << b << " points worth of hp" << endl;
def = 0;
}
}
}
EnemyHp3 = d;
Hp = b;
}while(run > 6 && EnemyHp3 > 0 && Hp > 0);
}
}while(EnemyHp3 <= 0);
}
};
void Locations::Load_Area5(void)
{
srand((unsigned) time(NULL));
attack = rand() % 6;
Enemyattack = rand() % 4 - def;
e = EnemyHp4 - attack;
b = Hp - Enemyattack;
if(EnemyHp4 <= 0)
{
do
{
cout << endl << endl << "you see an empty room, thats another one down..." << endl;
cout << "do you want to go back to the senter square? y/n:" << endl;
cout << "<Senter Square>" << endl;
cin >> direction2;
switch(direction2)
{
case 'Y' :
case 'y' :
Locations Load;
Load.Load_Area1();
break;
}
}while(1);
}
else
{
do
{
if(EnemyHp4 > 0)
{
do
{
cout << endl << endl << "A beast attacks you..." << endl << "What do u do: " << endl;
cout << "(1)...Run" << endl;
cout << "(2)...Fight" << endl;
cout << "(3)...Defend" << endl;
cin >> fight;
if(fight == 1)
{
cout << "you try and run..." << endl;
run = rand() % 11;
if(run <= 6)
{
cout << endl << endl << "you succed to exape the monster and are back at the senter square..." << endl;
Locations Load;
Load.Load_Area1();
}
else
{
if(run > 6)
{
cout << endl << endl << "you fail to exape the monster..." << endl;
}
}
break;
}
else
{
if(fight == 2)
{
cout << endl << endl << "you attack the monster hurting him " << attack << " points worth of dammage" << endl;
cout << "the monster now has " << e << " points worth of hp" << endl;
cout << "the monster clubs you cousing " << Enemyattack << " points worth of dammage" << endl;
cout << "you now have " << b << " points worth of hp" << endl;
getche();
EnemyHp4 = e;
Hp = b;
Locations Load;
Load.Load_Area5();
}
else
{
if(fight == 3)
{
def = rand() % 5;
cout << endl << endl << "the monster clubs you cousing " << Enemyattack << " points worth of dammage" << endl;
cout << "you now have " << b << " points worth of hp" << endl;
def = 0;
}
}
}
EnemyHp4 = e;
Hp = b;
}while(run > 6 && EnemyHp4 > 0 && Hp > 0);
}
}while(EnemyHp4 <= 0);
}
};
void main()
{
Locations Load;
Load.Load_Area1();
}
Edited by - McChuie on 8/6/00 9:56:39 PM
Debugging
I am making just about my first game ever, and I cinda know what I am doing but I don't understand all the error messages i have (theres only 7), so I was hoping that if i posted my code with the error messages mabie you guys could help me by first helping me complete my first game (YA!!) and second help formiliorize me with the error messages. Ok so here's the code:
What error messages do you get?
Edited by - richardve on August 5, 2000 9:05:55 PM
Edited by - richardve on August 5, 2000 9:05:55 PM
Oh my god, GW-BASIC flashbacks!
Couple of things you need to post.. what compiler you''re using, and a list of the error messages you are getting.
-RWarden (roberte@maui.net)
Couple of things you need to post.. what compiler you''re using, and a list of the error messages you are getting.
-RWarden (roberte@maui.net)
The errors are listed in the code. But the compiler name is not present...
"Everything is relative." -- Even in the world of computers.
"Everything is relative." -- Even in the world of computers.
everything is relative. -- even in the world of computers... so PUSH BEYOND THE LIMITS OF SANITY!
Ok, I just saw your error messags in code. Sorry
1. This error is caused by you putting a semicolon after the closing bracket of the LoadArea1 function.
Fixing 1 should eliminate errors 1, 2, 3, 4, and 5.
6. This is caused by you having a semicolon at the function definition. I.e. "void Locations::Load_Area4();" should be "void Locations::Load_Area4()".
7. This is exactly the same as 6.
So anyway all the errors are just caused by unneeded semicolons.
-RWarden (roberte@maui.net)
1. This error is caused by you putting a semicolon after the closing bracket of the LoadArea1 function.
Fixing 1 should eliminate errors 1, 2, 3, 4, and 5.
6. This is caused by you having a semicolon at the function definition. I.e. "void Locations::Load_Area4();" should be "void Locations::Load_Area4()".
7. This is exactly the same as 6.
So anyway all the errors are just caused by unneeded semicolons.
-RWarden (roberte@maui.net)
August 05, 2000 08:50 PM
1. "int Enemyattack = rand() % 4 - def;"
You have not assigned def a value yet. Make sure you do so before you use it. (I suspect you''ll want to change this to a function.) (It will work, but it''ll use whatever value happens to be in memory there, which is probably not what you want.)
Error 1: You''re missing a "}". And you don''t need the semi-colon either. So
case ''E'' :
case ''e'' :
Load.Load_Area5();
break;
};
Should become
case ''E'' :
case ''e'' :
Load.Load_Area5();
break;
}
}
Error 2, 3 and 4: You''re missing braces ("}") on your switch statement. Add those and try it.
Error 5: You forgot a "}" again, to end your if. So right before the else, put a "}".
Error 6: Remove the semi-colon after
"void Locations::Load_Area4();" (make it "void Locations::Load_Area4()").
Error 7: Same as above.
You have not assigned def a value yet. Make sure you do so before you use it. (I suspect you''ll want to change this to a function.) (It will work, but it''ll use whatever value happens to be in memory there, which is probably not what you want.)
Error 1: You''re missing a "}". And you don''t need the semi-colon either. So
case ''E'' :
case ''e'' :
Load.Load_Area5();
break;
};
Should become
case ''E'' :
case ''e'' :
Load.Load_Area5();
break;
}
}
Error 2, 3 and 4: You''re missing braces ("}") on your switch statement. Add those and try it.
Error 5: You forgot a "}" again, to end your if. So right before the else, put a "}".
Error 6: Remove the semi-colon after
"void Locations::Load_Area4();" (make it "void Locations::Load_Area4()").
Error 7: Same as above.
WOW!! Thanks guys!! you REALLY help me out! I did what you told me and it worked, but it opened up new errors, 4 are the exact same and 1 is somthing easy to fix, I changed my code to the newer one and put in where ther errors are. Thanks again!!!
But I dont understand
"Error 1: You're missing a "}". And you don't need the semi-colon either. So
case 'E' :
case 'e' :
Load.Load_Area5();
break;
};
Should become
case 'E' :
case 'e' :
Load.Load_Area5();
break;
}
}"
where do i do that?
Edited by - McChuie on August 5, 2000 12:22:29 AM
But I dont understand
"Error 1: You're missing a "}". And you don't need the semi-colon either. So
case 'E' :
case 'e' :
Load.Load_Area5();
break;
};
Should become
case 'E' :
case 'e' :
Load.Load_Area5();
break;
}
}"
where do i do that?
Edited by - McChuie on August 5, 2000 12:22:29 AM
August 05, 2000 11:25 PM
Looks like you forgot more braces ("{") on your switch statements. Look at all your switch statements and make sure you have them like this:
switch (variable)
{
...
}
switch (variable)
{
...
}
August 05, 2000 11:28 PM
You did the
"Error 1: You''re missing a "}". And you don''t need the semi-colon either. So
case ''E'' :
case ''e'' :
Load.Load_Area5();
break;
};
Should become
case ''E'' :
case ''e'' :
Load.Load_Area5();
break;
}
}"
in "LoadArea1" on the first switch statement. (Look at the closing brace on the switch statement.)
"Error 1: You''re missing a "}". And you don''t need the semi-colon either. So
case ''E'' :
case ''e'' :
Load.Load_Area5();
break;
};
Should become
case ''E'' :
case ''e'' :
Load.Load_Area5();
break;
}
}"
in "LoadArea1" on the first switch statement. (Look at the closing brace on the switch statement.)
Ok, now I fixed those errors, but again it showed new ones (actually 1 but 4 times):
initialization of ''Load'' is skipped by ''default'' label
I have a fealing that this is the last wave of errors, but i thought that last time so this might not be the last of me.
And the compiler I use is the one that came with MV C++
initialization of ''Load'' is skipped by ''default'' label
I have a fealing that this is the last wave of errors, but i thought that last time so this might not be the last of me.
And the compiler I use is the one that came with MV C++
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement