-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathiceCreamDisplay.cc
More file actions
53 lines (43 loc) · 1.59 KB
/
iceCreamDisplay.cc
File metadata and controls
53 lines (43 loc) · 1.59 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
#include "iceCreamDisplay.h"
#include "gameDisplay.h"
#include "borderDisplay.h"
#include "statusDisplay.h"
#include <memory>
#include <string>
#include <ncurses.h>
IceCreamDisplay::IceCreamDisplay(): display_border{make_shared<BorderDisplay>()},
display_status{make_shared<StatusDisplay>()}, display_objects{make_shared<GameDisplay>()} {}
void IceCreamDisplay::render() {
display_border->display();
display_objects->display();
display_status->display();
refresh();
}
void IceCreamDisplay::updateStatus(vector<string> messages) {
display_status->setMessages(messages);
}
vector<string> IceCreamDisplay::getStatus() {
return display_status->getMessages();
}
void IceCreamDisplay::updateObjects(vector<shared_ptr<GameObject>> objects) {
display_objects->setObjects(objects);
}
void IceCreamDisplay::vanishUpdate(int numOfPlatformsPassed) {
string platformMessage = "You passed " + to_string(numOfPlatformsPassed) + " platforms";
updateHelper("You disintegrated!", "Tough run.", platformMessage);
}
void IceCreamDisplay::hitFlyUpdate(int numOfPlatformsPassed) {
string platformMessage = "You passed " + to_string(numOfPlatformsPassed) + " platforms";
updateHelper("You hit a fly!", "Tough run.", platformMessage);
}
void IceCreamDisplay::inProgress() {
updateHelper("Game in progress.", "Keep going!", "");
}
void IceCreamDisplay::updateHelper(string msg1, string msg2, string msg3) {
vector<string> messages = getStatus();
messages.clear();
messages.push_back(msg1);
messages.push_back(msg2);
messages.push_back(msg3);
updateStatus(messages);
}