diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2012-08-14 18:05:13 +0200 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2012-08-14 18:05:13 +0200 |
commit | c331551e407fda9803522433dc8871fa6cc5f4ba (patch) | |
tree | 42cb623b0dd3d7550d90e2c0f537c15f10145c39 /effect-pad.c | |
parent | 9be84de9fb224a3e069eb8577baf02f3dcf81a0f (diff) | |
download | osc-graphics-c331551e407fda9803522433dc8871fa6cc5f4ba.tar.gz |
use SDL_gfx for framerate adjustment
Diffstat (limited to 'effect-pad.c')
-rw-r--r-- | effect-pad.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/effect-pad.c b/effect-pad.c index 0911701..b942bdc 100644 --- a/effect-pad.c +++ b/effect-pad.c @@ -5,6 +5,7 @@ #include <SDL.h> #include <SDL_image.h> +#include <SDL_framerate.h> //#define EFFECT_FIRE_COLORKEYED @@ -33,6 +34,7 @@ #define SCREEN_WIDTH 640 #define SCREEN_HEIGHT 480 +#define FRAMERATE 20 /* Hz */ static SDL_Surface *screen; @@ -257,8 +259,10 @@ process_events(void) int main(int argc, char **argv) { - SDL_Surface *fire_surface; - SDL_Surface *image_surface; + FPSmanager fpsm; + + SDL_Surface *fire_surface; + SDL_Surface *image_surface; if (SDL_Init(SDL_INIT_VIDEO)) { SDL_ERROR("SDL_Init"); @@ -275,6 +279,9 @@ main(int argc, char **argv) return EXIT_FAILURE; } + SDL_initFramerate(&fpsm); + SDL_setFramerate(&fpsm, FRAMERATE); + image_surface = IMG_Load("image_1.jpg"); if (image_surface == NULL) { SDL_IMAGE_ERROR("IMG_Load"); @@ -296,7 +303,7 @@ main(int argc, char **argv) SDL_BlitSurface(fire_surface, NULL, screen, NULL); SDL_Flip(screen); - SDL_Delay(1000/20); + SDL_framerateDelay(&fpsm); } /* never reached */ |