-* How do you all fix the FPS ratio on your programs under SDL?
I used to do something like:
#define FPS (1000 / 35)
int ActualTime, LastTime;
while(!done)
{
GameFrame();
ActualTime = SDL_GetTicks();
if (ActualTime < LastTime + FPS)
SDL_Delay(LastTime + FPS - ActualTime);
LastTime = ActualTime;
}
This is supposed to give a fixed ratio of 35 frames per second…
I know I should use the elapsed time between frames to move
sprites according to this time, but that involves asigning
speeds (pixels per second) to sprites (maybe in float coord?)
and some integration methods for collision detection…
The above way is very simple but maybe there is a better way
to do it, maybe using a SDL_SuperBFunction() I don’t know
-* The same goes for moving a sprite/square from a surface to
another… (by example for erasing all the old sprites by moving
the virtual screen background over there, or by moving the
entire screen)… must I do them by my self
-* I would like to know, by example, how to load a PCX (or any other
format, please NOT BMP, I hate them) into a surface, convert it
to the same depth than the screen, set a ColourKey (0,0,0) and
blit it in (x,y) coordinates on the screen…
-* And finally, there was a Linux-stupid-and-crap-programs compo on
es.comp.os.linux.programacion newsgroup and I did some SDL programs.
If anyone would like to take a look to them (just 4Kb) and tell
me if they include bad SDL code and how I should make things, I will
be very grateful:
http://web.jet.es/s.romero/ecol_compo/boom.tar.gz
http://web.jet.es/s.romero/ecol_compo/lands3d.tar.gz
http://web.jet.es/s.romero/ecol_compo/vida.tar.gz
Those are my very first programs with SDL (with the speccy emulator),
a particle simulator (a programmer’s art tree exploding), and pseudo3d
landscape and John Conway’s Life.
Sorry for the big post and thx a lot for any help.
Please answer if possible, this post has all my SDL doubts :-)–
-----------------------------------------------------
NoP / Compiler – sromero at unix-shells.com |
---|
POWERED BY - Linux RedHat 6.0 - Reg. User #74.821 |
http://web.jet.es/s.romero |
~-----------------------------------------------------~