mirror of
https://github.com/brmlab/ledbar.git
synced 2025-06-09 21:34:00 +02:00
Factor out #define FPS, sleep -> wait
This commit is contained in:
parent
ea6ebd7d2c
commit
86890d1a4d
1 changed files with 6 additions and 5 deletions
|
@ -34,6 +34,7 @@
|
||||||
#define RESY 600
|
#define RESY 600
|
||||||
#define BPP 32
|
#define BPP 32
|
||||||
#define BOXES 10
|
#define BOXES 10
|
||||||
|
#define FPS 40
|
||||||
|
|
||||||
SDL_Rect rects[BOXES];
|
SDL_Rect rects[BOXES];
|
||||||
|
|
||||||
|
@ -271,7 +272,7 @@ int main(int argc, char* argv[])
|
||||||
int t = 0;
|
int t = 0;
|
||||||
int size;
|
int size;
|
||||||
int lastUpdate = 0;
|
int lastUpdate = 0;
|
||||||
int sleep;
|
int wait;
|
||||||
FILE* fp;
|
FILE* fp;
|
||||||
|
|
||||||
if (argc == 1) fp = 0;
|
if (argc == 1) fp = 0;
|
||||||
|
@ -318,11 +319,11 @@ int main(int argc, char* argv[])
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sleep = 25 - (SDL_GetTicks() - lastUpdate);
|
wait = 1000/FPS - (SDL_GetTicks() - lastUpdate);
|
||||||
if (sleep > 0) {
|
if (wait > 0) {
|
||||||
SDL_Delay(sleep);
|
SDL_Delay(wait);
|
||||||
}
|
}
|
||||||
lastUpdate += 25;
|
lastUpdate += 1000/FPS;
|
||||||
}
|
}
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
if (fp) {
|
if (fp) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue