Results 1 to 7 of 7

Thread: FPS vs. Speed of movement

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2001
    Location
    Great White North, ey?
    Posts
    202

    Question FPS vs. Speed of movement

    You know how on some computers a game can run at 100fps and on others the same game will run at like 60 or 50fps. Well I have a quesion. If I want to move a sprite 5 pixels to the right, that is a fast enough pace when running at 100fps, but it is not fast enough if running at 50fps. So is it a good idea to tie together the FPS you are getting with the speed of movment of your sprite? Say if I run at 100fps then speed = 5 if 80fps then speed = 6, if 60fps then speed = 7...etc

    Would that work, how do you guys do it?

  2. #2
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    Yea, FPS is inversely proportional to movement.

  3. #3
    Addicted Member
    Join Date
    Aug 2002
    Location
    Baltimore, MD
    Posts
    230
    Normally sprite movement has nothing to do with frame rate, it's time dependant. Your sprite would move at the same rate no matter what your frame rate is. The only problem you'll have is when your frame rate gets really really low. On a decent machine though it shouldn't be a problem.

  4. #4
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    Get b****ed at the last time I posted this code...
    Code:
    Dim tDelta As Single
    Dim s As Long
    Dim e As Long
    ...
    While True  'Your game loop
       s = GetTickCount()
       'Do Stuff
       DoEvents
       e = GetTickCount()
       tDelta = CSng(e - s) / 1000.0
    Wend
    tDelta contains the fraction of a second your frame took to loop once. Simply multiply the distance you want your sprite to move in one second by tDelta, and add it to the sprite's position. Using this method, FPS = 1.0 / tDelta.

    Z.

  5. #5
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    Oh, and you have to do your movement EVERY frame.

    Z.

  6. #6
    Addicted Member
    Join Date
    Aug 2002
    Location
    Baltimore, MD
    Posts
    230
    If you do your movement every time through the game loop and the sprite is a person walking, you'll potentially have the sprite moving without the legs moving since you'll only have a certain number of frames in the sprite animation. Though if you have enough frames of animation it may not be noticeable.

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Dec 2001
    Location
    Great White North, ey?
    Posts
    202

    Cool

    Ok, thanks I'll try that.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width