Monday 30 May 2011

My basic battle scene (C++)

//this set goes at the top of the file with the global varables
int Health;//it's the players health
int Attack;//it's the players Attack
int enemyHp;//it's the enemies health
int enemyAp;//it's your enemies Attack
// you can copy and paste it into your work
int EnemyFB(){
Health=30;//it's the players health
enemyAp=3;//it's your enemies Attack
Health=Health-enemyAp;
cout << "enemy fights back " << endl;
cout << "Enemy does " << enemyAp << " damage, you have " << Health << " Health";
hold();
}
void fight (){
do[//start rhe fight secuence
Attack=3;//it's the players Attack
enemyHp=20;//it's the enemies health
cout << "Do you want to attack your enemy? (Y/N)" << endl;
cin >> YoN;
switch (YoN){
case 'y'://in case they have choosen y/to attack
enemyHp=enemyHp-Attack;
cout << "You attack your enemy you do " << Attack << " Damage" << endl << "Your enemy now has " << enemyHp << endl;
EnemyFB();//go to the enemy fight back
break;
case 'Y'://in case they have choosen Y/to attack
enemyHp=enemyHp-Attack;
cout << "You attack your enemy you do " << Attack << " Damage" << endl << "Your enemy now has " << enemyHp << endl;
EnemyFB();//go to the enemy fight back
break;
default:// if anything apart from Y IS PRESSED
cout << "What so you don't to fight?"<< endl;
hold ();//you should already have this function inside your game
}while (enemyHp>0);//It'll continue doing the procedure while your enemies hp is still a positive int
cout << "You have deffeated your enemy" << endl;
hold();
}

No comments:

Post a Comment