-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGame.cpp
More file actions
101 lines (87 loc) · 2.91 KB
/
Game.cpp
File metadata and controls
101 lines (87 loc) · 2.91 KB
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
// Game.cpp
// Elijah Willis
#include "Game.h"
#include "Temple.h"
#include "utilities.h"
#include "Player.h"
#include <iostream>
using namespace std;
// Implement these and other Game member functions you may have added.
Game::Game(int goblinSmellDistance) {
m_temple = new Temple();
}
Game::~Game() {
delete m_temple;
}
void Game::play()
{
char input;
while (true) {
// this will help output the game onto terminal
m_temple->displayLevel();
m_temple->getMyPlayer()->displayMyStats();
m_temple->displayActions();
// Quit game if game over
if (m_temple->isTheGameOver()) {
exit(-1);
}
// Get keyboard command
input = getCharacter();
cout << endl << endl;
// Bool to determine if monsters should move
bool didPlayerMove = false;
switch(input) {
case ARROW_LEFT:
case ARROW_RIGHT:
case ARROW_UP:
case ARROW_DOWN:
// Attempt to move player in direction
clearScreen();
m_temple->getMyPlayer()->calculateAMove(input);
didPlayerMove = true;
break;
case 'g':
// Attempt to pick up object
clearScreen();
didPlayerMove = m_temple->getMyPlayer()->commitAnAction();
break;
case '>':
// Attempt to descend stairs
clearScreen();
didPlayerMove = m_temple->getMyPlayer()->commitAnActionStair();
break;
case 'i':
// Display inventory
clearScreen();
m_temple->getMyPlayer()->displayMyInventory();
didPlayerMove = m_temple->getMyPlayer()->commitAnAction();
break;
case 'w':
// Display inventory
clearScreen();
m_temple->getMyPlayer()->displayMyInventoryW();
didPlayerMove = m_temple->getMyPlayer()->commitAnAction();
break;
case 'r':
// Display inventory
clearScreen();
m_temple->getMyPlayer()->displayMyInventoryS();
didPlayerMove = m_temple->getMyPlayer()->commitAnAction();
break;
case 'q':
m_temple->getMyPlayer()->adjustTheHP(-50);
m_temple->endTheGame("");
break;
case 'c':
clearScreen();
// Cheat mode by maxing all stats
m_temple->getMyPlayer()->cheatMode();
didPlayerMove = m_temple->getMyPlayer()->commitAnAction();
break;
}
// If player made a move, move monsters
if (didPlayerMove) {
m_temple->monsterMovement();
}
}
}