Smooth scrolling
My isometric engine can support scrolling by any number of pixels, but it''s still rather jumpy. Even if I set it to 60 fps and it scrolls at 5 pixels per frame, it''s jumpy. If I set the pixels per frame for scrolling lower than 5, it''s too slow of a scroll. Anyone know how to get really smooth scrolling done while still being fast enough without putting the gamer to sleep?
ColdfireV
[email=jperegrine@customcall.com]ColdfireV[/email]
I''ve seen it done several ways, possibly the best is to give the screen a "vector". And a formula to calculate how fast to scroll, probably won''t fix the jumpiness. But could allow you to start with a really low scroll speed and accelerate it.
Are you just using a keyboard to scroll around the map? Using the mouse generally results in much smoother scrolling. For example, if you''re using DirectInput, you could write some code like this to update the screen position with the mouse:
DIMOUSESTATE mouse_state;
/*
..
read the mouse
..
*/
// update screen position
Screen_X += mouse_state.lX;
Screen_Y += mouse_state.lY;
The screen should always scroll smoothly using something like that because the mouse velocity isn''t always constant.. it changes with the motion of the mouse... so it will always look smooth. At least that''s been my experience. Try it for yourself... and if that still isn''t smooth I''d say you need to optimize your code more.
Al
DIMOUSESTATE mouse_state;
/*
..
read the mouse
..
*/
// update screen position
Screen_X += mouse_state.lX;
Screen_Y += mouse_state.lY;
The screen should always scroll smoothly using something like that because the mouse velocity isn''t always constant.. it changes with the motion of the mouse... so it will always look smooth. At least that''s been my experience. Try it for yourself... and if that still isn''t smooth I''d say you need to optimize your code more.
Al
Alexbigshot@austin.rr.comFoolish man give wife grand piano. Wise man give wife upright organ.
Actually, looking at my code more kinda helped me out a little. My problem still isn''t fixed, but here''s what the actual problem is. My code is set up so that the map drawing function is told what map coordinates should be centered on the screen. Then the x and y pixels for each tile have added to them an offset to give them a small scroll (1 pixel). The reason for the jumpiness is because while it''s small scrolling, it scrolls by tiles also. Maybe I have my whole tile system set up wrong. I mean, it works, but it''s really hard to work with. How does everyone else store what part of the map should be displayed? I have my center tile position method, but what does everyone else do? (BTW: I''m using diamond-shaped tiles, so it''s kinda hard to do a pixel method of positioning).
ColdfireV
ColdfireV
[email=jperegrine@customcall.com]ColdfireV[/email]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement