Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Ok, maybe it's a VERY STUPID question, but still I have some trouble figuring how to achieve a fixed framerate...

 

Let's suppose I write my own dx engine and finally managed to render a tile-based map.

Now I'd like to place my "main character" on this map (rendered for simplicity's sake with the Sprite object).

When my char moves, it should animate. I can very simply change the "drawing frame" of my character everytime I do a BeginScene.

However, running on a fast computer this should result in a faster-than-light animation, when on a slow machine it can be painfully sloooooooooow.

 

What I am asking in this useless rant is some hint, link or pseudo code (I use VB.NET, but my problem is more a "conceptual" one than a "code-syntax" one) on how to handle a "fixed frame rate" animation or something similar.

 

Thanks anyone!

Posted

Firstly, I'd like to point out that I have never done this, or anything remotely like it, so I could be way off base.

 

Is it possible to choose which frame from the animation based upon the system clock (or some other timer)? That way, no matter how fast the frame rate is the animation will be fixed.

TT

(*_*)

 

There are 10 types of people in this world;

those that understand binary and those that don't.

Posted
Direct3D is incredibly fast if you do things right, if you post the rendering code someone can see if anything is wrong
.Net allows software to be written for any version of Windows and not break like Unmanaged applications unless using Unmanaged procedures like APIs. If your program uses large amounts of memory but releases it when something else needs it, then what's the problem?
Posted
Is it possible to choose which frame from the animation based upon the system clock (or some other timer)? That way, no matter how fast the frame rate is the animation will be fixed. [/b]

 

Yes, that was the first thing I thought about.

However, I cannot figure not even pseudo-code based on a "timer-sync". :(

 

For instance, if I want to move the character from one tile to another, I'll need to sync BOTH the animation AND the position of the character on the screen.

I don't know, it's a lot of work, and I think the solution is REALLY simple...

 

Originally posted by AndreRyan

Direct3D is incredibly fast if you do things right, if you post the rendering code someone can see if anything is wrong

 

I don't have any rendering code. :) It's more a "conceptual" problem than a "technical" one...

Posted (edited)

Thanks!

 

Thanks Mutant, that's quite exactly what I was looking for!

I suggest everyone has my own problem to read the thread linked above! :)

 

Oddly enogh, I figured also how to perform a sort of "frameskip" on lower-end machines. Simply achieved by skipping the entire "rendering" procedure if the machine is taking too much time.

 

[EDIT: Look at these links, they may prove useful]

http://www.visualbasicforum.com/showthread.php?t=88872

http://www.visualbasicforum.com/showthread.php?t=81033

http://members.xoom.virgilio.it/robydx/main.htm

 

The last one is Roberto Zero page, an Italian guy who wrote (and still writes) a LONG serie of tutorials on DX8 and DX9(managed).

Unfortunately the entire page is in Italian only (I'm Italian too, btw), but I think the source code can be VERY useful.

Edited by shouzama

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...