From 032d4f98c809bde6231ff78ba50e8c244334739f Mon Sep 17 00:00:00 2001 From: tom Date: Fri, 20 Nov 2015 15:23:18 -0600 Subject: made guys randomly walk around and a timeout on getch --- src/List.cpp | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'src/List.cpp') 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; + } + +} -- cgit v1.2.3