#define MAX_FPS 60
-static void fade_buf(SDL_Surface *screen, int amount)
+static void fade_buf(SDL_Surface *screen, double fade)
{
int i;
unsigned int *buf = screen->pixels;
unsigned char *b;
+ unsigned char amount;
+ static double threshold;
+ threshold += fade;
+
+ if (threshold > 1) {
+ amount = threshold;
+ threshold -= amount;
+ } else {
+ return;
+ }
- for (i = 0; i < screen->pitch * screen->h / sizeof(*buf); i ++) {
+ for (i = 0; i < screen->pitch * screen->h / sizeof(*buf); i++) {
if (!buf[i])
continue;
b = (unsigned char *)&buf[i];
{
struct timespec tp;
unsigned long ret;
- static unsigned long start = 0;
+ static unsigned long start;
clock_gettime(CLOCK_MONOTONIC, &tp);
case SDLK_a:
time_scale_rate = 1 / 1.5;
break;
+ case SDLK_1:
+ status->time_scale = 1;
+ break;
+ case SDLK_2:
+ status->time_scale = 10;
+ break;
+ case SDLK_3:
+ status->time_scale = 20;
+ break;
+ case SDLK_4:
+ status->time_scale = 30;
+ break;
case SDLK_t:
status->tracers_enabled =
!status->tracers_enabled;
}
break;
case SDL_VIDEORESIZE:
- status->screen = SDL_SetVideoMode(event.resize.w,
- event.resize.h,
- 32,
- status->screen->flags);
+ status->screen =
+ SDL_SetVideoMode(event.resize.w,
+ event.resize.h,
+ 32,
+ status->screen->flags);
break;
case SDL_QUIT:
goto quit;
step_count++;
/*
- * Do not draw to the screen more often than MAS_FPS
+ * Do not draw to the screen more often than MAX_FPS
* per second
*/
if (last_frame_tick + (1000 * 1000) / MAX_FPS > ticks)