nikminer4sv

Untitled

Aug 23rd, 2021 (edited)
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.62 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <windows.h>
  4. #include <thread>
  5.  
  6. using namespace std;
  7.  
  8. class Variables {
  9. public:
  10.  
  11.     float Money = 0;
  12.     float MoneyForClick = 1;
  13.     float MoneyPerSecond = 1;
  14.  
  15.     float UpgradeMultiplicator = 2;
  16.     float AutoclickerUpgradeMultiplicator = 1.5;
  17.     float UpgradeLevel = 0;
  18.     float UpgradeCost = 10;
  19.     float AutoclickerUpgradeLevel = 0;
  20.     float AutoclickerUpgradeCost = 10;
  21.  
  22.     bool GameIsFinished = false;
  23.  
  24.     void ShowGameData() {
  25.  
  26.         system("cls");
  27.         cout << "------------------------------------------------" << endl;
  28.         cout << "Money: " << Money << endl;
  29.         cout << "------------------------------------------------" << endl;
  30.         cout << "Money for click: " << MoneyForClick << endl;
  31.         cout << "Money per second: " << MoneyPerSecond << endl;
  32.         cout << "------------------------------------------------" << endl;
  33.         cout << "Upgrage level: " << UpgradeLevel << endl;
  34.         cout << "Autoclicker upgrage level: " << AutoclickerUpgradeLevel << endl;
  35.         cout << "------------------------------------------------" << endl;
  36.         cout << "Upgrage cost: " << UpgradeCost << endl;
  37.         cout << "Autoclicker upgrage cost: " << AutoclickerUpgradeCost << endl;
  38.         cout << "------------------------------------------------" << endl;
  39.         cout << endl;
  40.         cout << "Press 'u' to upgrade amount money for click" << endl;
  41.         cout << "Press 'a' to upgrade amount money per second" << endl;
  42.         cout << "Press 'l' to finish this game" << endl;
  43.  
  44.     }
  45.  
  46. };
  47.  
  48. void AutoClicking(Variables *GameVariables);
  49.  
  50. int main() {
  51.  
  52.     Variables GameVariables;
  53.  
  54.     float *Money = &GameVariables.Money;
  55.     float *MoneyForClick = &GameVariables.MoneyForClick;
  56.     float *MoneyPerSecond = &GameVariables.MoneyPerSecond;
  57.  
  58.     float *UpgradeLevel = &GameVariables.UpgradeLevel;
  59.     float *UpgradeCost = &GameVariables.UpgradeCost;
  60.     float *AutoclickerUpgradeLevel = &GameVariables.AutoclickerUpgradeLevel;
  61.     float *AutoclickerUpgradeCost = &GameVariables.AutoclickerUpgradeCost;
  62.     float *UpgradeMultiplicator = &GameVariables.UpgradeMultiplicator;
  63.     float *AutoclickerUpgradeMultiplicator = &GameVariables.AutoclickerUpgradeMultiplicator;
  64.  
  65.     thread AutoClickingTh(AutoClicking, &GameVariables);
  66.  
  67.     GameVariables.ShowGameData();
  68.     AutoClickingTh.detach();
  69.  
  70.     while (!GameVariables.GameIsFinished) {
  71.        
  72.         char Input;
  73.         Input = getche();
  74.        
  75.         switch (Input) {
  76.         case ' ':
  77.             *Money += *MoneyForClick;
  78.             break;
  79.        
  80.         case 'u':
  81.             if (*Money >= *UpgradeCost) {
  82.                 *MoneyForClick *= *UpgradeMultiplicator;
  83.                 *Money -= *UpgradeCost;
  84.                 *UpgradeLevel += 1;
  85.                 *UpgradeCost *= 2 * *UpgradeMultiplicator;
  86.             }
  87.             break;
  88.  
  89.         case 'a':
  90.             if (*Money >= *AutoclickerUpgradeCost) {
  91.                 *MoneyPerSecond *= *AutoclickerUpgradeMultiplicator;
  92.                 *Money -= *AutoclickerUpgradeCost;
  93.                 *AutoclickerUpgradeLevel += 1;
  94.                 *AutoclickerUpgradeCost *= 2 * *AutoclickerUpgradeMultiplicator;
  95.             }
  96.             break;
  97.  
  98.         case 'l':
  99.             GameVariables.GameIsFinished = true;
  100.             break;
  101.         }
  102.  
  103.         GameVariables.ShowGameData();
  104.  
  105.     }
  106.  
  107. }
  108.  
  109. void AutoClicking(Variables *GameVariables) {
  110.     while (!GameVariables->GameIsFinished) {
  111.         Sleep(1000);
  112.         GameVariables->Money += GameVariables->MoneyPerSecond;
  113.         GameVariables->ShowGameData();
  114.     }
  115. }
Add Comment
Please, Sign In to add comment