Hello, I posted a while ago to get some help with a simple game that I was creating to test what I had learned. I decided to rewrite the code to add new things that I've learned. I'm getting a lot of errors, I'm sure it has something to do witht he function, but if you could look at this code, it would be greatly appreciated, thank you, and thanks to everyone that's helped me in the past!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
#include <iostream>
#include <string>
using namespace std;
int hero_health, monster_health, hero_damage, monster_damage, hero_weapon, hero_RH, monster_RH;
hero_health = 100;
monster_health = 5;
hero_damage = hero_weapon;
monster_damage = 10;
int battle (hero_health, monster_health, hero_damage, monster_damage, hero_weapon);
int main ()
{
string battle;
string hero_name;
cout << "enter your hero's name: ";
getline(cin, hero_name);
cout << "welcome to Cravin " << hero_name;
cout << "What weapon would you like to fight with? \n";
cout << "press 1 for sword, press 2 for axe, press 3 for hammer";
cin >> hero_weapon;
chooseweapon:
switch (hero_weapon)
{
case 1:
cout << "you choose to weild the sword. A long sharp blade, that glints in the sun!";
hero_weapon = 5;
break;
case 2:
cout << "you choose to wield the axe. It's blade shimmers in the light!";
hero_weapon = 5;
break;
case 3:
cout << "you choose to wield the hammer. A massive bludgeoning weapon";
hero_weapon = 10;
break;
default:
cout << "you have pressed an incorrect key.";
goto chooseweapon;
}
cout << "you are walking through the hills, and come across a viciouse gobline.\n";
cout << "it sneers it's teeth. Do you wish to fight it, or run away?";
battleflag:
getline (cin,battle)
if (battle == "battle" || battle == "fight" || battle == "battle goblin" || battle == fight goblin)
{
cout << "you choose to attack the goblin! ";
cout << "You exchange blows";
cout << "your remaining health is: " << hero_RH;
cout << "the monster's remaining health is: " << monster_RH;
battle (100, 5, hero_damage, 10, hero_weapon);
}
else
{
cout << "I didn't understand what you wanted to do";
goto battleflag;
}
return 0;
}
battle (hero_health, monster_health, hero_damage, monster_damage, hero_weapon)
{
hero_RH = hero_health - monster_damage;
monster_RH = monster_health - hero_weapon;
return hero_RH, monster_RH;
}
|
Here are the errors:
1>c:\users\scott\desktop\jeremy\c++\programs\program test\program test\program.cpp(5) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\scott\desktop\jeremy\c++\programs\program test\program test\program.cpp(5) : error C2086: 'int hero_health' : redefinition
1> c:\users\scott\desktop\jeremy\c++\programs\program test\program test\program.cpp(4) : see declaration of 'hero_health'
1>c:\users\scott\desktop\jeremy\c++\programs\program test\program test\program.cpp(6) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\scott\desktop\jeremy\c++\programs\program test\program test\program.cpp(6) : error C2086: 'int monster_health' : redefinition
1> c:\users\scott\desktop\jeremy\c++\programs\program test\program test\program.cpp(4) : see declaration of 'monster_health'
1>c:\users\scott\desktop\jeremy\c++\programs\program test\program test\program.cpp(7) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\scott\desktop\jeremy\c++\programs\program test\program test\program.cpp(7) : error C2086: 'int hero_damage' : redefinition
1> c:\users\scott\desktop\jeremy\c++\programs\program test\program test\program.cpp(4) : see declaration of 'hero_damage'
1>c:\users\scott\desktop\jeremy\c++\programs\program test\program test\program.cpp(8) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\scott\desktop\jeremy\c++\programs\program test\program test\program.cpp(8) : error C2086: 'int monster_damage' : redefinition
1> c:\users\scott\desktop\jeremy\c++\programs\program test\program test\program.cpp(4) : see declaration of 'monster_damage'
1>c:\users\scott\desktop\jeremy\c++\programs\program test\program test\program.cpp(9) : error C2078: too many initializers
1>c:\users\scott\desktop\jeremy\c++\programs\program test\program test\program.cpp(43) : error C2143: syntax error : missing ';' before 'if'
1>c:\users\scott\desktop\jeremy\c++\programs\program test\program test\program.cpp(43) : error C2065: 'fight' : undeclared identifier
1>c:\users\scott\desktop\jeremy\c++\programs\program test\program test\program.cpp(43) : error C2146: syntax error : missing ')' before identifier 'goblin'
1>c:\users\scott\desktop\jeremy\c++\programs\program test\program test\program.cpp(43) : error C2059: syntax error : ')'
1>c:\users\scott\desktop\jeremy\c++\programs\program test\program test\program.cpp(44) : error C2065: 'goblin' : undeclared identifier
1>c:\users\scott\desktop\jeremy\c++\programs\program test\program test\program.cpp(44) : error C2143: syntax error : missing ';' before '{'
1>c:\users\scott\desktop\jeremy\c++\programs\program test\program test\program.cpp(49) : error C2064: term does not evaluate to a function taking 5 arguments
1>c:\users\scott\desktop\jeremy\c++\programs\program test\program test\program.cpp(51) : error C2181: illegal else without matching if
1>c:\users\scott\desktop\jeremy\c++\programs\program test\program test\program.cpp(59) : error C2448: 'battle' : function-style initializer appears to be a function definition
1>Build log was saved at "file://c:\Users\Scott\Desktop\Jeremy\C++\Programs\Program Test\Program Test\Debug\BuildLog.htm"
1>Program Test - 18 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========