Hi
I´m working on a 2d-platformgame and
i have a problem whit "Delta time" in
my jumproutine,the X movement is ok,
X speed is always the same no matter what Fps
the game is running at,but the jumpspeed
follows the Fps,i know i also should calculate
the Jumpspeed whit Delta,but how?
Here is some code to run.It´s not from my game
but it shows you the problem.(try different delay´s)
Thanks
Henrik:)
Graphics 640,480
SetBuffer BackBuffer()
y#=300
yd#=10
Global speed#,oldms#,delta#,ms2#,xd#,curfps2#,x#
While Not KeyDown(1)
Cls
;delta
If curfps2=0 curfps2=75
oldms=ms2-oldms
delta=oldms
xd=75/curfps2
oldms=ms2
ms2=MilliSecs()
speed=xd
;jump
y=y-yd yd=yd-(0.2);calculate whit delta here
If yd<-10 yd=10;and here i think
Rect 320,y,10,10
Rect x+speed,330,10,10 x=x+speed If x>640 x=0
Line 0,315,640,315
Line 0,45,640,45
Text 10,10,"yd "+yd
Text 10,20,"fps "+curfps2
Text 10,350,"x speed(delta) "+speed
;fpscounter
curTime = MilliSecs()
If curTime > checkTime Then
checkTime = curTime + 1000
curFPS2 = fpscounter
fpscounter = 0
Else
fpscounter = fpscounter + 1
End If
Flip False
Delay 13
;try "flip false" and different
;delays to simulate different Fps.
;Delay 13=75fps(13.33333/1000)=75
Wend
I´m working on a 2d-platformgame and
i have a problem whit "Delta time" in
my jumproutine,the X movement is ok,
X speed is always the same no matter what Fps
the game is running at,but the jumpspeed
follows the Fps,i know i also should calculate
the Jumpspeed whit Delta,but how?
Here is some code to run.It´s not from my game
but it shows you the problem.(try different delay´s)
Thanks
Henrik:)
Graphics 640,480
SetBuffer BackBuffer()
y#=300
yd#=10
Global speed#,oldms#,delta#,ms2#,xd#,curfps2#,x#
While Not KeyDown(1)
Cls
;delta
If curfps2=0 curfps2=75
oldms=ms2-oldms
delta=oldms
xd=75/curfps2
oldms=ms2
ms2=MilliSecs()
speed=xd
;jump
y=y-yd yd=yd-(0.2);calculate whit delta here
If yd<-10 yd=10;and here i think
Rect 320,y,10,10
Rect x+speed,330,10,10 x=x+speed If x>640 x=0
Line 0,315,640,315
Line 0,45,640,45
Text 10,10,"yd "+yd
Text 10,20,"fps "+curfps2
Text 10,350,"x speed(delta) "+speed
;fpscounter
curTime = MilliSecs()
If curTime > checkTime Then
checkTime = curTime + 1000
curFPS2 = fpscounter
fpscounter = 0
Else
fpscounter = fpscounter + 1
End If
Flip False
Delay 13
;try "flip false" and different
;delays to simulate different Fps.
;Delay 13=75fps(13.33333/1000)=75
Wend