Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include <iostream>
- #include <Windows.h>
- #include <string>
- #include <cstdlib>
- #include <ctime>
- #include <vector>
- #include <string>
- #include <conio.h>
- #include <stdio.h>
- using namespace std;
- void BuyScreen(int& Damage, int& Gold, int& Health, int& Range);
- void CheckChoice(char& choice, int& Damage, int& Gold, int& Health, int& Range);
- bool Win;
- const int Zero = { 0x30 };
- const int One = { 0x31 };
- const int Two = { 0x32 };
- const int Three = { 0x33 };
- const int B = { 0x42 };
- const int W = { 0x57 };
- const int A = { 0x41 };
- const int S = { 0x53 };
- const int D = { 0x44 };
- const int U = { 0x55 };
- const int H = { 0x48 };
- const int J = { 0x4A };
- const int K = { 0x4B };
- const char Wall = '#';
- const char Ground = ' ';
- const char Goal = '?';
- const int Length = 20;
- const int Height = 20;
- char board[Height][Length] = { {'#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#'}, //0
- {'#', ' ', '#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#', ' ', ' ', ' ', ' ', '#'}, //1
- {'#', ' ', '#', ' ', '#', '#', '#', '#', ' ', '#', '#', '#', '#', ' ', '#', ' ', '#', '#', ' ', '#'}, //2
- {'#', ' ', '#', ' ', '#', ' ', ' ', ' ', ' ', '#', ' ', ' ', '#', ' ', '#', ' ', ' ', '#', ' ', '#'}, //3
- {'#', ' ', '#', ' ', '#', ' ', '#', '#', '#', '#', ' ', ' ', '#', ' ', '#', '#', '#', '#', ' ', '#'}, //4
- {'#', ' ', '#', '#', '#', ' ', '#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#'}, //5
- {'#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#', '#', '#', '#', '#', ' ', '#', '#', '#', '#', '#', '#'}, //6
- {'#', ' ', '#', '#', '#', '#', '#', ' ', '#', ' ', ' ', ' ', '#', ' ', ' ', ' ', ' ', ' ', ' ', '#'}, //7
- {'#', ' ', '#', ' ', ' ', ' ', ' ', ' ', '#', ' ', '#', ' ', '#', ' ', '#', ' ', '#', ' ', ' ', '#'}, //8
- {'#', ' ', '#', '#', '#', '#', '#', '#', '#', ' ', '#', ' ', '#', ' ', '#', ' ', '#', ' ', ' ', '#'}, //9
- {'#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#', ' ', '#', ' ', '#', ' ', ' ', ' ', ' ', '#'}, //10
- {'#', '#', '#', ' ', '#', '#', '#', '#', '#', ' ', '#', ' ', '#', ' ', '#', ' ', '#', '#', ' ', '#'}, //11
- {'#', ' ', ' ', ' ', '#', ' ', ' ', ' ', ' ', ' ', '#', ' ', '#', ' ', '#', ' ', ' ', '#', ' ', '#'}, //12
- {'#', ' ', '#', '#', '#', ' ', '#', '#', '#', ' ', '#', ' ', '#', ' ', '#', '#', ' ', '#', ' ', '#'}, //13
- {'#', ' ', '#', ' ', ' ', ' ', '#', ' ', '#', ' ', '#', ' ', '#', ' ', ' ', '#', ' ', '#', ' ', '#'}, //14
- {'#', ' ', '#', ' ', '#', ' ', '#', ' ', '#', ' ', '#', ' ', '#', '#', ' ', '#', ' ', '#', ' ', '#'}, //15
- {'#', ' ', ' ', ' ', '#', ' ', '#', ' ', '#', ' ', '#', ' ', ' ', '#', ' ', '#', ' ', '#', ' ', '#'}, //16
- {'#', ' ', '#', '#', '#', ' ', '#', ' ', '#', ' ', '#', '#', ' ', '#', '#', '#', ' ', '#', ' ', '#'}, //17
- {'#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '?', '#'}, //18
- {'#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#'}};//19
- // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
- void ShowBoard()
- {
- for (int i = 0; i < Height; i++)
- {
- for (int j = 0; j < Length; j++)
- {
- cout << board[i][j];
- }
- cout << endl;
- }
- }
- void ClearScreen()
- {
- HANDLE hStdOut;
- CONSOLE_SCREEN_BUFFER_INFO csbi;
- DWORD count;
- DWORD cellCount;
- COORD homeCoords = { 0, 0 };
- hStdOut = GetStdHandle( STD_OUTPUT_HANDLE );
- if (hStdOut == INVALID_HANDLE_VALUE)
- return;
- /* Get the number of cells in the current buffer */
- if (!GetConsoleScreenBufferInfo( hStdOut, &csbi ))
- return;
- cellCount = csbi.dwSize.X *csbi.dwSize.Y;
- /* Fill the entire buffer with spaces */
- if (!FillConsoleOutputCharacter(hStdOut, (TCHAR) ' ', cellCount, homeCoords, &count))
- return;
- /* Fill the entire buffer with the current colors and attributes */
- if (!FillConsoleOutputAttribute(hStdOut, csbi.wAttributes, cellCount, homeCoords, &count))
- return;
- /* Move the cursor home */
- SetConsoleCursorPosition( hStdOut, homeCoords );
- }
- void BuyScreen(int& Damage, int& Gold, int& Health, int& Range)
- {
- bool Invalid = true;
- bool Choosing;
- while (Invalid)
- {
- int hPotionCost = 5 * Health;
- int damageUpCost = Damage * 1000;
- int rangeUpCost = Range * 1500;
- ClearScreen();
- int BuyChoice;
- cout << "You have " << Gold << " gold and " << Health << " health.\n\n";
- cout << "What would you like to buy?\n";
- cout << "\n0 - Healing Potion - " << hPotionCost << " Gold";
- cout << "\n1 - Damage Up - " << damageUpCost << " Gold";
- cout << "\n2 - Range Up - " << rangeUpCost << " Gold";
- cout << "\n3 - Exit - 0 Gold\n\n";
- Choosing = true;
- Sleep(50);
- while (Choosing)
- {
- //Buy a healing potion
- if (GetAsyncKeyState(Zero))
- {
- BuyChoice = 0;
- Choosing = false;
- }
- //Damage Up
- if (GetAsyncKeyState(One))
- {
- BuyChoice = 1;
- Choosing = false;
- }
- //Range Up
- if (GetAsyncKeyState(Two))
- {
- BuyChoice = 2;
- Choosing = false;
- }
- //Exit
- if (GetAsyncKeyState(Three))
- {
- BuyChoice = 3;
- Choosing = false;
- }
- }
- switch (BuyChoice)
- {
- case 0:
- if (Gold < hPotionCost)
- {
- cout << "\nYou don't have enough gold for that!\n";
- Invalid = true;
- system("PAUSE");
- continue;
- }
- else
- {
- cout << "\nYou feel very refreshed!\n";
- Health += 10;
- Gold -= hPotionCost;
- system("PAUSE");
- if (Health > 100)
- Health = 100;
- break;
- }
- case 1:
- if (Gold < damageUpCost)
- {
- cout << "\nYou don't have enough gold for that!\n";
- Invalid = true;
- system("PAUSE");
- continue;
- }
- else
- {
- cout << "\nYour muscles grow!\n";
- Damage += 1;
- Gold -= damageUpCost;
- system("PAUSE");
- break;
- }
- case 2:
- if (Gold < rangeUpCost)
- {
- cout << "\nYou don't have enough gold for that!\n";
- Invalid = true;
- system("PAUSE");
- continue;
- }
- else
- {
- cout << "\nYour arms are like warm rubber!\n";
- Range += 1;
- Gold -= rangeUpCost;
- system("PAUSE");
- break;
- }
- case 3:
- cout << "\nVisit again soon!\n";
- Invalid = false;
- system("PAUSE");
- break;
- default:
- cout << "\nInvalid Choice!\n";
- system("PAUSE");
- continue;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement