int i;
unsigned char *buf = screen->pixels;
- for (i = 0; i < screen->pitch * screen->h; i++) {
+ for (i = 0; i < screen->pitch * screen->h; i++)
buf[i] = (buf[i] < amount) ? 0 : buf[i] - amount;
- }
}
static void loop(SDL_Surface *screen)
SDL_Flip(screen);
- while(SDL_PollEvent(&event)) {
+ while (SDL_PollEvent(&event)) {
if (event.type == SDL_KEYDOWN &&
event.key.keysym.sym == SDLK_ESCAPE) {
printf("\nExiting. Good bye!\n");
if (last_fps_time + 500 < ticks) {
last_framecount = framecount - last_framecount;
- last_fps = last_framecount * 1000 /
+ last_fps = last_framecount * 1000 /
(float)(ticks - last_fps_time);
last_framecount = framecount;
last_fps_time = ticks;
SDL_Surface *screen;
int flags = SDL_DOUBLEBUF | SDL_HWSURFACE;
- // Load SDL
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
fprintf(stderr, "Unable to initialize SDL: %s\n",
SDL_GetError());
return 1;
}
- atexit(SDL_Quit); // Clean it up nicely :)
+ atexit(SDL_Quit);
screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 32, flags);
if (screen == NULL) {
do {
ret = read(fd, rndbuf + i,
RAND_BUF_SIZE * (sizeof(rndbuf[0]) - i));
-
+
if (ret <= 0) {
error = errno;
fprintf(stderr, "Error reading file %s: %s\n",