Results 1 to 34 of 34

Thread: Time-based movement

  1. #1

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051

    Time-based movement

    Hi all, i'm moving my objects according to when the last frame was rendered.

    I want things to move every 10ms, but on slow computers this won't happen, and on fast computers i want think to move as smoothly as possible.

    I'm currently moving objects using this as a way of altering there velocity according to the time passed:

    Code:
    x*(GetTickCount()-LastThink)/10
    where x is the actual velocity, and lastthink is the last time the object moved (the 10 is because i want things based on 10ms).

    I think this works ok, but i'm having trouble with acceleration. I'm currently doing this to gradually reduce the speed of my object:
    Code:
    Velocity *= 0.98
    This doesn't work, the object slows down faster when i'm on a fast computer (and it's called a lot), but takes ages to slow down on a slow computer (when it's not called as often).

    To fix this i tried using this (pow is a funciton calculating is 1st parameter raised to the power of its 2nd parameter.):
    Code:
    velocity *= pow(0.98f,(float)((GetTickCount()-LastThink)/10))
    This doesn't work either unfortunatly.


    Anyone have any ideas??
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  2. #2
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    You aren't doing this are you:
    Code:
    XPlayerVel = x*(GetTickCount()-LastThink)/10
    YPlayerVel = y*(GetTickCount()-LastThink)/10
    XEnemyVel = x*(GetTickCount()-LastThink)/10
    YEnemyVel = x*(GetTickCount()-LastThink)/10
    If you are that could be the problem. It would be better to store GetTickCount()-LastThink in a variable at the start of a loop because otherwise the time the objects are all based on will get larger as the fame nears painting .
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  3. #3
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    I actually find a frame limiter better than time based movement. I have a CPP file that might help you use the GetPerformance counter, which is more acuarate and can be used to increase the acuracy if you want to keep it time based.

    One sec I'll just look for the file....
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  4. #4
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    Here you go....
    Attached Files Attached Files
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  5. #5

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    Thanks for that class, it looks good.

    I'll use it if i can't work out what i'm doing wrong, but i'd really like to get time-based movement working, because it's much better for moving objects the same speed on slow or fast computers (plus it uses a fast computers speed to create smooth movement).

    btw. i am storeing gettickcount in a variable each time but i didn't post that to keep it simple.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  6. #6
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    You don't have the book Game Programing Gems 2 do you....there is an article on how to make your own game loop, and your own counter there....it looks really good, havn't read it yet, but I will....

  7. #7

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    No, i don't have that book.

    I have done game loops before, but i've always done it by checking if it's time to do the calcuations, if not then i wait. (to that effect anyway. I actually do the calculations then wait to render).

    I don't want to do it that way unless i have to though.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  8. #8
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    I've always done it by timebased movement like your trying to do. Basically I put this at the top: (sory its VB
    VB Code:
    1. '------Basic time based loop handling---------------------------------------------------------------------------
    2. lngLstTickCount = lngTickCount
    3. lngTickCount = GetTickCount()
    4. intTickDiff = IIf(lngTickCount - lngLstTickCount < 2000, lngTickCount - lngLstTickCount, 8)
    5. 'If extremly long lag the IIf stops objects based on time from moving too much.
    6. If intTickDiff = 0 Then intTickDiff = 1 'Prevents division by zero
    7. sngTickDiv = intTickDiff / 1000
    8. '---------------------------------------------------------------------------------------------------------------

    Then where something move:
    VB Code:
    1. PlayerXPos = PlayerXPos + (RunSpeed * (sngTickDiv))

    On my lastest project it seemed to go very strange and jumpy though. It relies on the idea that the current frame will take the same amount of time as the last one. However if you use the Performance Counter instead of GetTickCount then I guess it will be better, but I can't seem to get the performance counter to work in VB .
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  9. #9

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    I think i've done what you said, but it's still slower when i make the rendering take ages (by making loads of sprites)!

    This is my main movement code:

    Code:
    void GameThink(void)
    {
    	LastThink = CurrentGetTickCount;
    	CurrentGetTickCount = GetTickCount();
    	
    	AlterVelocityBasedOnKeyboard()
    
    	//Move the ship
    	Ship.Move();
    	Delta = ((float)CurrentGetTickCount-(float)LastThink)/1000.0f;
    }
    It is called in this loop:

    Code:
    while( uMsg.message != WM_QUIT )
    {
    	if( PeekMessage( &uMsg, NULL, 0, 0, PM_REMOVE ) )
    	{ 
    		TranslateMessage( &uMsg );
    		DispatchMessage( &uMsg );
    	}
           else
    	{
    		GameThink();
    	    Render();
    	}
    }
    and i'm doing position = position + velocity*delta when i move an object.

    I'm also doing the same when increasing the velocity using the arrow keys.

    The only think i can think of that could be wrong is if i need to change my acceleration code to consider time, but i'm not sure how to.
    Last edited by SLH; May 13th, 2004 at 10:42 AM.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  10. #10
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    Yeah the acceleration must also be set using the time. I think its just the same:
    Vel = Vel + Acc * delta

    if not try:
    Vel = Vel + Acc * delta * delta

    I think its the first though.
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  11. #11
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    Thinking of it yes it is:
    Code:
    if (KeyPressed)
    {
      Acc = 10;
    }
    else
    {
      Acc = 0;
    }
    Vel += Acc * delta;
    Vel -= Vel * CoF; // This is just to add friction so there is a max speed.
    Pos += Vel * delta;
    This will work quite nicley
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  12. #12

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    Vel -= Vel * CoF;

    That is the line i'm having trouble with, when the computer runs fast, this'll have more effect that when it's ran slower, as a result you're able to travel fast when the computer is slow.

    I've also tried Vel -= Vel * CoF * Delta; but that doesn't work either.

    Thanks for all your help btw.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  13. #13
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Vel -= Vel * CoF; // This is just to add friction so there is a max speed.
    Vel *= (1-CoF);
    which could be one constant
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  14. #14
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    btw Gettickcount isn't that accurate, especially on slow computer.. use multimedia timer or QPC
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  15. #15
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    Vel *= (1 - CoF) * delta;

    This should be it I think.

    Thanx keda, I was thinking that looked strange what'd done.

    I used this on a project of mine that was based on a constant frame rate:
    VB Code:
    1. Public Sub CalcPosition(ByRef X As Single, ByRef Y As Single, ByRef XVel As Single, ByRef YVel As Single, _
    2.                         ByVal XAcc As Single, ByVal YAcc As Single, ByVal CoFriction, ByVal GravityOn As Boolean)
    3.     If Mode = 0 Then
    4.         XVel = XVel + XAcc
    5.         YVel = YVel + YAcc
    6.     ElseIf Mode = 1 And GravityOn Then
    7.         XVel = XVel + XAcc
    8.         YVel = YVel + YAcc + Gravity
    9.     End If
    10.    
    11.     XVel = XVel - (XVel * CoFriction)
    12.     YVel = YVel - (YVel * CoFriction)
    13.    
    14.     X = X + XVel
    15.     Y = Y + YVel
    16.    
    17. End Sub
    Basically I would expect you put * delta on the end of all these lines ?
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  16. #16
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    Posted by kedaman
    btw Gettickcount isn't that accurate, especially on slow computer.. use multimedia timer or QPC
    The file I attached further up uses the QPC .
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  17. #17
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    lol.. don't throw everything in a function, it'll be slower that way
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  18. #18
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    Posted by kedaman
    lol.. don't throw everything in a function, it'll be slower that way
    This is only for VB version, I'm gonna be rewritting the project in C++ once I have it working in VB, then the function will be an inline one .
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  19. #19

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    Ok, i've tried all your suggestions, but i still can't get it to work. I'm probably being really dumb so i'll post what i have so far.

    Code:
    #define TimeAltered(x) (x*Delta)
    /////////////////
    LastThink = CurrentGetTickCount;
    CurrentGetTickCount = GetTickCount();
    if(KEYDOWN(InputBuffer,DIK_UP))
    {
    	Ship.Velocity.x += Delta*(cos(Ship.Rotation+D3DX_PI/2)*5);
    	Ship.Velocity.y += Delta*(sin(Ship.Rotation+D3DX_PI/2)*5);
    }
    Velocity.x *= TimeAltered(0.98);
    Velocity.y *= TimeAltered(0.98);
    
    Position.x += TimeAltered(Velocity.x);
    Position.y += TimeAltered(Velocity.y);
    Render();
    Delta = ((float)CurrentGetTickCount-(float)LastThink)/1000.0f;
    This is pretty much the game loop.
    Last edited by SLH; May 13th, 2004 at 11:40 AM.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  20. #20
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    You do know it doesn't show delta being set anywhere in the code you just gave?
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  21. #21

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    doh, edited.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  22. #22
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    I would have done:
    Code:
    #define TimeAltered(x) (x*Delta)
    /////////////////
    
    // Somewhere before the game loop starts...
    
    // Will just initiate the CurrentGetTickCount for the first loop...
    CurrentGetTickCount = GetTickCount() - 10;
    
    /////////////////
    LastThink = CurrentGetTickCount;
    CurrentGetTickCount = GetTickCount();
    Delta = ((float)CurrentGetTickCount-(float)LastThink)/1000.0f;
    if(KEYDOWN(InputBuffer,DIK_UP))
    {
    	Ship.Velocity.x += Delta*(cos(Ship.Rotation+D3DX_PI/2)*5);
    	Ship.Velocity.y += Delta*(sin(Ship.Rotation+D3DX_PI/2)*5);
    }
    Velocity.x *= TimeAltered(0.98);
    Velocity.y *= TimeAltered(0.98);
    
    Position.x += TimeAltered(Velocity.x);
    Position.y += TimeAltered(Velocity.y);
    Render();
    Just because you need to know delta before going into the loop.

    What is happening to it now, is it just running unpredictably or just slower on slower machines?
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  23. #23

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    I've changed the delta line now, thanks.

    At the moment when running fast (rendering taking little time) the ship barely moves at all, and when running slowly (rendering taking longer) the ship moves fast (all be it in large steps).
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  24. #24
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    Isn't that right?, try increasing the 5 you have as the velocity and it should appear normal when the loop is fast and just jumpy when the loop takes a long time. If it looks like they are both going the same speed just ones smoother then alls good. Slight discrepancies can be cleared out by using the performance counter.
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  25. #25
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    If your not sure send me the exe and I'll try it on mine
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  26. #26
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    oh.. one more thing Electroman, why do you have this delta thing? You could make sure a loop takes a certain amount of time instead.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  27. #27
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    Thats what I said higher up ^^^^.
    I normally use a frame limiter. Consoles are restricted to only working on a frame limiter, they have a video frame every 16ms and if you miss it then you gotta wait till the next one, which means on a console you can only have 60fps or 30fps.
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  28. #28

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    Originally posted by Electroman
    Isn't that right?, try increasing the 5 you have as the velocity and it should appear normal when the loop is fast and just jumpy when the loop takes a long time. If it looks like they are both going the same speed just ones smoother then alls good. Slight discrepancies can be cleared out by using the performance counter.
    Yeah, i think it's right, but it doesn't work. The slow one goes miles faster and in big jumps, but the faster one hardly moves.

    Kedaman: That's what i'd do previously, but i want to try and do it this way as it's better (it'll run as smoothly as the computer can handle).

    If i can't get this sorted by today then i think i'll just stick with a simple loop though.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  29. #29
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    yeah I see what you are getting at you two. How about if you store the velocities in relative units instead, and you can keep out the delta
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  30. #30

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    But to store the velocities as relative i would have to multiply them by delta??

    Right now the velocities represent movement per second, i then scale that up or down based on the time elapsed. It just gets complicated when you think about acceleration etc.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  31. #31
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    I think the problem just lies with the GetTickCount's acuracy now. Becuase if you think about it the error has been squared when you go into acceleration and that will mess things up alot. Explains my my current project didn't like the Time based method suddenly. Its the first time I properly added Acceleration.
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  32. #32

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    Ok, i'll have a go using queryperformancecounter and let you know the results.

    Thanks a lot for all your help, both of you.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  33. #33
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    The stored velocities would be pixels or whatever/frame, and by dividing off delta(seconds per frame), you get pixels or whatever/second. The idea is that you run a test loop to find delta on beforehand and then adjust all measures given in seconds^-n in frame^-n instead
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  34. #34
    Fanatic Member alkatran's Avatar
    Join Date
    Apr 2002
    Location
    Canada
    Posts
    860
    Personnaly, I store the last 10 frames, then average the time between them. I use that for my time. It makes the speed not do a MASSIVE jump if you pause code execution (by dragging the form, for example).
    Don't pay attention to this signature, it's contradictory.

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