1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
//main.cpp
#include <iostream>
#include <windows.h>
#include "rtsmenu.h"
int main()
{
using namespace std;
//Treasury
int yMoney = 100;
int cMoney = 100;
//
//Units
int ySwordsmen = 0;
int cSwordsmen = 0;
int yArchers = 0;
int cArchers = 0;
int yCavalary = 0;
int cCavalary = 0;
int ySoldiers = (ySwordsmen + yArchers + yCavalary);
int cSoldiers = (cSwordsmen + cArchers + cCavalary);
//
int action;
cout << "Starting...\n";
Sleep(250);
cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
action = menu(ySwordsmen, cSwordsmen, yArchers, cArchers, yCavalary, cCavalary, yMoney, cMoney);
cout << "\n\n";
if (action == 1)
{
cout << "What units do you want to buy?\n";
}
if (action == 2)
{
if (ySoldiers == 0)
{
cout << "You can't attack!\n";
}
else
cout << "On guard!\n";
}
if (action == 3)
{
yMoney += 50;
cout << "Waiting for computer to finish...\n";
}
cin.get();
cin.get();
return 0;
}
//rtsmenu.h
#ifndef RTSMENU_H
#define RTSMENU_H
#include <iostream>
int menu(int ySwordsmen, int cSwordsmen, int yArchers, int cArchers, int yCavalary, int cCavalary, int yMoney, int cMoney)
{
using namespace std;
cout << "Your Army:\t\t\tOpposing Army:\n\n";
cout << "Swordsmen:\t" << ySwordsmen << "\t\tSwordsmen:\t" << cSwordsmen << endl;
cout << "Archers:\t" << yArchers << "\t\tArchers:\t" << cArchers << endl;
cout << "Cavalary:\t" << yCavalary << "\t\tCavalary:\t" << cCavalary << endl;
cout << "\nTreasury:\t" << yMoney << "\t\tTreasury:\t" << cMoney;
cout << "\nWould you like to buy units (1), attack enemy(2), or do nothing (3)?";
int action;
cin >> action;
while (action < 1 || action > 3)
{
cout << "Please try again\n";
cin >> action;
}
return action;
}
#endif
|