From 29a1b689339e74fe22726b57874ff626f86d649e Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Wed, 9 Nov 2011 23:54:35 +0100 Subject: [PATCH] Added --speed , --help, and --usage to conway. --- games/conway.cpp | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/games/conway.cpp b/games/conway.cpp index 45c7c55e..e6965420 100644 --- a/games/conway.cpp +++ b/games/conway.cpp @@ -2,9 +2,11 @@ #include #include #include +#include #include #include - +#include + using namespace Maxsi; using namespace Maxsi::Keyboard; @@ -136,15 +138,36 @@ void Update() Render(); } +int usage(int argc, char* argv[]) +{ + printf("usage: %s [OPTIONS]\n", argv[0]); + printf("Options:\n"); + printf(" --speed How many miliseconds between updates\n"); + printf(" --usage Display this screen\n"); + printf(" --help Display this screen\n"); + + return 0; +} + int main(int argc, char* argv[]) { + int sleepms = 50; + for ( int i = 1; i < argc; i++ ) + { + if ( String::Compare(argv[i], "--help") == 0 ) { return usage(argc, argv); } + if ( String::Compare(argv[i], "--usage") == 0 ) { return usage(argc, argv); } + if ( String::Compare(argv[i], "--speed") == 0 && 1 < argc-i ) + { + sleepms = String::ToInt(argv[++i]); + } + } + int result = Init(); if ( result != 0 ) { return result; } // Update the game every 50th milisecond. while ( true ) { - const int sleepms = 50; Thread::USleep(sleepms * 1000); Update(); }