JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
fixed screenshot code so you can take more than one (and won't overwrite previous...
authorJason Woofenden <jason283@herkamire.com>
Sun, 26 Apr 2009 16:03:20 +0000 (12:03 -0400)
committerJason Woofenden <jason283@herkamire.com>
Sun, 26 Apr 2009 19:57:55 +0000 (15:57 -0400)
README
main.c

diff --git a/README b/README
index fd1aece..5fc8451 100644 (file)
--- a/README
+++ b/README
@@ -4,9 +4,16 @@ VoR is a quick action game where you drive a space ship and try to avoid
 crashing into rocks. Current information about vor can be found on the
 homepage: http://jasonwoof.org/vor
 
 crashing into rocks. Current information about vor can be found on the
 homepage: http://jasonwoof.org/vor
 
-To play, press space to start (or 1 for an easy game) then use the arrow keys
-(or the numpad if you prefer) to steer around, dodge rocks, and make your way
-rightward. You can also press F to toggle full-screen mode and P to pause.
+Here are the keys:
+
+ Space: Start playing
+     1: Switch to easy mode and start playing
+     2: Switch to normal mode (default) and start playing
+Arrows: Steer (use short taps, and remember to slow down)
+   Esc: Quit
+     F: Toggle full-screen mode
+     P: Pause/unpause
+     3: Save a screenshot
 
 See INSTALL for instructions on building, running and installing.
 
 
 See INSTALL for instructions on building, running and installing.
 
diff --git a/main.c b/main.c
index 6f4fa1c..2bf7715 100644 (file)
--- a/main.c
+++ b/main.c
@@ -74,6 +74,7 @@ struct dot bdot[MAXBANGDOTS];
 // Other global variables
 char topline[1024];
 char *initerror = "";
 // Other global variables
 char topline[1024];
 char *initerror = "";
+int screenshot_number = 0;
 
 struct ship ship = { SHIP, 0, NULL, XSIZE/2, YSIZE/2, BARRIER_SPEED, 0.0 };
          
 
 struct ship ship = { SHIP, 0, NULL, XSIZE/2, YSIZE/2, BARRIER_SPEED, 0.0 };
          
@@ -676,8 +677,21 @@ gameloop() {
                                                                return;
                                                        case SDLK_3:
                                                        case SDLK_PRINT:
                                                                return;
                                                        case SDLK_3:
                                                        case SDLK_PRINT:
-                                                               // FIXME make a unique filename like vor-screenshot-<pid>-<count>.bmp
-                                                               SDL_SaveBMP(surf_screen, "snapshot.bmp");
+                                                               {
+                                                                       FILE *screenshot_fp;
+                                                                       char tmp[30];
+                                                                       char *screenshot_filename = &(tmp[0]);
+                                                                       for(;;) {
+                                                                               snprintf(screenshot_filename, 30, "vor-screenshot-%02i.bmp", screenshot_number++);
+                                                                               screenshot_fp = fopen(screenshot_filename, "r");
+                                                                               if(screenshot_fp) {
+                                                                                       fclose(screenshot_fp);
+                                                                               } else {
+                                                                                       break;
+                                                                               }
+                                                                       }
+                                                                       SDL_SaveBMP(surf_screen, screenshot_filename);
+                                                               }
                                                                break;
                                                        case SDLK_p:
                                                        case SDLK_PAUSE:
                                                                break;
                                                        case SDLK_p:
                                                        case SDLK_PAUSE: