diff --git a/Uppgift-3-Spel/a.out b/Uppgift-3-Spel/a.out new file mode 100755 index 0000000000000000000000000000000000000000..a398520ed6a2db900ffaef0877675112a23b5ad4 Binary files /dev/null and b/Uppgift-3-Spel/a.out differ diff --git a/Uppgift-3-Spel/backup/a.out b/Uppgift-3-Spel/backup/a.out new file mode 100755 index 0000000000000000000000000000000000000000..e14343b95af6139cc53d893800edd60418090f72 Binary files /dev/null and b/Uppgift-3-Spel/backup/a.out differ diff --git a/Uppgift-3-Spel/backup/ghost.cc b/Uppgift-3-Spel/backup/ghost.cc new file mode 100644 index 0000000000000000000000000000000000000000..ffcc154676c7bfe2d44a30aa57e2c5446c35d992 --- /dev/null +++ b/Uppgift-3-Spel/backup/ghost.cc @@ -0,0 +1,171 @@ +#include "ghost.h" + +//ghost + +Ghost::Ghost(std::string const &color, Point const &start_pos, Pacman& pac) + : color_index(color), pos(start_pos), pacman{pac} +{} + +void Ghost::set_pos( Point new_pos) +{ + new_pos.x = pos.x; + new_pos.y = pos.y; +} + + + + +Point Ghost::get_pos() +{ + return Point{pos.x, pos.y}; +} + + + +//clyde +Clyde::Clyde(std::string const &color, Point const &start_pos, Pacman& pac) + : Ghost("orange", start_pos, pac) +{} + + +Point Clyde::get_scatter() +{ +return Point{0,0}; +} + + +Point Clyde::get_pos() +{ + return Point{pos.x, pos.y}; +} + +void Clyde::set_pos( Point new_pos) +{ +Ghost::set_pos(new_pos); +} + + + +string Clyde::get_color() const +{ +return "orange"; +} + +Point Clyde::get_chase() +{ + Point pac_dir = pacman.get_direction(); + Point pac_pos = pacman.get_position(); + int proximity = abs(pos.x - pac_pos.x) + abs(pos.y - pac_pos.y); + + if (proximity >= 2) + { + return pac_pos; + } + else + { + return Point{0,0}; + } + + +} + +//pinky + +Pinky::Pinky(std::string const &color, Point const &start_pos, Pacman& pac): +Ghost("pink", start_pos, pac) +{} + + +Point Pinky::get_scatter() +{ +return Point{0,21}; +} + + +Point Pinky::get_pos() +{ +return Point{pos.x, pos.y}; +} + +void Pinky::set_pos( Point new_pos) +{ +Ghost::set_pos(new_pos); +} + + + +string Pinky::get_color() const +{ +return "pink"; +} +Point Pinky::get_chase() +{ + + Point pac_dir {pacman.get_direction()}; + Point pac_pos {pacman.get_position()}; + + if(pac_dir.x == 0 && pac_dir.y == -1) + { + pac_pos.y = (pac_pos.y - 2); + } + else if(pac_dir.x == 0 && pac_dir.y == 1) + { + pac_pos.y = (pac_pos.y + 2); + +} + else if(pac_dir.x == -1 && pac_dir.y == 0) + { + pac_pos.x = (pac_pos.x -2 ); + + } + else if(pac_dir.x == 1 && pac_dir.y == 0) + { + pac_pos.x = (pac_pos.x -2); + + + } + return pac_pos; +} + +//blinky +Blinky::Blinky(std::string const &color, Point const &start_pos, Pacman& pac) + : Ghost("red", start_pos, pac) + {} + +void Blinky::set_pos(Point new_pos) { + set_pos(new_pos); +} + +Point Blinky::get_scatter() { + if (angry == true) + { + return Point{pacman.get_position()}; // stämmer? + } else + { + return Point{6, 6}; + } +} + +Point Blinky::get_chase() { + return Point{pacman.get_position()}; +} + +Point Blinky::get_pos() { + return pos; +} + +std::string Blinky::get_color()const +{ + return "pink"; +} + +bool Blinky::get_angry(){ + return angry; +} + +void Blinky::set_angry(bool state) { + angry = state; +} + + + diff --git a/Uppgift-3-Spel/backup/ghost.h b/Uppgift-3-Spel/backup/ghost.h new file mode 100644 index 0000000000000000000000000000000000000000..2dd23626afd7ba68398b0b85966c979deaf1d546 --- /dev/null +++ b/Uppgift-3-Spel/backup/ghost.h @@ -0,0 +1,61 @@ +#ifndef GHOST_H +#define GHOST_H + +#include "given.h" +#include "string" +using namespace std; + +class Ghost +{ +public: + Ghost(std::string const &color, Point const &start_pos, Pacman& pac); + virtual void set_pos( Point new_pos); + virtual Point get_scatter() = 0; + virtual Point get_chase() = 0; + virtual Point get_pos(); + virtual std::string get_color()const = 0; + virtual ~Ghost() = default; +protected: + std::string color_index; + Point pos; + Pacman& pacman; +}; + +class Clyde: public Ghost +{ +public: + Clyde(std::string const &color, Point const &start_pos, Pacman& pac); + void set_pos(Point new_pos) override; + Point get_scatter() override ; + Point get_chase() override ; + Point get_pos() override; + std::string get_color()const; +}; + +class Pinky: public Ghost +{ +public: + Pinky(std::string const &color, Point const &start_pos, Pacman& pac); + void set_pos(Point new_pos)override; + Point get_scatter() override; + Point get_chase() override ; + Point get_pos()override; + std::string get_color()const; +}; + +class Blinky : public Ghost +{ +public: + bool get_angry(); + void set_angry(bool state); + Blinky(std::string const &color, Point const &start_pos, Pacman& pac); + void set_pos(Point new_pos)override; + Point get_scatter() override; + Point get_chase() override; // Blinky::get_chase(const Point&)’ marked ‘override’, but does not override + Point get_pos()override; + std::string get_color()const; +private: + bool angry = false ; +}; + +#endif \ No newline at end of file diff --git a/Uppgift-3-Spel/backup/given.cc b/Uppgift-3-Spel/backup/given.cc new file mode 100644 index 0000000000000000000000000000000000000000..154bfe8f81b4c120c571f60e7e97b3480c0d1f87 --- /dev/null +++ b/Uppgift-3-Spel/backup/given.cc @@ -0,0 +1,46 @@ +#include "given.h" + +int WIDTH = 19; +int HEIGHT = 22; + +bool operator==(Point const& lhs, Point const& rhs) +{ + return lhs.x == rhs.x && lhs.y == rhs.y; +} + +std::istream& operator>>(std::istream& is, Point& rhs) +{ + return is >> rhs.x >> rhs.y; +} + +Pacman::Pacman() + : pos {}, dir {1,0} +{} + +Point Pacman::get_position() const +{ + return pos; +} + +void Pacman::set_position(Point const& p) +{ + if (p.x > WIDTH or p.x < 0 or p.y > HEIGHT or p.y < 0) + { + throw std::runtime_error("position outside valid range"); + } + pos = p; +} + +Point Pacman::get_direction() const +{ + return dir; +} + +void Pacman::set_direction(Point const& p) +{ + if (p.x > 1 or p.x < -1 or p.y > 1 or p.y < -1 or abs(p.x + p.y) != 1) + { + throw std::runtime_error("direction outside valid range"); + } + dir = p; +} diff --git a/Uppgift-3-Spel/backup/given.h b/Uppgift-3-Spel/backup/given.h new file mode 100644 index 0000000000000000000000000000000000000000..92b57b82966db209d7c3b0d63a7344dfe33a4fd1 --- /dev/null +++ b/Uppgift-3-Spel/backup/given.h @@ -0,0 +1,60 @@ +/* + I denna fil finns ett utval av kod fr�n det dina kollegor skrivit till ert pacman-projekt. Det �r + precis det som du beh�ver f�r att skriva din del av koden. + + Tips: Du f�r ut�ka denna fil med saker som du beh�ver f�r att ditt program ska kompilera. Det �r + �ven okej att ut�ka Point med fler operatorer om det skulle beh�vas. + */ + + +#include <stdexcept> +#include <iostream> + + +/* + Globala variabler f�r storlek p� spelplanen. + + Din kollega som skrev detta �r medveten om att globala variabler �r d�ligt och borde undvikas, men + har inte haft tid att �tg�rda det. I den slutgiltiga versionen av koden borde dessa s�klart l�sas + fr�n en fil med konfigurationsdata. + */ +extern int WIDTH; +extern int HEIGHT; + + +/* + Ett aggregat som anv�nd f�r att representera punkter och riktninar p� spelplanen. + Aggregatet har ocks� hj�lpsamma operatorer som kan underl�tta din implementation. + + */ +struct Point +{ + int x; + int y; +}; +bool operator==(Point const& lhs, Point const& rhs); +std::istream& operator>>(std::istream& is, Point& rhs); + + +/* + En klass f�r att representera spelarfiguren. Detta �r en nedskalad version j�mf�rt med det som + kollegan skrev till spelet. Notera att din kod inte beh�ver �ndras om man skulle g� fr�n denna + implementaion till den faktiska implementationen. + */ +class Pacman +{ +public: + + Pacman(); + + Point get_position() const; + void set_position(Point const& p); + + Point get_direction() const; + void set_direction(Point const& p); + +private: + + Point pos {}; + Point dir {}; +}; diff --git a/Uppgift-3-Spel/backup/main.cc b/Uppgift-3-Spel/backup/main.cc new file mode 100644 index 0000000000000000000000000000000000000000..bbfa9277c5ef66a1ae0e1c4ac44046d63bc52015 --- /dev/null +++ b/Uppgift-3-Spel/backup/main.cc @@ -0,0 +1,158 @@ +#include "ghost.h" +//#include "given.h" +#include <string> +#include <iostream> +#include <iomanip> +#include <sstream> +#include <vector> +#include <cctype> + +using namespace std; + +/* + Ledning och Tips: + + - Modifiera stukturen till en header-fil och en implementationsfil + - Ut�ka 'run()' och 'draw_map()' med �vrig funktionalitet. + - L�gg alla sp�ken i en l�mplig beh�llare som en datamedlem. + - Bryt ut stora kodblock till egna funktioner. + - Anv�nd hj�lpfunktioner f�r att undvika duplicering av kod. + - T�nk p� att varje funktion inte borde vara l�ngre �n 25 rader. + */ + +class Ghost_Tester +{ + +public: + + Pacman pacman; + vector<Ghost*> all_ghosts; + + Ghost_Tester(): + pacman {} ,all_ghosts{} + { + + all_ghosts.push_back(new Clyde("orange", Point{5,5}, pacman)); + all_ghosts.push_back(new Blinky("red", Point{6,6}, pacman)); + all_ghosts.push_back(new Pinky("pink", Point{7,7}, pacman)) ; + } + + void run() + { + while(true) + { + draw_map(); + cout << "> "; + + string line {}; + getline(cin, line); + istringstream iss {line}; + + string command {}; + iss >> command; + + for (Ghost* e : all_ghosts) + { + if (command == e -> get_color()) + { + Point new_pos {}; + iss >> new_pos.x >> new_pos.y; + e -> set_pos(new_pos); + } + else if (command == "chase") + { + e -> set_pos(e -> get_chase()); + } + else if (command == "scatter") + { + e -> set_pos(e -> get_scatter()); + } + else if (command == "anger") + { + // behöver vara blinky + if(e -> get_color() == "red") { + dynamic_cast<Blinky*>(e) -> set_angry(true); + } + } + } + + if (command == "pos") + { + Point new_pos {}; + iss >> new_pos.x >> new_pos.y; + pacman.set_position(new_pos); + } + else if (command == "dir") + { + } + else if (command == "quit") + { + for (Ghost* e : all_ghosts) + { + delete e; + } + + break; + } + } + } + + + + + + //fixa följande funltion +private: + + /* + En hj�lpfunktion som avg�r vilka tv� tecken som ska ritas ut f�r en given position p� + spelplanen. + */ + string to_draw(Point const& curr_pos) + { + string to_draw{" "}; + + if (pacman.get_position() == curr_pos) + { + to_draw[1] = '@'; + } + + return to_draw; + } + + /* + En hj�lpfunktion f�r att rita ut spelplanen f�r testprogrammet. + + Itererar �ver varje rad och column i kartan. Index f�r raderna �r flippade f�r att placera + y = 0 l�ngst ned. + + Varje punkt i kartan ritas som tv� tecken eftersom ett tecken i terminalen �r ca dubbelt s� + h�gt som det �r brett. + */ + void draw_map() + { + cout << "+" << setfill('-') << setw(WIDTH * 2) << "-" << "+\n"; + + for (int y {HEIGHT - 1}; y >= 0; --y) + { + cout << "|"; + for (int x {}; x < WIDTH; ++x) + { + cout << to_draw( Point{x,y} ); + } + cout << "|\n"; + } + + cout << "+" << setfill('-') << setw(WIDTH * 2) << "-" << "+" << endl; + } + + + +}; + +int main() +{ + Ghost_Tester gt {}; + gt.run(); + return 0; +} diff --git a/Uppgift-3-Spel/ghost.cc b/Uppgift-3-Spel/ghost.cc new file mode 100644 index 0000000000000000000000000000000000000000..ffcc154676c7bfe2d44a30aa57e2c5446c35d992 --- /dev/null +++ b/Uppgift-3-Spel/ghost.cc @@ -0,0 +1,171 @@ +#include "ghost.h" + +//ghost + +Ghost::Ghost(std::string const &color, Point const &start_pos, Pacman& pac) + : color_index(color), pos(start_pos), pacman{pac} +{} + +void Ghost::set_pos( Point new_pos) +{ + new_pos.x = pos.x; + new_pos.y = pos.y; +} + + + + +Point Ghost::get_pos() +{ + return Point{pos.x, pos.y}; +} + + + +//clyde +Clyde::Clyde(std::string const &color, Point const &start_pos, Pacman& pac) + : Ghost("orange", start_pos, pac) +{} + + +Point Clyde::get_scatter() +{ +return Point{0,0}; +} + + +Point Clyde::get_pos() +{ + return Point{pos.x, pos.y}; +} + +void Clyde::set_pos( Point new_pos) +{ +Ghost::set_pos(new_pos); +} + + + +string Clyde::get_color() const +{ +return "orange"; +} + +Point Clyde::get_chase() +{ + Point pac_dir = pacman.get_direction(); + Point pac_pos = pacman.get_position(); + int proximity = abs(pos.x - pac_pos.x) + abs(pos.y - pac_pos.y); + + if (proximity >= 2) + { + return pac_pos; + } + else + { + return Point{0,0}; + } + + +} + +//pinky + +Pinky::Pinky(std::string const &color, Point const &start_pos, Pacman& pac): +Ghost("pink", start_pos, pac) +{} + + +Point Pinky::get_scatter() +{ +return Point{0,21}; +} + + +Point Pinky::get_pos() +{ +return Point{pos.x, pos.y}; +} + +void Pinky::set_pos( Point new_pos) +{ +Ghost::set_pos(new_pos); +} + + + +string Pinky::get_color() const +{ +return "pink"; +} +Point Pinky::get_chase() +{ + + Point pac_dir {pacman.get_direction()}; + Point pac_pos {pacman.get_position()}; + + if(pac_dir.x == 0 && pac_dir.y == -1) + { + pac_pos.y = (pac_pos.y - 2); + } + else if(pac_dir.x == 0 && pac_dir.y == 1) + { + pac_pos.y = (pac_pos.y + 2); + +} + else if(pac_dir.x == -1 && pac_dir.y == 0) + { + pac_pos.x = (pac_pos.x -2 ); + + } + else if(pac_dir.x == 1 && pac_dir.y == 0) + { + pac_pos.x = (pac_pos.x -2); + + + } + return pac_pos; +} + +//blinky +Blinky::Blinky(std::string const &color, Point const &start_pos, Pacman& pac) + : Ghost("red", start_pos, pac) + {} + +void Blinky::set_pos(Point new_pos) { + set_pos(new_pos); +} + +Point Blinky::get_scatter() { + if (angry == true) + { + return Point{pacman.get_position()}; // stämmer? + } else + { + return Point{6, 6}; + } +} + +Point Blinky::get_chase() { + return Point{pacman.get_position()}; +} + +Point Blinky::get_pos() { + return pos; +} + +std::string Blinky::get_color()const +{ + return "pink"; +} + +bool Blinky::get_angry(){ + return angry; +} + +void Blinky::set_angry(bool state) { + angry = state; +} + + + diff --git a/Uppgift-3-Spel/ghost.h b/Uppgift-3-Spel/ghost.h new file mode 100644 index 0000000000000000000000000000000000000000..2dd23626afd7ba68398b0b85966c979deaf1d546 --- /dev/null +++ b/Uppgift-3-Spel/ghost.h @@ -0,0 +1,61 @@ +#ifndef GHOST_H +#define GHOST_H + +#include "given.h" +#include "string" +using namespace std; + +class Ghost +{ +public: + Ghost(std::string const &color, Point const &start_pos, Pacman& pac); + virtual void set_pos( Point new_pos); + virtual Point get_scatter() = 0; + virtual Point get_chase() = 0; + virtual Point get_pos(); + virtual std::string get_color()const = 0; + virtual ~Ghost() = default; +protected: + std::string color_index; + Point pos; + Pacman& pacman; +}; + +class Clyde: public Ghost +{ +public: + Clyde(std::string const &color, Point const &start_pos, Pacman& pac); + void set_pos(Point new_pos) override; + Point get_scatter() override ; + Point get_chase() override ; + Point get_pos() override; + std::string get_color()const; +}; + +class Pinky: public Ghost +{ +public: + Pinky(std::string const &color, Point const &start_pos, Pacman& pac); + void set_pos(Point new_pos)override; + Point get_scatter() override; + Point get_chase() override ; + Point get_pos()override; + std::string get_color()const; +}; + +class Blinky : public Ghost +{ +public: + bool get_angry(); + void set_angry(bool state); + Blinky(std::string const &color, Point const &start_pos, Pacman& pac); + void set_pos(Point new_pos)override; + Point get_scatter() override; + Point get_chase() override; // Blinky::get_chase(const Point&)’ marked ‘override’, but does not override + Point get_pos()override; + std::string get_color()const; +private: + bool angry = false ; +}; + +#endif \ No newline at end of file diff --git a/Uppgift-3-Spel/given.cc b/Uppgift-3-Spel/given.cc new file mode 100644 index 0000000000000000000000000000000000000000..154bfe8f81b4c120c571f60e7e97b3480c0d1f87 --- /dev/null +++ b/Uppgift-3-Spel/given.cc @@ -0,0 +1,46 @@ +#include "given.h" + +int WIDTH = 19; +int HEIGHT = 22; + +bool operator==(Point const& lhs, Point const& rhs) +{ + return lhs.x == rhs.x && lhs.y == rhs.y; +} + +std::istream& operator>>(std::istream& is, Point& rhs) +{ + return is >> rhs.x >> rhs.y; +} + +Pacman::Pacman() + : pos {}, dir {1,0} +{} + +Point Pacman::get_position() const +{ + return pos; +} + +void Pacman::set_position(Point const& p) +{ + if (p.x > WIDTH or p.x < 0 or p.y > HEIGHT or p.y < 0) + { + throw std::runtime_error("position outside valid range"); + } + pos = p; +} + +Point Pacman::get_direction() const +{ + return dir; +} + +void Pacman::set_direction(Point const& p) +{ + if (p.x > 1 or p.x < -1 or p.y > 1 or p.y < -1 or abs(p.x + p.y) != 1) + { + throw std::runtime_error("direction outside valid range"); + } + dir = p; +} diff --git a/Uppgift-3-Spel/given.h b/Uppgift-3-Spel/given.h new file mode 100644 index 0000000000000000000000000000000000000000..92b57b82966db209d7c3b0d63a7344dfe33a4fd1 --- /dev/null +++ b/Uppgift-3-Spel/given.h @@ -0,0 +1,60 @@ +/* + I denna fil finns ett utval av kod fr�n det dina kollegor skrivit till ert pacman-projekt. Det �r + precis det som du beh�ver f�r att skriva din del av koden. + + Tips: Du f�r ut�ka denna fil med saker som du beh�ver f�r att ditt program ska kompilera. Det �r + �ven okej att ut�ka Point med fler operatorer om det skulle beh�vas. + */ + + +#include <stdexcept> +#include <iostream> + + +/* + Globala variabler f�r storlek p� spelplanen. + + Din kollega som skrev detta �r medveten om att globala variabler �r d�ligt och borde undvikas, men + har inte haft tid att �tg�rda det. I den slutgiltiga versionen av koden borde dessa s�klart l�sas + fr�n en fil med konfigurationsdata. + */ +extern int WIDTH; +extern int HEIGHT; + + +/* + Ett aggregat som anv�nd f�r att representera punkter och riktninar p� spelplanen. + Aggregatet har ocks� hj�lpsamma operatorer som kan underl�tta din implementation. + + */ +struct Point +{ + int x; + int y; +}; +bool operator==(Point const& lhs, Point const& rhs); +std::istream& operator>>(std::istream& is, Point& rhs); + + +/* + En klass f�r att representera spelarfiguren. Detta �r en nedskalad version j�mf�rt med det som + kollegan skrev till spelet. Notera att din kod inte beh�ver �ndras om man skulle g� fr�n denna + implementaion till den faktiska implementationen. + */ +class Pacman +{ +public: + + Pacman(); + + Point get_position() const; + void set_position(Point const& p); + + Point get_direction() const; + void set_direction(Point const& p); + +private: + + Point pos {}; + Point dir {}; +}; diff --git a/Uppgift-3-Spel/main.cc b/Uppgift-3-Spel/main.cc new file mode 100644 index 0000000000000000000000000000000000000000..b113c93550246b253659d4fbf5a0bf871533a0e7 --- /dev/null +++ b/Uppgift-3-Spel/main.cc @@ -0,0 +1,175 @@ +#include "ghost.h" +//#include "given.h" +#include <string> +#include <iostream> +#include <iomanip> +#include <sstream> +#include <vector> +#include <cctype> + +using namespace std; + +/* + Ledning och Tips: + + - Modifiera stukturen till en header-fil och en implementationsfil + - Ut�ka 'run()' och 'draw_map()' med �vrig funktionalitet. + - L�gg alla sp�ken i en l�mplig beh�llare som en datamedlem. + - Bryt ut stora kodblock till egna funktioner. + - Anv�nd hj�lpfunktioner f�r att undvika duplicering av kod. + - T�nk p� att varje funktion inte borde vara l�ngre �n 25 rader. + */ + +class Ghost_Tester +{ + +public: + + Pacman pacman; + vector<Ghost*> all_ghosts; + + Ghost_Tester(): + pacman {} ,all_ghosts{} + { + + all_ghosts.push_back(new Clyde("orange", Point{5,5}, pacman)); + all_ghosts.push_back(new Blinky("red", Point{6,6}, pacman)); + all_ghosts.push_back(new Pinky("pink", Point{7,7}, pacman)) ; + } + + void run() + { + while(true) + { + draw_map(); + cout << "> "; + + string line {}; + getline(cin, line); + istringstream iss {line}; + + string command {}; + iss >> command; + + for (Ghost* e : all_ghosts) + { + if (command == e -> get_color()) + { + Point new_pos {}; + iss >> new_pos.x >> new_pos.y; + e -> set_pos(new_pos); + } + else if (command == "chase") + { + e -> set_pos(e -> get_chase()); + } + else if (command == "scatter") + { + e -> set_pos(e -> get_scatter()); + } + else if (command == "anger") + { + // behöver vara blinky + if(e -> get_color() == "red") { + dynamic_cast<Blinky*>(e) -> set_angry(true); + } + } + } + + if (command == "pos") + { + Point new_pos {}; + iss >> new_pos.x >> new_pos.y; + pacman.set_position(new_pos); + } + else if (command == "dir") + { + } + else if (command == "quit") + { + for (Ghost* e : all_ghosts) + { + delete e; + } + + break; + } + } + } + + + + + + //fixa följande funltion +private: + + /* + En hj�lpfunktion som avg�r vilka tv� tecken som ska ritas ut f�r en given position p� + spelplanen. + */ + + Point pacmanPosition = pacman.get_position(); + Point pacmanDirection = pacman.get_direction(); + + string to_draw(Point const& curr_pos) + { + string to_draw{" "}; + + if (pacman.get_position() == curr_pos) + { + to_draw[1] = '@'; + } + for (Ghost* temp : all_ghosts) + { + char r {temp -> get_color().at(0)}; + + if(temp -> get_chase() == curr_pos) + { + to_draw[1] = r; + } + if(temp -> get_pos() == curr_pos) + { + to_draw[1] = toupper(r); + } + } + + return to_draw; + } + + /* + En hj�lpfunktion f�r att rita ut spelplanen f�r testprogrammet. + + Itererar �ver varje rad och column i kartan. Index f�r raderna �r flippade f�r att placera + y = 0 l�ngst ned. + + Varje punkt i kartan ritas som tv� tecken eftersom ett tecken i terminalen �r ca dubbelt s� + h�gt som det �r brett. + */ + void draw_map() + { + cout << "+" << setfill('-') << setw(WIDTH * 2) << "-" << "+\n"; + + for (int y {HEIGHT - 1}; y >= 0; --y) + { + cout << "|"; + for (int x {}; x < WIDTH; ++x) + { + cout << to_draw( Point{x,y} ); + } + cout << "|\n"; + } + + cout << "+" << setfill('-') << setw(WIDTH * 2) << "-" << "+" << endl; + } + + + +}; + +int main() +{ + Ghost_Tester gt {}; + gt.run(); + return 0; +}