diff options
-rw-r--r-- | inc/Character.hpp | 2 | ||||
-rw-r--r-- | inc/Frame.hpp | 14 | ||||
-rw-r--r-- | inc/Screen.hpp | 4 | ||||
-rw-r--r-- | src/Character.cpp | 9 | ||||
-rw-r--r-- | src/Frame.cpp | 59 | ||||
-rw-r--r-- | src/Screen.cpp | 10 | ||||
-rw-r--r-- | src/main.cpp | 21 |
7 files changed, 30 insertions, 89 deletions
diff --git a/inc/Character.hpp b/inc/Character.hpp index 607e8ea..3111154 100644 --- a/inc/Character.hpp +++ b/inc/Character.hpp @@ -12,7 +12,7 @@ class Character { public: Character(char nSymbol, int nColor, Location L); - void move(Location L){l.x=L.x;l.y=L.y;} + void move(Location L){l=L;} void draw(WINDOW * w); Location action(vector <Location> occupied); bool check(Location L, vector <Location> occupied); diff --git a/inc/Frame.hpp b/inc/Frame.hpp index cc87090..4e4b57f 100644 --- a/inc/Frame.hpp +++ b/inc/Frame.hpp @@ -16,13 +16,13 @@ class Frame Frame(string location, int nRow, int nCol); // main window with seeded map Frame(Frame &super, int rows, int cols, int nRow, int nCol); // viewport ~Frame(); - WINDOW * getWin(); - WINDOW * getSuper(); - bool getHasSuper(); - int getHeight(); - int getWidth(); - int getRow(); - int getCol(); + WINDOW * getWin(){return w;} + WINDOW * getSuper(){return super;} + bool getHasSuper(){return hasSuper;} + int getHeight(){return height;} + int getWidth(){return width;} + int getRow(){return row;} + int getCol(){return col;} void fillWindow(); void refresh(); void move(int nRow, int nCol); diff --git a/inc/Screen.hpp b/inc/Screen.hpp index 505f4e2..2108b97 100644 --- a/inc/Screen.hpp +++ b/inc/Screen.hpp @@ -12,8 +12,8 @@ class Screen Screen(); ~Screen(); void ping(string msg); - int getHeight(); - int getWidth(); + int getHeight(){return height;} + int getWidth(){return width;} private: int height, width; }; diff --git a/src/Character.cpp b/src/Character.cpp index 423a342..8b4a4b5 100644 --- a/src/Character.cpp +++ b/src/Character.cpp @@ -64,8 +64,6 @@ Location Character::action(vector <Location> occupied) Lo = l; } - //move(Lo); - if(check(Lo,occupied)) { move(Lo); @@ -78,12 +76,9 @@ Location Character::action(vector <Location> occupied) bool Character::check(Location L, vector <Location> occupied) { - for(int i = 0; i < 10; i++) - { + for(int i = 0; i < 10; i++) if(L.x == occupied[i].x && L.y == occupied[i].y) - { return false; - } - } + return true; } diff --git a/src/Frame.cpp b/src/Frame.cpp index a8403b7..c63aeb4 100644 --- a/src/Frame.cpp +++ b/src/Frame.cpp @@ -44,27 +44,7 @@ Frame::~Frame() { delwin(w); } -/* -void Frame::add(Character &c) -{ - mvwaddch(w,c.getRow(),c.getCol(),c.getSymbol()); -} - -void Frame::erase(Character &c) -{ - mvwaddch(w,c.getRow(),c.getCol(),' '); -} -void Frame::add(Character &c, int nRow, int nCol) -{ - if((nRow >= 0 && nRow < height) && (nCol >= 0 && nCol < width)) - { - erase(c); - mvwaddch(w,nRow,nCol,c.getSymbol()); - c.move(nRow,nCol); - } -} -*/ void Frame::center(Character &ch) { if(hasSuper) @@ -148,42 +128,3 @@ void Frame::fillWindow() } wattroff(w,COLOR_PAIR(3)); } - -WINDOW * Frame::getWin() -{ - return w; -} - -WINDOW * Frame::getSuper() -{ - return super; -} - -bool Frame::getHasSuper() -{ - return hasSuper; -} - -int Frame::getHeight() -{ - return height; -} - -int Frame::getWidth() -{ - return width; -} - -int Frame::getRow() -{ - return row; -} - -int Frame::getCol() -{ - return col; -} - - - - diff --git a/src/Screen.cpp b/src/Screen.cpp index 9d0a72c..2cc5079 100644 --- a/src/Screen.cpp +++ b/src/Screen.cpp @@ -28,13 +28,3 @@ void Screen::ping(string msg) const char * cmsg = msg.c_str(); printw(cmsg); } - -int Screen::getHeight() -{ - return height; -} - -int Screen::getWidth() -{ - return width; -} diff --git a/src/main.cpp b/src/main.cpp index df5a563..022a2aa 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -16,7 +16,8 @@ int main() map.fillWindow(); L.draw(map.getWin()); cursor.draw(map.getWin()); - + + bool paused = false; while(true) { char c = getch(); @@ -31,9 +32,23 @@ int main() l.x = l.x-1; else if (c == 'q') break; - + else if (c == 'p') + { + if (paused) + { + timeout(100); + paused = false; + } + else + { + timeout(-1); + paused = true; + } + } + cursor.move(l); - L.action(); + if (!paused) + L.action(); map.fillWindow(); L.draw(map.getWin()); cursor.draw(map.getWin()); |