From f4fb010f30ec23968f222a648a0138a74ac86cd5 Mon Sep 17 00:00:00 2001
From: Alrik Appelfeldt <alrap417@student.liu.se>
Date: Wed, 6 Mar 2024 19:04:54 +0000
Subject: [PATCH] Upload New File

---
 Uppgift-3-Spel/main.cc | 128 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 128 insertions(+)
 create mode 100644 Uppgift-3-Spel/main.cc

diff --git a/Uppgift-3-Spel/main.cc b/Uppgift-3-Spel/main.cc
new file mode 100644
index 0000000..d9bd958
--- /dev/null
+++ b/Uppgift-3-Spel/main.cc
@@ -0,0 +1,128 @@
+#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}));
+   all_ghosts.push_back(new Blinky("red", Point{6,6}));
+    all_ghosts.push_back(new Pinky("pink", Point{7,7})) ;  
+    }
+
+    void run()
+    {
+        while(true)
+        {
+            draw_map();
+            cout << "> ";
+
+            string line {};
+            getline(cin, line);
+            istringstream iss {line};
+        
+            string command {};
+            iss >> command;
+
+            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")
+            {
+                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;
+}
-- 
GitLab