cout<<"--------------[TYPE THE NUMBER FOR THE ATTACK TYPE AND PRESS ENTER]------------"<<endl<<endl;
//prompts the user to enter what kind of attack they want to do
//attack_type 1 will cause a sword attack, attack_type 2 will fire gun, attack_type 3 will use fireball
// attack_type 4 will do heal, attack_type 5 will do percoset, attack_type 6 will use speed, 7 acid
//do magic menu is 10 and do item menu is 11
if (current_player.bullets < 1) //if the player has no bullets, dont show fire gun as an option
{
cout<<"----------[1 FOR KNIFE ATTACK]------[2 FOR MAGIC]------[3 TO USE ITEM]----------"<<endl;
attack_type = getche();//cin>>attack_type;
if(attack_type == ''2''){attack_type = ''8'';}
if(attack_type == ''3''){attack_type = ''9'';}
}
else //the player had bullets,show gun as an option for attacking
{
cout<<"----------------[1 FOR KNIFE ATTACK]----------[2 TO FIRE GUN]------------------"<<endl<<endl;
cout<<"----------------[3 TO USE MAGIC]--------------[4 TO USE ITEM]------------------"<<endl;
attack_type = getche();///cin>>attack_type;
if (attack_type == ''3''){attack_type = ''8'';} //if they chose magic, pop up magic menu
if (attack_type == ''4''){attack_type = ''9'';} //if they chose item, pop up item
}
//now if the player chose magic, then show magic choices
if (attack_type == ''8'')
{
cout<<"[1 FOR FIREBALL] [2 FOR HEAL]"<<endl;
magic_type = getche();///cin>>magic_type;
if (magic_type == 1) {return ''3'';} //attack_type = ''3'';} //they cast fireball
else if (magic_type == 2) {return ''4'';}//attack_type = ''4'';} //they cast heal
}
//else they chose item, show item choices.
else if (attack_type == ''9'')
{
cout<<"--------[1 FOR PERCOSET]----------[2 FOR SPEED]---------[3 FOR ACID]------------"<<endl;
item_type = getche();///cin>>item_type;
if (item_type == 1) {attack_type = ''5'';}
else if (item_type == 2) {return ''6'';}//attack_type = ''6'';}
else if (item_type == 3) {return ''7'';}//attack_type = ''7'';}
}
ps- originally there was only one return in the function, the one at the bottom. the others you see i just put it there to see if that would fix it, but it probably just made things worse. also i know using those numbers is hard to follow, im going to change it around to enums or something
using getche()
is there some sort of function or something that clears getch() because if i use it twice in a row with 2 seperate variables, the second one doesnt work. heres my source.
What do you mean it doesn''t work? Which part of the code is the error in from what you posted?
--{You fight like a dairy farmer!}
--{You fight like a dairy farmer!}
it compiles... but when i press 1, 2, 3 or 4, it works fine. these all use the same variable attack_type. if i switch it to magic_type or item_type = getch(), it doesnt work. i press the key and nothing happends
quote:Original post by graveyard fillaAnd did you also "switch" the if statement conditionals and bodies?
if i switch it to magic_type or item_type = getch(), it doesnt work. i press the key and nothing happends
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement