Results 1 to 5 of 5

Thread: AHHH its the timer crisis

  1. #1
    Senior Member Regular Contributor
    Join Date
    Apr 2001
    Posts
    102

    AHHH its the timer crisis

    Ok, iv'e read NeHe's tutorial on creating a timer and all of that but I'm not sure if that code fits my case. I want the screen to render fast but I want only certain things in my scene to be slowed down (because now they are way too fast). This is much like how it is in modern games; a screen could render 20fps or 100fps but all the moving objects move at the same speed in both cases. How can I do this??

    Thanks!

  2. #2
    Senior Member Regular Contributor
    Join Date
    Feb 2000
    Posts
    154

    Re: AHHH its the timer crisis

    Position+=Velocity*dtime;

    Where dtime is the time it took to draw previous frame. Use timeGetTime() or QueryPerformanceCounter() to calculate dtime, assuming your in windows.

  3. #3
    Member Contributor
    Join Date
    Feb 2000
    Location
    Brisbane,QLD, Australia
    Posts
    99

    Re: AHHH its the timer crisis

    dont forget set your movement to units per second.. then work from a scalar value which represtents how long in seconds the last frame took to render.

    float starttime, endtime, timetaken, scalar;

    float movespeed = 10; // move at 10 units per sec
    starttime = currenttime;
    render();
    endtime = currenttime;
    timetaken = endtime-starttime;
    // assuming your timer reports in 1000's of a second
    scalar = timetaken/1000.0f;
    position+=movespeed*scalar;

  4. #4
    Senior Member Regular Contributor
    Join Date
    Apr 2001
    Posts
    102

    Re: AHHH its the timer crisis

    How do you round a floating-point number into an integer?

  5. #5
    Senior Member OpenGL Guru zed's Avatar
    Join Date
    Nov 2010
    Posts
    2,466

    Re: AHHH its the timer crisis

    on a similar thread u all might wanna have a looksy at this http://www.flipcode.com/cgi-bin/msg....rum=totd&id=-1

Similar Threads

  1. timer
    By Vlasko in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 05-25-2003, 11:35 PM
  2. AHHH! BSP Files!
    By 31337 in forum OpenGL: Advanced Coding
    Replies: 6
    Last Post: 04-27-2003, 09:10 AM
  3. Crisis!!?!?!?!?
    By in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 08-13-2002, 07:34 AM
  4. AHHH!!! HELP!! :confused:
    By ViRuS in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 11-16-2000, 09:13 AM
  5. Timer Please!!!
    By frogger in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 05-16-2000, 07:34 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean