MMF Built-in Movement Formulae
Author: | DeadmanDines
|
Submitted: | 16th December, 2003
|
Views: | 5532
| Rated: |
|
|
I know there are a few people who crave a little more control over the movements in their games but for some reason or other don't want to use custom or 'static' movements to do it. These can also apply to those who build their custom movements using the Bouncing Ball Object, as I used to.
These formulae are simple enough, and not 100% accurate (I think speed in BIMs (Built In Movements) are updated after every event loop rather than at certain time intervals, you see).
Anyway, here are a few that should help:
Intro:
The following units are used:
pps -- pixels per second; the number of pixels travelled per second at the current speed.
units -- the speed setting for BIMs. A speed of 100 is a speed of 100 'units'.
s -- seconds.
px -- pixels
Units to PPS
This lets you convert a speed in units to the speed in PPS.
pps = speed * 6
Distance from speed and time
If you know the BIM speed (units) and amount of time taken (seconds), you can calculate the distance your object should travel (px).
distance = ( speed * 6 ) * time
Speed from distance and time
If you know how far the object has travelled (in px) and how long it took (seconds), then you can find out what speed (in Units) it must have been going in. This can also be used to work out approximately what speed you must be at to get somewhere in a certain time.
speed = ( distance / time ) / 6
Time from distance and speed
If you know how far (in px) the object has travelled, and at what speed (units), you can work out how long it took.
time = ( distance / speed ) / 6
So...
Hopefully, those may help someone. If you spot any errors in these, or have any other comments, please say so. Remember; these are not 100% accurate for the reasons I stated above, and so should only be used to estimate.
Eg: an object travelling at 100u for 0.5s could travel anywhere between 280 and 320 pixels depending on slowdown, etc. The equations will give you 300px.
|
|
DeadmanDinesBest Article Writer Registered 27/04/2006
Points 4758
|