Restored from previous forum. Originally posted by MrVainSCL.
Hi @ all
I found a small example how to run your program on all PCs in same speed but FPS independent... So i coded this small example... Btw i am not really happy with this result, because its not really smooth on my system ;(( But mabye this will help you...
Code: Select all
;-----------------------------------
;
; Run your prog in same speed on all
; PCs but FPS independent - Example
;
;-----------------------------------
;
#scrw = 640 ; screenwidth
#scrh = 480 ; screendheight
#scrd = 16 ; screendepth
;
;-------- Init all the needed system stuff --------
;
If InitSprite() = 0 Or InitKeyboard() = 0
MessageBox_ (0,"Can't open DirectX 7 or later", "ExampleSource", #MB_ICONINFORMATION|#MB_OK)
End
EndIf
;
;-------- Init Screen and load stuff --------
;
If OpenScreen(#scrw,#scrh,#scrd,"ExampleSource") = 0
MessageBox_ (0,"Could not open 640x480x16 screen", "ExampleSource", #MB_ICONINFORMATION|#MB_OK)
End
EndIf
;
SetPriorityClass_(GetCurrentProcess_(), 13 ) ; 13 = HIGH_PRIORITY_CLASS
;
;-------------------------------
;
yspeed.f = 0.2
oldmillisecs = GetTickCount_()
;
;-------- Test MainLoop --------
;
Repeat
deltatime = GetTickCount_() -oldmillisecs ; Maybe use CurrentTime !? Mhhh...
oldmillisecs = GetTickCount_()
;
ClearScreen(RGB(0,0,0)) ; ClearScreen black
;
y = y+deltatime*yspeed ; this is movement by time elapsed.
;
If y>480 : y=0 : EndIf
;
StartDrawing(ScreenOutput())
FrontColor(RGB(255,255,255))
Box(320,y,16,16)
StopDrawing()
;
FlipBuffers()
; ;
ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape)
End
;-------------------------------
greetz
MrVainSCL! aka Thorsten