float back_dist;
// all movement is based on t_frame.
+unsigned long frames, start, end;
float t_frame; // length of this frame (in ticks = 1/20th second) adjusted for gamespeed
int ms_frame; // length of this frame (milliseconds)
int ms_end; // end of this frame (milliseconds)
void
draw(void) {
- SDL_FillRect(surf_screen,NULL,0); // black background
+ // SDL_FillRect(surf_screen,NULL,0); // black background
draw_dots(surf_screen); // background dots
draw_sprite(SPRITE(&ship));
draw_rocks();
ms_frame = SDL_GetTicks() - ms_end;
ms_end += ms_frame;
t_frame = opt_gamespeed * ms_frame / 50;
+ frames++;
while(SDL_PollEvent(&e)) {
switch(e.type) {
return 1;
}
+ start = SDL_GetTicks();
+ frames = 0;
gameloop();
+ end = SDL_GetTicks();
+ printf("%ld frames in %ld ms, %.2f fps.\n", frames, end-start, frames * 1000.0 / (end-start));
return 0;
}