Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: Framerate problems

  1. #11

    Framerate problems

    Don't use GetTickCount, it has a very low resolution. QueryPerformanceCounter or timeGetTime are better.

    Also, it is better to store positions, speeds etc. as floating-point (i.e. Single/Double) rather than integers.
    [size=10px][ Join us in #pgd on irc.freenode.net ] [ Sign the Petition for a Software Patent Free Europe ][/size]

  2. #12

    Re: Framerate problems

    Been here myself so I know how confused you are, but it's a lot easier than you think.

    You need to write some code to calculate how long it's been since the last frame and move everything based on that.

    So if you want something to move at 100 pixels per second, work out how much time has gone by since the last frame and move your character by the appropriate amount.

    Don't have access to it now, but if you want some example code, email me
    thedamot@mailcan.com

    Cheers,


    Damot

  3. #13
    Legendary Member cairnswm's Avatar
    Join Date
    Nov 2002
    Location
    Randburg, South Africa
    Posts
    1,537

    Framerate problems

    Here is some source code:

    http://www.cairnsgames.co.za/downloa.../barbarsrc.zip

    Note however that the way this code works is that it waits until a set delay is complete before moving the sprite - ie it skips some frames if no movement is neccessary.

    Look at the Draw functions in UnitBarBar and UnitItems.
    William Cairns
    My Games: http://www.cairnsgames.co.za (Currently very inactive)
    MyOnline Games: http://TheGameDeveloper.co.za (Currently very inactive)

Page 2 of 2 FirstFirst 12

Bookmarks

Posting Permissions

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