News:

PlayBASIC2DLL V0.99 Revision I Commercial Edition released! - Convert PlayBASIC programs to super fast Machine Code. 

Main Menu

Banshee Studios Timing routine

Started by Draco9898, January 24, 2005, 03:50:25 PM

Previous topic - Next topic

Draco9898

Hi, I found this excellent timing routine on banshee studios webpage, and I thought everyone could use it :) It auto- regulates itself so that uneven processing can't mess up your game and your game will run the same on all machines regardless of FPS as long as you use it right :) I hope Banshee studios don't mind me posting it here  :lol:

Anyway heres the codez:

PlayBASIC Code: [Select]
`Make Game time variables and stuff
Dim GameTime(5)
Global gameTime
resetGameTime()


Do
gameTimeStabliser()
cls 0
Text 10,10,GameTime
Sync
Loop


`Reset game time stabliser
Function resetGameTime()
For gs=1 To 6
gameTimeStabliser()
Next
EndFunction



`Game time stabliser
Psub gameTimeStabliser()
For g=1 To 4
GameTime(g)=GameTime(g+1)
Next
time=Timer()
GameTime(5)=time-lastTime
lastTime=time
GameTime=(GameTime(1)+GameTime(2)+GameTime(3)+GameTime(4)+GameTime(5))*0.2
EndPsub



(login required)
DualCore Intel Core 2 processor @ 2.3 ghz, Geforce 8600 GT (latest forceware drivers), 2 gigs of ram, WIN XP home edition sp2, FireFox 2.

"You'll no doubt be horrified to discover that PlayBasic is a Programming Language." -Kevin

kevin

#1
Just be aware, that there is a down fall of using scalars, as it means you really have to use ray based collision.   If you use a regional based collision system as seen languages like PB/DB/BB etc etc, you will get 'leap froging' on slower machines.

 It occurs when a fast moving object is moved to accommodate the lower physical rate, and in doing so, the object can skip over it's targets / walk through walls etc...

Draco9898

QuoteJust be aware, that there is a down fall of using scalars, as it means you really have to use ray based collision.   If you use a regional based collision system as seen languages like PB/DB/BB etc etc, you will get 'leap froging' on slower machines.

  It occurs when a fast moving object is moved to accommodate the lower physical rate, and in doing so, the object can skip over it's targets / walk through walls etc...

OH ouchies  :blink:
DualCore Intel Core 2 processor @ 2.3 ghz, Geforce 8600 GT (latest forceware drivers), 2 gigs of ram, WIN XP home edition sp2, FireFox 2.

"You'll no doubt be horrified to discover that PlayBasic is a Programming Language." -Kevin