Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- #include <Windows.h>
- #include "posdots.h"
- #include "random.h"
- using namespace std;
- int dest = 0, life = 100, food = 100, gas = 100, war = 100, koef = 1;
- void game();
- void fight();
- void anim();
- void loot();
- // STARTING MENU
- void main(){
- int i(1);
- char userChose, arrow[20]{};
- do {
- system("cls");
- cout << "\t\t\t\t" << "Where do you want to go?\n\n\n\n\n" << endl;
- cout << "\t\t\t\t" << arrow[1] << "1.Vynnyky;(EASY)" << endl;
- cout << "\t\t\t\t" << arrow[2] << "2.Lviv;(MEDIUM)" << endl;
- cout << "\t\t\t\t" << arrow[3] << "3.Sokilnyky; (HARD)" << endl;
- userChose = _getch();
- if (userChose == 's'&& i != 4){ arrow[i] = '>'; arrow[i - 1] = ' '; i++; }// Система керування меню
- else if (userChose == 's') { arrow[3] = ' '; i = 1; arrow[i] = '>'; i++; }
- }
- while (userChose != 'f');
- dest = i-1;
- system("cls");
- switch (dest){
- case 1: {cout << "\n\n\n\n\n\t\t\t\t\t\tLET'S GO INTO VYNNYKY!" << endl; Sleep(1500); } break;
- case 2: {cout << "\n\n\n\n\n\t\t\t\t\t\tLET'S GO INTO LVIV!" << endl; Sleep(1500); } break;
- case 3: {cout << "\n\n\n\n\n\t\t\t\t\t\tLET'S GO INTO SOKILNYKY!" << endl; Sleep(1500); } break;
- default: cout << "ERROR!" << endl;
- }
- game();
- }
- /* User interface;*/
- void game()
- {
- char play;
- for (int p(0); p < (dest + 1) * 10; p++){
- system("cls");
- int lostgas = 15, lostfood = random(10, 20);
- if (p != 0){
- if (gas - lostgas > 0){ gas = gas - lostgas; }
- else if (gas - lostgas <= 0){ gas = 0; system("cls"); cout << "You have lost all gas!\n GAME OVER!"; exit(0); }
- if (food - lostfood > 0){ food = food - lostfood; }
- else if (food - lostfood <= 0){ food = 0; system("cls"); cout << "You have starved to death!\n GAME OVER!"; exit(0); }
- }
- cout << "xxxxxxxxxxxxxxxxxxx" << endl;
- cout << "x life:" << life << " x" << endl;
- cout << "x food:" << food << " x" << endl;
- cout << "x gas:" << gas << " x" << endl;
- cout << "x war:" << war << " x" << endl;
- cout << "xxxxxxxxxxxxxxxxxxx" << endl; /* END OF INTERFACE*/
- anim();// driving the road
- cout << "\n\n\n\n\n\t\t\t\t\t\tYou have lost: " << lostgas << " gas and: " << lostfood << " food";
- play = getch();
- fight();
- }
- }
- // анімація їзди, на половині - запускається ф-ія loot();
- void anim(){
- char f[]{" "};
- for (int k(0); k <= strlen(f); k++){
- cout << f[k]; cout << " .--." << endl; if (k > 0) { curs({ 0 + k, 7 }); }
- cout << f[k]; cout << " .----' '--." << endl; if (k > 0) { curs({ 0 + k, 8 }); }
- cout << f[k]; cout <<" '-()-----()-'" << endl; if (k > 0) { curs({ 0 + k, 9 }); }
- Sleep(25);
- curs({ 0+k, 6 });
- if (k == strlen(f) / 2){
- loot(); system("cls");
- cout << "xxxxxxxxxxxxxxxxxxx" << endl;
- cout << "x life:" << life << " x" << endl;
- cout << "x food:" << food << " x" << endl;
- cout << "x gas:" << gas << " x" << endl;
- cout << "x war:" << war << " x" << endl;
- cout << "xxxxxxxxxxxxxxxxxxx" << endl;
- k = 58; }
- }
- }
- // Питає шо шукати, знаходить ранд число. Використовує функцію анімації dots();
- void loot(){
- int i(1), randloot(0);
- char userChose, arrow[20]{};
- do {
- system("cls");
- cout << "xxxxxxxxxxxxxxxxxxx" << endl;
- cout << "x life:" << life << " x" << endl;
- cout << "x food:" << food << " x" << endl;
- cout << "x gas:" << gas << " x" << endl;
- cout << "x war:" << war << " x" << endl;
- cout << "xxxxxxxxxxxxxxxxxxx" << endl;
- cout << "\t\t\t\t" << "What do you want to find?\n\n\n\n\n" << endl;
- cout << "\t\t\t\t" << arrow[1] << "1.Bullets" << endl;
- cout << "\t\t\t\t" << arrow[2] << "2.Aids" << endl;
- cout << "\t\t\t\t" << arrow[3] << "3.Gas" << endl;
- cout << "\t\t\t\t" << arrow[4] << "4.Food" << endl;
- userChose = _getch();
- if (userChose == 's'&& i != 5){ arrow[i] = '>'; arrow[i - 1] = ' '; i++; }
- else if (userChose == 's') { arrow[4] = ' '; i = 1; arrow[i] = '>'; i++; }
- } while (userChose != 'f');
- i--;
- printf("\n");
- switch (i){
- case 1: {cout << "Looking for Bullets"; dots(5, 19, 17); randloot = random(10, (60 / dest)*koef); cout << "You found " << randloot << " Bullets"; if (war + randloot > 100){ war = 100; }
- else { war += randloot; } Sleep(500); randloot = 0; } break;
- case 2: {cout << "Looking for Aids"; dots(10, 16, 17); randloot = random(5, (30 / dest)*koef); cout << "You found " << randloot << " Aids"; if (life + randloot > 100){ life = 100; }
- else { life += randloot; } Sleep(500); randloot = 0; } break;
- case 3: {cout << "Looking for Gas"; dots(1, 15, 17); randloot = random(10, (60 / dest)*koef); cout << "You found " << randloot << " Gas"; if (gas + randloot > 100){ gas = 100; }
- else { gas += randloot; } Sleep(500); randloot = 0; } break;
- case 4: {cout << "Looking for Food"; dots(7, 16, 17); randloot = random(10, 40 * koef); cout << "You found " << randloot << " Food"; if (food + randloot > 100){ food = 100; }
- else { food += randloot; } Sleep(500); randloot = 0;} break;
- }
- }
- void fight(){
- int enemyType(0), winrounds(0), yScore(0), eScore(0), fighttype(0), i(1);
- char userChose, arrow[20]{}; //0 - zombies, 1 - humans;
- enemyType = random(0, 1);
- do {
- system("cls");
- cout << "\t\t\t\t" << "What type of fight do you prefer?\n\n\n\n\n" << endl;
- cout << "\t\t\t\t" << arrow[1] << "1.Passive (Nothing changes)" << endl;
- cout << "\t\t\t\t" << arrow[2] << "2.Aggressive (full gas, if you win atleast 2 rounds!)" << endl;
- cout << "\t\t\t\t" << arrow[3] << "3.Stealth (full life, if you win atleast 2 rounds!" << endl;
- userChose = _getch();
- if (userChose == 's'&& i != 4){ arrow[i] = '>'; arrow[i - 1] = ' '; i++; }// Система керування меню
- else if (userChose == 's') { arrow[3] = ' '; i = 1; arrow[i] = '>'; i++; }
- } while (userChose != 'f');
- fighttype = i - 1;
- if (enemyType == 0){//humans
- cout << "FIGHT AGAINST HUMANS!" << endl; Sleep(200);
- for (int i(0); i <= 2; i++){
- int extraloot = random(10, 30);
- yScore = random(0, 10) - (2 * fighttype); if (yScore < 0) yScore = 0;
- eScore = random(0, 10) - (1 * koef); if (eScore < 0) eScore = 0;
- if (yScore > eScore){ winrounds += 1; cout << "You have won round!" << endl; Sleep(1400); }
- else if (yScore < eScore) { cout << "You have loose round! You have lost:" << extraloot << " life" << endl; Sleep(1400); if (life - extraloot <= 0){ life = 0; } else life -= extraloot; }
- else if (yScore == eScore) { cout << "DRAW! You have found extra loot:" << extraloot << "bullets!" << endl; Sleep(1400); if (war + extraloot >= 100){ war = 100; } else war += extraloot; }
- }
- }
- else {//zombies
- cout << "FIGHT AGAINST ZOMBIES!" << endl; Sleep(200);
- for (int i(0); i <= 2; i++){
- int extraloot = random(10, 20);
- yScore = random(0, 10) - (2 * dest); if (yScore < 0) yScore = 0;
- eScore = random(0, 10) - (1 * koef); if (eScore < 0) eScore = 0;
- if (yScore > eScore){ winrounds += 1; cout << "You have won round!" << endl; Sleep(1400); }
- else if (yScore < eScore) { cout << "You have loose round! You have lost:" << extraloot << " life" << endl; Sleep(1400); if ((life - extraloot) <= 0){ life = 0; } else life = life - extraloot; }
- else if (yScore == eScore) {cout << "DRAW! You have found extra loot:" << extraloot << "bullets!" << endl; Sleep(1400); if (war + extraloot >= 100){ war = 100; } else war += extraloot; }
- }
- }
- if (fighttype == 2 && winrounds >= 2){ cout << "You have won 2 rounds! Full gas!" << endl; gas = 100; winrounds = 0; }
- else if (fighttype == 3 && winrounds >= 2){ cout << "You have won 2 rounds! Full Health!" << endl; life = 100; winrounds; }
- if (life == 0){ cout << "GAME OVER!" << endl; exit(0); }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement