A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: [Discussion] Accurate/CPU independent timers for a racing game?

  1. #1
    Senior Member
    Join Date
    Nov 2005
    Posts
    192

    [Discussion] Accurate/CPU independent timers for a racing game?

    Is there a way to accurately and fairly time a person in a racing game? To me it seems like someone with a fast computer will get a faster time than someone with a slow computer (provided they drove exactly the same path). They have a higher average frame rate, so they will get through more of the level than the other person in the same amount of time.

    What is the best way to fix this, and how can you time the players?

    Thanks

    edit:
    Last edited by Flyingcow; 07-05-2011 at 07:46 AM.

  2. #2
    Senior Member
    Join Date
    Jan 2010
    Posts
    126
    Of course, use a fixed timestep.

    In my racing game a user at 30fps can get the same scores as someone running at 60fps.

    The physics run at a fixed 100fps, and the visuals are interpolated between physics frames.

    A fixed timestep is pretty much necessary for fair times in racers etc.

  3. #3
    Senior Member
    Join Date
    Nov 2005
    Posts
    192
    Something like this? http://gafferongames.com/game-physic...your-timestep/

    Thank you for the reply, but what do you use to time the races? A timer, or add up the fixed timeSteps?

    EnterFrame game loop, or timer game loop?

    My game hardly has any physics. You are basically just a spaceship with constant magnitude of acceleration, no external forces.

  4. #4
    Senior Member
    Join Date
    Jan 2010
    Posts
    126
    That's exactly what I mean, that's what I based my fixed timestep on.

    Forget the Timer class, it's rubbish.

    I made my own stopwatch/lap timer class using getTimer and offsets. It's really the only way for accurate time keeping in Flash.

    And of course an EnterFrame loop.

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

HTML5 Development Center