Well to practise my coding in C + + I started to create games, I have created this one
Instructions
You Set up your warriors in 3 values
Enemy Set up his warriors
You attack, choose value from 0-9
Enemy attack from 0-9
You have 3 soldiers
If he hits you a soldier it loses 1 HP, soldiers have 3 HP
*etc*
If all soldiers are dead you Lose.
Code:
#include <ctime>
#include <cstdlib>
#include <iostream>
using namespace std;
int main(){
int vida1 = 3;
int vida2 = 3;
int amigo1 = 2;
int amigo2 = 2;
int amigo3 = 2;
int enemy1 = 2;
int enemy2 = 2;
int enemy3 = 2;
int map1[ 10 ] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
int map2[ 10 ] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
int map3[ 10 ] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
int hit1;
time_t t;
time(&t);
srand(t);
int warrior1;
int warrior2;
int warrior3;
int gameover = 2;
cout << "----------------------------" << endl;
cout << "| Welcome To WarriorKiller |" << endl;
cout << "----------------------------" << endl;
cout << "Choose Position Of Warrior 1 -> ";
cin >> warrior1;
cout << "Choose Position Of Warrior 2 -> ";
cin >> warrior2;
cout << "Choose Position Of Warrior 3 -> ";
cin >> warrior3;
map1[warrior1-1] = warrior1;
map2[warrior2-1] = warrior2;
map3[warrior3-1] = warrior3;
cout << "----------------------------" << endl;
cout << "| Warrior Board |" << endl;
cout << "----------------------------" << endl;
cout << "------------------------------" << endl;
for (int i=0;i<10;++i){
cout << "|" << map1[i] << "|";
}
cout << endl;
for (int y=0;y<10;++y){
cout << "|" << map2[y]<< "|";
}
cout << endl;
for (int x=0;x<10;++x){
cout << "|" << map3[x]<< "|";
}
cout << endl;
cout << "------------------------------" << endl;
do{
int hit2 = rand() % 9 + 1;
int warrior1x = rand() % 9 + 1;
int warrior2x = rand() % 9 + 1;
int warrior3x = rand() % 9 + 1;
cout << "----------------------------" << endl;
cout << "| ! Attacking Time ! |" << endl;
cout << "----------------------------" << endl;
cout << "Select Number To Attack (0 - 9) -> ";
cin >> hit1;
if (hit1 == warrior1x){
cout << "You Attacked Enemy Warrior 1 !" << endl;
--enemy1;
} else if (hit1 == warrior2x) {
cout << "You Attacked Enemy Warrior 2 !" << endl;
--enemy2;
}else if (hit1 == warrior3x) {
cout << "You Attacked Enemy Warrior 3 !" << endl;
--enemy3;
}else {
cout << "You Miss !" << endl;
}
cout << "Enemy Attacks -> ";
cout << hit2 << endl;
if (hit2 == warrior1){
cout << "Enemy Attacked Warrior 1 !" << endl;
--amigo1;
}else if (hit2 == warrior2){
cout << "Enemy Attacked Warrior 2 !" << endl;
--amigo2;
}else if (hit2 == warrior3){
cout << "Enemy Attacked Warrior 3 !" << endl;
--amigo3;
} else {
cout << "Enemy Miss !" << endl;
}
if (amigo1 == 0){
--vida1;
}else if ( amigo2 == 0){
--vida1;
}else if (amigo3 == 0){
--vida1;
}
if (enemy1 == 0){
--vida2;
}else if (enemy2 == 0){
--vida2;
}else if (enemy3 == 0){
--vida2;
}
if (vida1 == 0){
gameover = 1;
}else if (vida2 == 0){
gameover = 1;
}
}while(gameover == 2);
cout << "GAME OVER" << endl;
system("PAUSE");
}
Any tip to improve code will be accepted ;D