[…]
The points that I see troublesome are:
-
Non linear trajectories.
-
Variability of results.
Exacty. Collision detection and per-frame check state/perform action
control systems are especially troublesome.
Simply put; in a time based system, you have to trow away the idea of a
discrete timeline.
Or do you?
No! It’s perfectly possible to convert back and forth between the actual
frame rate and any other frame rate. You can just keep your "engine"
running at whatever frame rate you want, and then interpolate all actual
rendering coordinates between the last two frames generated by the engine.
From cs.h of Project Spitfire (now used in SKobo):
—8<----------------------------------------------------------------
typedef struct
{
/* 24:8 fixpoint values /
int x, y; / logic position */
int xv, yv;
int xa, ya;
} cs_vector_t;
typedef struct
{
/* 24:8 fixpoint values here as well */
cs_vector_t v;
int ox, oy; /* last position (for filtering) */
int gx, gy; /* graphic position */
/* (changed != 0) if gx or gy changed during the last update.
* This is a bit mask with the same format as the coords,
* which means that you can mask some low bits off to set
* a coarse movement sensitivity threshold.
* Ex. (changed & 0xffffff00) == "gx or gy moved to
* another pixel posn."
*/
int changed;
} cs_point_t;
---------------------------------------------------------------->8—
cs_vector_t is the part that the game engine should be concerned with.
(You may ignore the (xy,yv) and (xa,ya) pairs - they’re from the original
control system of PSF, which uses them to automatically manage speed and
acceleration. SKobo doesn’t use them at all.)
cs_point_t is used by the graphics engine to convert the “stream of
frames” from the game engine frame rate (fixed at 60 Hz for PSF and 30 Hz
for SKobo) to the screen frame rate (limited to the monitor refresh rate
where possible).
I’m just about to uploaded a test program for the SKobo graphics engine,
which demonstrates perfectly smooth animation with a control system frame
rate of 5 Hz (graphics from XKobo). It’ll be at
http://olofson.net/download/enginetest.tar.gz
in a few minutes.
It’s using an “old” version of the engine, which explains the cool "zoom"
bug when starting the program. All objects are insitialized at (0,0),
causing the engine to interpolate their movement to their real starting
positions over the first control system frame, which is 200 ms…
BTW, my latest hack of XKobo 1.11+ is on that site as well, just peel the
path off. Nothing special; just minor improvements of Izumo’s sound FX
engine.
//David Olofson — Programmer, Reologica Instruments AB
.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------------> http://www.linuxdj.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |
--------------------------------------> david at linuxdj.com -'On Wednesday 05 September 2001 11:30, A. R. Mosteo Chagoyen wrote: