I would like make a safety solution that control the speed of my games, in order to run the game same speed both on slow and fast computers.
I invented this code for this, what clocks the fps:
Code: Select all
dim as integer fps,frame
dim as double starttime
if timer-starttime>1 then
print "ESC: exit, FPS: "& str(fps)
loop until inkey=Chr$(27)
It seems to be good for me, but what is your opinion, as a skilled FB programmer?
I think if I can get the fps, then e.g. I can move the game objects by pixel amount, in inverse ratio to fps, so for example bigger fps would result in smaller move on a fast computer and less fps would result in larger move on a slow computer. Or I can give the suitable value to Sleep command.
I don't know, are these good conceptions?