summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortom <tom@ground-control>2015-11-20 15:23:18 -0600
committertom <tom@ground-control>2015-11-20 15:23:18 -0600
commit032d4f98c809bde6231ff78ba50e8c244334739f (patch)
tree9e94f4b1d50d443e82509c7a3060173b5f602eaf /src
parent5d3145ca44d7966326136adc1bd2dec910b5a8d2 (diff)
made guys randomly walk around and a timeout on getch
Diffstat (limited to 'src')
-rw-r--r--src/List.cpp32
-rw-r--r--src/Screen.cpp1
-rw-r--r--src/main.cpp1
3 files changed, 33 insertions, 1 deletions
diff --git a/src/List.cpp b/src/List.cpp
index ec2495c..c0d956f 100644
--- a/src/List.cpp
+++ b/src/List.cpp
@@ -6,7 +6,8 @@ List::List()
{
Character x ('@',4,150,150+i);
men.push_back(x);
- }
+ }
+ srand(time(NULL));
}
void List::draw(WINDOW * w)
@@ -14,3 +15,32 @@ void List::draw(WINDOW * w)
for(int i = 0; i < 10; i++)
men[i].draw(w);
}
+
+void List::actions()
+{
+ for(int i = 0; i < 10; i++)
+ {
+ int x = men[i].getRow();
+ int y = men[i].getCol();
+ int r = rand()%15+1;
+ if(r==1)
+ men[i].move(x+1,y);
+ else if(r==2)
+ men[i].move(x-1,y);
+ else if(r==3)
+ men[i].move(x,y+1);
+ else if(r==4)
+ men[i].move(x,y-1);
+ else if(r==5)
+ men[i].move(x+1,y+1);
+ else if(r==6)
+ men[i].move(x-1,y-1);
+ else if(r==7)
+ men[i].move(x+1,y-1);
+ else if(r==8)
+ men[i].move(x-1,y+1);
+ else
+ continue;
+ }
+
+}
diff --git a/src/Screen.cpp b/src/Screen.cpp
index 6f82b8c..9d0a72c 100644
--- a/src/Screen.cpp
+++ b/src/Screen.cpp
@@ -9,6 +9,7 @@ Screen::Screen()
keypad(stdscr,TRUE);
curs_set(0);
getmaxyx(stdscr,height,width);
+ timeout(100);
start_color();
init_pair(1, COLOR_GREEN, COLOR_BLACK);
diff --git a/src/main.cpp b/src/main.cpp
index 1066d08..93693ee 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -29,6 +29,7 @@ int main()
else if (c == 'q')
break;
+ L.actions();
map.fillWindow();
L.draw(map.getWin());
cursor.draw(map.getWin());