Repository navigation
Expand file tree
/
Copy pathprinter.cpp
More file actions
48 lines (43 loc) · 1.5 KB
/
Copy pathprinter.cpp
File metadata and controls
48 lines (43 loc) · 1.5 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
#include "printer.hpp"
#include "moveLogic.hpp"
#include <fstream>
void printGameMenu(Gameplan& playground,Character& kong){
std::array<std::string,4> moves={
"| [W] up |",
"| [S] down |",
"| [A] left |",
"| [D] right |"};
std::array<bool,4> canMove=moveLogic(playground,kong);
std::cout << "Make a move: (Press a key)\n" <<
(canMove[0] ? moves[0] : "") <<
(canMove[1] ? moves[1] : "") <<
(canMove[2] ? moves[2] : "") <<
(canMove[3] ? moves[3] : "") <<
std::endl;
}
void printPlayground(Gameplan& playground, Character& kong){
std::vector<std::vector<char> > map= playground.getPlayground();
std::vector<std::vector<char> > currentPlayground=map;
std::array<int,2> pos=kong.getPosition();
char donkey=kong.getSymbol();
std::string color=kong.getColor();
if(pos.at(0)!=0) {
currentPlayground[static_cast<size_t>(pos.at(0))][static_cast<size_t>(pos.at(1))]=donkey;
}
for(size_t i=0;i<map.size();i++){
for(size_t j=0;j<map[i].size();j++){
char sign=currentPlayground[i][j];
std::cout << (
(sign==donkey && donkey!=' ') ? color : "" )
<< sign << "\033[1;0m";
}
std::cout << std::endl;
}
}
void printPicture(std::string file){
Gameplan pic;
std::ifstream motiv(file);
pic.read(motiv);
Character invisible(' ', {0,0}, " ");
printPlayground(pic, invisible);
}