Advertisement
GoodiesHQ

Natsu

Mar 20th, 2014
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.35 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdlib.h>
  3.  
  4. #define MAX_HEALTH 500
  5. #define MAX_ATTACK 50
  6. #define MIN_ATTACK 1
  7.  
  8. using namespace std;
  9.  
  10. void startGame(){
  11.     int health, attack;
  12. begin:
  13.     cout << "Welcome!\n";
  14.     health = MAX_HEALTH;
  15.     attack = MIN_ATTACK;
  16.  
  17.     while(health>0){
  18.         cout << health << "\t- " << attack << "\t= ";
  19.         health -= attack;
  20.         cout << health << endl;
  21.         attack++;
  22.     }
  23.     cout << "You Died!\n";
  24. }
  25.  
  26. int main(){
  27.     char blue[] = "\x1b[1;34m\0";
  28.     char normal[] = "\x1b[0;39m\0";
  29.     char choice;
  30. start:
  31.     cout << blue << "#########################################" << normal << endl;
  32.     cout << blue << "#" << normal << "  Welcome to a quick battle test! :) " << blue << "\t#" <<normal << endl;
  33.     cout << blue << "#" << normal << "          20/01/2014 03:10 AM" << blue << "\t\t#" << normal << endl;
  34.     cout << blue << "#########################################" << normal << endl;
  35.  
  36. else1:
  37.     cout << "\n------ Press (S)tart or (E)xit ------" << endl;
  38.     cin >> choice;
  39.  
  40.     if (choice == 'S' || choice == 's')
  41.         startGame();
  42.     else if(choice == 'E' || choice == 'e'){
  43.         cout << "\nAre you sure you want to quit?\n(Y/N): ";
  44.         cin >> choice;
  45.  
  46.         if (choice == 'Y' || choice == 'y')
  47.             cout << "OK bye bye!" << endl;
  48.         else if (choice == 'n' || choice == 'N')
  49.             goto start;
  50.     }else{
  51.         cout << "Please choose Yes or no" << endl;
  52.         goto else1;
  53.     }
  54.     return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement