]> git.lizzy.rs Git - nothing.git/commitdiff
Provide platforms via CLI
authorrexim <reximkut@gmail.com>
Wed, 20 Dec 2017 03:10:06 +0000 (10:10 +0700)
committerrexim <reximkut@gmail.com>
Wed, 20 Dec 2017 03:10:06 +0000 (10:10 +0700)
README.md
src/main.c

index 67db61be0939d049fec35a237d6b806cad7e026a..4394d089877e6e66d158e853751fd764cf39a980 100644 (file)
--- a/README.md
+++ b/README.md
@@ -12,8 +12,7 @@ $ mkdir build
 $ cd build/
 $ cmake ..
 $ make
-$ cd ..
-$ ./nothing
+$ ./nothing <level-file>
 ```
 
 ## Build on Windows
index 5b4173828689563b6b8263fc385557a4844434ff..0248cd0ff3765fc463d05432b5e36d73a42bf6aa 100644 (file)
@@ -11,7 +11,6 @@
 #define SCREEN_WIDTH 800
 #define SCREEN_HEIGHT 600
 #define GAME_FPS 60
-#define LEVEL_FILE_NAME "./levels/platforms.txt"
 
 /* LT module adapter for SDL_Quit */
 static void SDL_Quit_lt(void* ignored)
@@ -20,13 +19,20 @@ static void SDL_Quit_lt(void* ignored)
     SDL_Quit();
 }
 
-int main(int argc, char *argv[])
+static void print_usage(FILE *stream)
 {
-    (void) argc;                /* unused */
-    (void) argv;                /* unused */
+    fprintf(stream, "Usage: nothing <level-file>\n");
+}
 
+int main(int argc, char *argv[])
+{
     lt_t *const lt = create_lt();
 
+    if (argc < 2) {
+        print_usage(stderr);
+        RETURN_LT(lt, -1);
+    }
+
     if (SDL_Init(SDL_INIT_EVERYTHING) < 0) {
         print_error_msg(ERROR_TYPE_SDL2, "Could not initialize SDL");
         RETURN_LT(lt, -1);
@@ -75,7 +81,7 @@ int main(int argc, char *argv[])
 
     // ------------------------------
 
-    game_t *const game = PUSH_LT(lt, create_game(LEVEL_FILE_NAME), destroy_game);
+    game_t *const game = PUSH_LT(lt, create_game(argv[1]), destroy_game);
     if (game == NULL) {
         print_current_error_msg("Could not create the game object");
         RETURN_LT(lt, -1);