Thread: Frame Rate

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    118

    Frame Rate

    Hello. I am having a problem with timing my frame rate for an animated sprite in my game. The sprite consists of 7 DirectX surfaces that I flip through to create the animation. The problem is that I want to pause between each frame, but let the rest of the programs main loop run at full speed. I was wondering if anyone could help me on this matter. I was thinking of using something like GetTickCount, but I can't seem to make just the frame rate pause without it slowing the entire loop. I would greatly apprciate any help, or a link to set me in the right direction.

  2. #2
    Banned
    Join Date
    Jan 2003
    Posts
    1,708
    I'm not entirely sure what you are saying, you only want to draw the object(s) a certain number of times per second? If you have GetTickCount, you are measuring in milliseconds. If you want to draw 20 times per second, 1000 / 20 = 50, therefore you only draw it every 50 ms.


    Code:
    //if more than 50ms has passed since last draw we draw the sprites
    CurrentSpriteTime = GetTickCount();
    
    if((CurrentSpriteTime - LastSpriteTime) >= 50) {
    Render$$$$(); 
    LastSpriteTime = CurrentSpriteTime;
    }
    does that seem correct to you? I honestly haven't done this before.
    Last edited by Silvercord; 04-03-2003 at 03:29 PM.

  3. #3
    I think he's saying he wants a pause between the frames of his animation. Basically you just need to store the time it takes to progress the frame, either as a constant or a variable. Then have a variable the stores the time when the last frame started. Before you draw the sprite, you check if the time has elapsed. If so, you draw the next frame instead of the old one.

  4. #4
    Banned
    Join Date
    Jan 2003
    Posts
    1,708
    doesn't mine do just that? If you are pausing between each animation frame, that means you are only drawing x amount of times per second.

  5. #5
    Registered User
    Join Date
    Oct 2002
    Posts
    118
    Thanks for the help. Just seeing your code was all I needed. Sometimes I need a little push with the simple things. All is going well now, so thanks a million!
    "The distinction between past, present and future is only an illussion, even if a stunning one."
    -Albert Einstein

  6. #6
    Banned
    Join Date
    Jan 2003
    Posts
    1,708
    Sweet, glad I helped ya.

  7. #7
    I was just clarifying to you what he wanted . The way you worded it was that you only displayed the animation every so often.

    you only want to draw the object(s) a certain number of times per second?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Frame Rate Limiter
    By Nurfina in forum Game Programming
    Replies: 13
    Last Post: 04-14-2007, 01:29 PM
  2. Getting Frame Rate in DirectX
    By Rune Hunter in forum Game Programming
    Replies: 4
    Last Post: 11-02-2005, 02:57 PM
  3. Animation not working....
    By aquinn in forum C Programming
    Replies: 7
    Last Post: 02-19-2005, 05:37 AM
  4. the effects of textures on my frame rate
    By DavidP in forum Game Programming
    Replies: 37
    Last Post: 10-03-2003, 11:24 AM
  5. Whats a good frame rate?
    By compjinx in forum Game Programming
    Replies: 16
    Last Post: 04-07-2002, 05:31 PM