From: Jason Woofenden Date: Sun, 26 Apr 2009 16:03:20 +0000 (-0400) Subject: fixed screenshot code so you can take more than one (and won't overwrite previous... X-Git-Tag: 0.5.4~14 X-Git-Url: https://jasonwoof.com/gitweb/?p=vor.git;a=commitdiff_plain;h=c1db302b3620bf4e0314867cddf094402d76d2d6 fixed screenshot code so you can take more than one (and won't overwrite previous screenshot(s)) and documented the feature --- diff --git a/README b/README index fd1aece..5fc8451 100644 --- 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 -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. diff --git a/main.c b/main.c index 6f4fa1c..2bf7715 100644 --- a/main.c +++ b/main.c @@ -74,6 +74,7 @@ struct dot bdot[MAXBANGDOTS]; // 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 }; @@ -676,8 +677,21 @@ gameloop() { return; case SDLK_3: case SDLK_PRINT: - // FIXME make a unique filename like vor-screenshot--.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: