aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSemperVinco <w.deweijer@hotmail.com>2017-03-03 14:21:03 +0100
committerSemperVinco <w.deweijer@hotmail.com>2017-03-03 14:21:03 +0100
commitbf5fa43b838cfea11e16a3339b10174ea28ea918 (patch)
tree7420b208e17e6e96eecad95a8a68c633a86cafac
parent9f38c82b01c44410bb7778d2607f38daec9dfb35 (diff)
add single step option -t, make step printing accurate
-rw-r--r--main.cpp13
-rw-r--r--parse.cpp2
-rw-r--r--parse.h2
3 files changed, 12 insertions, 5 deletions
diff --git a/main.cpp b/main.cpp
index 7786149..e1e94f8 100644
--- a/main.cpp
+++ b/main.cpp
@@ -48,7 +48,7 @@ int parseInt(const char *str){
}
void usage(char **argv){
- cerr<<"Usage: "<<argv[0]<<" [-r <fname>]* [-p <fname> <x> <y> <heading>]* [-s <sleeptime>]"<<endl;
+ cerr<<"Usage: "<<argv[0]<<" [-r <fname>]* [-p <fname> <x> <y> <heading>]* [-s <sleeptime>] [-t]"<<endl;
}
int main(int argc,char **argv){
@@ -61,6 +61,7 @@ int main(int argc,char **argv){
vector<RobotSpec> robotSpecs;
int sleeptime=3000;
+ bool step = false;
if(argc<=1){
usage(argv);
@@ -104,6 +105,10 @@ int main(int argc,char **argv){
i+=1;
break;
+ case 't':
+ step = true;
+ break;
+
default:
cerr<<"Unknown switch in '"<<argv[i]<<"'"<<endl;
return 1;
@@ -131,11 +136,13 @@ int main(int argc,char **argv){
signal(SIGINT,signalHandler);
#endif
world.print(*sb);
+ sb->draw();
for(int i=0;i<C::autoTimeout;i++){
- usleep(sleeptime);
+ if(step) cin.get();
+ else usleep(sleeptime);
world.tick();
world.print(*sb);
- sb->mvprintf(0, SIZE, "step: %5i", i);
+ sb->mvprintf(0, SIZE, "step: %5i", i+2);
sb->draw();
}
delete sb;
diff --git a/parse.cpp b/parse.cpp
index a0267cc..cbfb306 100644
--- a/parse.cpp
+++ b/parse.cpp
@@ -199,4 +199,4 @@ string preprocess(istream &file){
}
return result;
-} \ No newline at end of file
+}
diff --git a/parse.h b/parse.h
index 7af8b2a..fc6cd0e 100644
--- a/parse.h
+++ b/parse.h
@@ -8,4 +8,4 @@ using namespace std;
Team assemble(const string &source);
-string preprocess(istream &file); \ No newline at end of file
+string preprocess(istream &file);