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 96 97 98 99 100 101 102 103 104 105
|
#include <iostream>
#include "windows.h"
#include "math.h"
#include "time.h"
#include <string>
#include "Goblin.h"
#include "User.h"
#include "Inventory.h"
#include "Maps.h"
using namespace std;
void treasureGet();
Goblin goblinObject;
User userObject;
Inventory Io;
Maps MO;
int counter = 0;
bool gotten[20]{false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false};
int gottenCounter = 0;
bool game_running = true;
int main()
{
while(game_running == true){
//SCREEN CLEARING
system("cls");
for(int display = 0; display < 22; display++){
cout << MO.map[MO.currentMap][display] << endl;
}
//MAIN DISPLAYED INFORMATION
cout << "Money:$" << userObject.points << endl;
cout << "F1:Inventory" << endl;
cout << "Health:" << userObject.health << endl;
//PAUSE BEFORE ACTION
system("pause>nul");
//ARROW KEY ACTIONS
if(GetAsyncKeyState(VK_DOWN)){
if(MO.map[MO.currentMap][MO.y + 1][MO.x] != '#' && MO.map[MO.currentMap][MO.y + 1][MO.x] != 'D' && MO.map[MO.currentMap][MO.y + 1][MO.x] != 'G'){
MO.map[MO.currentMap][MO.y][MO.x] = ' ';
MO.y++;
MO.map[MO.currentMap][MO.y][MO.x] = '@';
}
else if(MO.map[MO.currentMap][MO.y + 1][MO.x] == 'G'){
goblinObject.goblinBattle();
userObject.lastKeyPressed = 1;
}
}
if(GetAsyncKeyState(VK_UP)){
if(MO.map[MO.currentMap][MO.y - 1][MO.x] != '#' && MO.map[MO.currentMap][MO.y - 1][MO.x] != 'D' && MO.map[MO.currentMap][MO.y - 1][MO.x] != 'G'){
MO.map[MO.currentMap][MO.y][MO.x] = ' ';
MO.y--;
MO.map[MO.currentMap][MO.y][MO.x] = '@';
}
else if(MO.map[MO.currentMap][MO.y - 1][MO.x] == 'G'){
goblinObject.goblinBattle();
userObject.lastKeyPressed = 1;
}
}
if(GetAsyncKeyState(VK_RIGHT)){
if(MO.map[MO.currentMap][MO.y][MO.x + 1] != '#' && MO.map[MO.currentMap][MO.y][MO.x + 1] != 'D' && MO.map[MO.currentMap][MO.y][MO.x + 1] != 'G'){
MO.map[MO.currentMap][MO.y][MO.x] = ' ';
MO.x++;
MO.map[MO.currentMap][MO.y][MO.x] = '@';
}
else if(MO.map[MO.currentMap][MO.y][MO.x + 1] == 'G'){
goblinObject.goblinBattle();
userObject.lastKeyPressed = 3;
}
}
if(GetAsyncKeyState(VK_LEFT)){
if(MO.map[MO.currentMap][MO.y][MO.x - 1] != '#' && MO.map[MO.currentMap][MO.y][MO.x - 1] != 'D' && MO.map[MO.currentMap][MO.y][MO.x - 1] != 'G'){
MO.map[MO.currentMap][MO.y][MO.x] = ' ';
MO.x--;
MO.map[MO.currentMap][MO.y][MO.x] = '@';
}
else if(MO.map[MO.currentMap][MO.y][MO.x - 1] == 'G'){
goblinObject.goblinBattle();
userObject.lastKeyPressed = 4;
}
}
if(GetAsyncKeyState(VK_F1)){
Io.inventoryOpen();
}
if(counter == 9 && userObject.health < 20){
counter = 0;
userObject.health++;
}
else if(counter < 9){
counter++;
}
}
return 0;
}
|