From 9f0de11816fdbd0981aeaa3a840e3942fd249eb4 Mon Sep 17 00:00:00 2001 From: tom Date: Sun, 22 Nov 2015 15:21:30 -0600 Subject: cleaned up a little and added pausing, the location vector in list.*pp is overkill, should probably just be using the men vector for everything --- src/Character.cpp | 9 ++------- src/Frame.cpp | 59 ------------------------------------------------------- src/Screen.cpp | 10 ---------- src/main.cpp | 21 +++++++++++++++++--- 4 files changed, 20 insertions(+), 79 deletions(-) (limited to 'src') 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 occupied) Lo = l; } - //move(Lo); - if(check(Lo,occupied)) { move(Lo); @@ -78,12 +76,9 @@ Location Character::action(vector occupied) bool Character::check(Location L, vector 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()); -- cgit v1.2.3