The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.
SDL
Simple Directmedia Layer Forums
jumps in scrolling animation
anees
Joined: 23 Jul 2010
Posts: 3
Posted: Mon Jul 26, 2010 9:42 am
Hi,
I am using SDL in a utility which scrolls banner horizontally, this utility will be executed in window mode. Sample code is at bottom.
During scrolling, a lot of jumps can be observed by looking closely. The frame rate is around 550-600 frames/s, but it seems frames are skipping which is causing the jerks. I have event tried controlling the scrolling speed to 60 frames/s, but it makes no difference. Is there any way to achieve smooth scrolling ? - an initialization flag or a different approach.
//If there's an event to handle
SDL_Event event;
if( SDL_PollEvent( &event ) ) {
//If a key was pressed
if( event.type == SDL_KEYDOWN ) {
//Set the proper message surface
switch( event.key.keysym.sym ) {
case SDLK_ESCAPE: quit=true; break;
}
}
//If the user has Xed out the window
else if( event.type == SDL_QUIT ) {
//Quit the program
quit = true;
}
}
//If a message needs to be displayed
if( message != NULL )
{
SDL_FillRect( SDL_GetVideoSurface(), NULL, 0 );
//Apply the message centered on the screen
apply_surface(x, (SCREEN_HEIGHT - message->h ) / 2, message, screen );
}