There are two ways I do it.. Itterative (works by difference of time since last frame) and the other is time since start which I find easier.
TIME SINCE START:
StartTime = timer()
StartX# = 0.0
StartY# = 0.0
SpeedX# = 5.0
SpeedY# = 10.0
Gravity# = -9.8
X# = 0
Y# = 0
do
CurrentTime = timer()
TimeOffset# = ((CurrentTime - StartTime) * 0.001)
X# = (TimeOffset# * SpeedX#) + StartX#
Y# = (TimeOffset# * SpeedY#) + StartY# + (TimeOffset# * TimeOffset# * Gravity#)
loop
Now that code works on these principles:
newPos = origPos + (Time * Speed)
newPos = origPos + (Time * Speed) + (Time * Time * Acc)
The first forumla represents constant speed and displacement, the second is used for speed, acceleration/retardation and displacement.
In my code, I assume X is positive to the right and Y is positive in the upwards direction (hence gravity being negative as it forces downwards).
Obviously with that code, you can then use the X# and Y# to position what ever you want (particle, objects, etc).
You can also use the second formula where wind is involved in the X. Simply set a variable for wind force and then assume it is an acceleration in a direction.
These get much more complicated when you start to involve things like wind resistance, friction, etc.
The other method is similar, except instead of taking the time since the start, you use time since the last frame and the foruma's are a little different as you need to work out the speed relative for the frame.
X# = 0.0
Y# = 0.0
SX# = 10.0
SY# = 10.0
G# = -9.8
dT# = 1.0
lastFrameTime = timer()
do
dT# = (timer() - lastFrameTime) * 0.001
SY# = SY + (dT# * G#)
X# = X# + (SX# * dT#)
Y# = Y# + (SY# * dT#)
loop
This works everything out relative to the last frame, not absolutely since the begining.
This changes the speed each time as the vertical component of the speed decreases due to gravity (in this case).
I think the above code is correct - I did it off the top of my head without checking.
I personally normally go for the first set of formula's as I think it would be more accurate to work out the position based on the time difference since the begining rather than itterative each frame. This is because any errors will build up in the itterative method, however in the absolute method the errors should be kept down. On the other side, the itterative method uses less variables and logically less memory (all be it next to no difference, but if you use this kind of principle and multilpy it by thousands, then you see my point). EG: A particle system with 1,000,000 particles, each particle having 2 excess floats and an excess integer then I think it works out at 6 bytes per particle and therefore 6,000,000 bytes of memory..
Just a thought!