# Pixle Calc. Problem

Show 80 post(s) from this thread on one page
Page 1 of 2 12 Last
• 03-14-2005
loopshot
Pixle Calc. Problem
For the game i have been making i have been using some physics to create realistic, parabolic, movments.

i first use Vf = Vi + at to find the next velocity from the last one
then i change Vi = Vf in order to create the change in velocity
then DeltaY = Vi(Sin(theta)(DeltaTime) - 1/2(Gravity(DeltaTime^2)
then DeltaX = Vi(Cos(theta)(DeltaTime)
(i love physics)

the problem is that since i am having this program run at 60 frames per second i use 1/60 for my DeltaTime, right. but the chance from one position to the next it to small becouse the time change it to small so the object dose not move becouse you cant draw part of a pixle, and if i up the time frame it of corse moves way to fast.

Any one with any tricks on the subject plz tell me and thank you for your input
• 03-14-2005
loopshot
Sorry chance should me change
• 03-14-2005
Perspective
Make your time based movement depend on time, not frames. That way you can have any frame rate you want and the motion still takes the same amount of time.
• 03-15-2005
loopshot
• 03-18-2005
loopshot
I have been looking around and have not been able to find any thing one implementing time, can some one point me in the right direction, that would be great.

it would also be great if some one could explain a little about how to implement what Perspective was talking about, after some thought i dont really understand how that would help me with my pixle problem becouse i would still be using small incremets of time, which would still not show up when the flote converts to int.

thanks for the help
• 03-18-2005
VirtualAce
Quote:

I have been looking around and have not been able to find any thing one implementing time, can some one point me in the right direction, that would be great.
I know we discussed this on the game programming forum because Shakti and I use different timing methods and there is a post here which talks about both approaches.

Do a search on TimeGetTime() and GetTickCount().
• 03-18-2005
loopshot
I Searched TimeGetTime() and GetTickCount() in different cominations them seprate and i did not find much but i will look them up on msdn i guess, i did not see the posts before becouse i was searching for just time implemetation, and time tracking, time ect.
thanks for listing the functions though
• 03-18-2005
MrWizard
You should probably look into high-resolution timers. Those other timers are junk.

QueryPerformanceFrequency
QueryPerformanceCounter
• 03-18-2005
loopshot
Thanks Mr Wizard :)

another question that i have is, when seting up all of this time stuff for when to recalculate every thing, do i check the time, and have it continue to loop my program, then check agian for == or greater than, or do i loop though only that specific spot untill the condition it met then continue though my program.(remember this is a game and the time period is the time between when to calculate my physics agian)
• 03-18-2005
Shakti
The way I do it (thanks to some guy over at www.gamedev.net):
Code:

```// This function is called ONCE each frame float Val2Proc() {         static double      time_elapsed;         static __int64      pc1, pc2;         static __int64      pf;         QueryPerformanceCounter((LARGE_INTEGER*)&pc2);         time_elapsed = double(pc2-pc1) / double(pf);         QueryPerformanceFrequency((LARGE_INTEGER*)&pf);         QueryPerformanceCounter((LARGE_INTEGER*)&pc1);         // procPower is a global float i have. 50 is a number I just chose.         procPower = (float)time_elapsed*50.0f;            return (float)time_elapsed; }```
Then, I multiply everything that should be timebased (like cameraspeed, the speed of an object) with procPower. There are lots of ways you could do it, this is one. most likely not the best way but I think it does the job just fine.
• 03-19-2005
VirtualAce
Quote:

QueryPerformanceCounter((LARGE_INTEGER*)&pc2);
That's the one I was looking for not GetTickCount().
• 03-21-2005
Tronic
Depending on what hardware you support, always remember that the machine the game will want to run on / is capable of running on might not have harware timers. I personally support both hardware and multimedia timers in all my games for older computers.
• 03-22-2005
VirtualAce
Quote:

Depending on what hardware you support, always remember that the machine the game will want to run on / is capable of running on might not have harware timers. I personally support both hardware and multimedia timers in all my games for older computers.
Every system running windows XP/98 SE/2K can use those functions. They are part of the API. If you are not using Windows then of course you will have to use your platform's equivalent. All and I mean ALL CPUS have hardware timers.
• 03-22-2005
loopshot
thanks alot for all of your help
• 03-22-2005
loopshot
Shakti, why do you return (float)time_elapsed;, when you have already set procPower to what you want? is it just to make the function more usefull by allowing the coder to also use it to return the time elapsed between frames if needed?

Also, why in "procPower = (float)time_elapsed*50.0f;" do you multiply time_elapsed by 50?

Also, why in "time_elapsed = double(pc2-pc1) / double(pf);" do you divide by the frequency pf?
Show 80 post(s) from this thread on one page
Page 1 of 2 12 Last