Advertisement

Smoothly sliding bitmap around the screen

Started by February 25, 2003 12:24 PM
6 comments, last by John_123 21 years, 8 months ago
I''m trying to smoothly slide a bitmap across the screen and can''t seem to get the movement fluid. It''s fast, but not totally smooth. Small amount of jerkiness that ruins the sliding animation. Basically doing a blit in a loop stepping one x,y at a time. Is there any way to make the movement smooth without using directx or open/gl? Using VC7 & C++. Tried playing with the Sleep(1) and the x,y values, but doesn''t help much. The purpose being to slide chips from the player into the pot at the center of the table.
A very simple way is to perhaps move the bitmap one x and one y every THIRD frame.

Otherwise you might want to raise frames per second so that it is drawn more smoothly.

What API are you using?

-----------------------------
Final Frontier Trader
-----------------------------Final Frontier Trader
Advertisement
Just using GDI. It''s a small bitmap 90x32. Basically all I do is BitBit in steps of 1. Not sure what you mean by every third frame. I do the following:

BitBlt to (x+1, y+1)
::Sleep(1) // tried various values

biovenger is right, but there's no need to move 1 pixel every
third frame !

here's the pseudo code:

for i=0 to num_pixels_to_move
sprite.move(sprite.x+1, sprite.y+1);
sprite.render
end for

that way no more flickering !!!




There is no problem, only solutions...


[edited by - DarkPixel on February 25, 2003 4:49:56 PM]

[edited by - DarkPixel on February 25, 2003 4:50:35 PM]

There is no problem, only solutions...
An even better way is to create a backbuffer bitmap, blit all
your sprite stuff into and then render the buffer !

It''s a little more time consuming but it''s the best way to do
fluid animations !



There is no problem, only solutions...

There is no problem, only solutions...
The *ONLY* way to perform real smooth scrolling and animation is subjecting your program to the vsync of the monitor.
This can only be done in fullscreen exclusive mode.
Advertisement
I''m already doing it as you described. The problem isn''t flickering. I double buffer everything with a back buffer. The problem is...say in a loop of 100, stepping 1 (horizontal straight line), it will "jerk" about 5-8 times through the sequence. Very minor pause, but noticable enough to ruin the animation. Like drawing a bar graph. You would expect that in a tight loop like this it would be smooth through the range. It is for the most part, except for those little minor jumps.
Can''t agree with the full scree. Look at the poker game at paradisepoker.com. The chips slide totally smooth using only GDI in a window. That''s what I''m trying to accomplish.

This topic is closed to new replies.

Advertisement