Archived

This topic is now archived and is closed to further replies.

Bad_Maniac

Fast Moving 2D Animation Tricks ?

Recommended Posts

First things first: MS Visual C++ 6.0 DirectX 8.1 SDK (DDRAW7) Windows XP pro FAST PC/256Mb RAM Right, I've been checking out a lot of tutorials, checked through some books at the library, and found that they all recommend running your average 2D scroller in 30fps. Locking it to that is not a problem, I just let my windows message handler take up those extra cycles for now. =D It does have a drawback though. If I want something travelling REALLY fast, say 90 pixels per second, that's 3 pixels per frame. and that looks JERKY and BAD! Just post briefly how you have solved this problem either using neat tricks or other angles to tackle the problem. and uhm, I'd rather not up the framerate to 60 or even 75 fps, since... I want my game to run on old(ish) computers, and it should. I just want the animations to look nicer. So any ideas? It''s nice to be important, but it''s more important to be nice. [edited by - Bad_Maniac on October 2, 2002 5:51:32 PM]

Share this post


Link to post
Share on other sites
I don''t know who told you to run a 2D scroller in 30fps but that is complete rubbish. You need 50fps+ for a 2D scroller to look smooth unless you do motion blurring.
The best way to get this running quickly on older computers is to support lower resolutions - i.e. get the required fillrate down.

Share this post


Link to post
Share on other sites
Sometimes the frame rate can actually establish the character of a game.

A 30fps game might have a different playability than a 60fps game just from the smoothness of the animation.

Who knows, it might have to do with the fact that movies play at 24fps.

Share this post


Link to post
Share on other sites
Why lock a game at 30 fps, well I want to do a very simple scrolling 2D game, and I want it to run on almost any machine. and well, if I don''t lock the fps the game will run too fast to play on fast Athlons, I would rather have it run the same speed on any system. And at the moment I do that by locking fps, not by timing.
I didn''t ask this to hear how stupid I am and how wrong my method is. it is the way all games have been made for about 10 years, so it''ll work for me.

Motion blur, any hints on that, or tutorials around?

It''''s nice to be important, but it''''s more important to be nice.

Share this post


Link to post
Share on other sites
Letting the FPS go wild doesn''t stop you from having your game run reasonably on any PC. You can write your code so that the graphics are time-synched.

I agree with letting the FPS go crazy. 60 fps looks a lot better than 30..


Cheers!

Share this post


Link to post
Share on other sites
quote:
Why lock a game at 30 fps, well I want to do a very simple scrolling 2D game, and I want it to run on almost any machine. and well, if I don't lock the fps the game will run too fast to play on fast Athlons, I would rather have it run the same speed on any system.


You can have the best of both worlds

In my game I when I'm moving a sprite, I create an "event" that keeps track of how fast it needs to move. For example, I'm creating an 2D tile-esque RPG, where every time the player hits an arrow key, their character moves one tile (16x16pixels).

Here's some pseudo-C


struct Step
{
pointer to the sprite it's moving
distance
start position
time length(amount of time the move should take)
delta (time length / distance)
time of last update
}

The delta time is the amount of time that needs to pass before the object should be moved one pixel.

Thus, every game loop I iterate through the steps:

void ProcessSteps()
{
For each step:
if(time of last update + delta < current time)
move the sprite one pixel
}


Oversimplified, but I hope it makes some sense.

[edited by - tls284 on October 3, 2002 3:28:01 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by Waverider
Who knows, it might have to do with the fact that movies play at 24fps.


And movies are very jerky - just watch the background scroll by. You don''t notice it much because of the automatic motion blurring.

Locking the framerate has many advantages, and is much easier to program for, but 30fps is too low for a smooth scrolling game. Ideally you should lock at some division of the refresh rate. If all monitors support 60Hz, then lock at that.

I think there are some tutorials on motion blurring on this site, failing that try www.flipcode.com

Share this post


Link to post
Share on other sites
If you draw textures with the characters, you could add alphablending to some trailing frames (dunno how ddraw would handle this, I don''t use dx). Say you want something to move 3 pixels, which you mentioned. Just add one or two alpha-blended images behind, or something. I don''t know how it will look, but it should work You better do some research on this anyway...
And I will _not_ discuss whether you should use fps-fixed or time-synced physics

Share this post


Link to post
Share on other sites
A couple of things re frame rates:

1) Movies have 24 frames per second, but each frame is displayed twice. Your brain extrapolates movement from the motion blur making it seem like it is 48 fps.

2) To most people, a slower solid frame rate (eg constant 30fps) is a lot more pleasing than a quicker fluctuating frame rate (eg 40-50fps). By limiting the frame rate a bit lower, it means that the frame rate can be sustained.

3) I''m not fully certain on this, but I''m fairly sure that the reason 60hz was chosen as the basic minimum for monitors is because it is at around 50-60hz that a flashing light will appear continuous to our eyes. The actual ''refresh rate'' of our eyes is around half that - although you will notice if every 2nd frame is missing, the actual information from the extra frames doesn''t add to your perception - that is, unless the extra frames are incongruous with what your brain expects.

With motion blur, an image at 30fps will work fine because it all fits together in the brain. Without correct motion blur at 30fps, motion will seem jerky. By using 60fps, a similar effect to motion blur is made which helps things to look right.

As you increase the frame rate beyond 60fps, things will continue to look better as motion blur type effects look better and better.

Remember though that the eye isn''t as simple as a couple of numbers. Even though it sees at about 30fps, if you showed a white flash on a black background for 1/100th of a second, your eye would still see it.



Trying is the first step towards failure.

Share this post


Link to post
Share on other sites
quote:
If you draw textures with the characters, you could add alphablending to some trailing frames (dunno how ddraw would handle this, I don''t use dx). Say you want something to move 3 pixels, which you mentioned. Just add one or two alpha-blended images behind, or something. I don''t know how it will look, but it should work


*Don''t* do this. It makes things look blurry and that''s about it. The idea of motion blur is to *add* information, leaving a faded trail removes it as the trail obscures new info. With motion blur, you want to show where stuff was say half a frame ago - the person already knows where it was 1 frame ago - you showed it to them

Trying is the first step towards failure.

Share this post


Link to post
Share on other sites