Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Players
- {
- public:
- int id;
- string name;
- int life = 100;
- int damage = 20;
- };
- int main()
- {
- int id;
- int shoot = 0;
- int reply = -1;
- string player1;
- cout << "Choose an username: ";
- cin >> player1;
- Players p1;
- p1.name = player1;
- Players p2;
- p2.name = "Naabs";
- cout << "Welcome: " << p1.name << endl << "Your heath: "<< p1.life << endl << endl;
- cout << "Starting a new game..." << endl << endl;
- cout << "You are versus : " << p2.name << endl << "His heath: " << p2.life << endl << endl;
- while(p1.life >= 0 && p2.life >= 0)
- {
- cout << "Do you want to shoot at: " << p2.name << " ? (1 or 0): ";
- cin >> reply;
- if (reply == 1 || reply == 0)
- {
- p2.life = p2.life - p1.damage;
- cout << p2.name << " has been shoot and took: " << p1.damage << " damages" << endl;
- cout << p2.life << " life left" << endl;
- }
- else
- {
- cout << "Invalide reply... Quitting";
- return 0;
- }
- }
- cout << p2.name << " is dead, good job" << endl;
- cout << p1.name << " has won";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement