Hi guys I put this code in a multilayer pong and it does some werid things for example the ball will hit the bottom of the screen and like stay there and moving right or left in velocity.
Then it finally corrects it's self. The point is my code shouldn't make the ball do that . It seems since I added this it doesn't work right it seems. Here is a example of the same delta timer I got in the code for my multilayer game.
You seen any problems with this?
here is the code
rem Frame limiter Delta-time Demo
sync on
sync rate 60
rem delta frame rate type
type FrameRateType
TargetFPS as float
SpeedFactor as float
CurrentTicks as float
FrameDelay as float
endtype
global delta as FrameRateType
rem starting delta time variables
delta.TargetFPS = 60
delta.FrameDelay = timer()
delta.CurrentTicks = timer()
rem x & y position for the circle
x# = 320-5
y# = 240-5
do
rem make sure it doesn't show garble text junk and updates
cls
rem my current ticks of my clock
delta.CurrentTicks = timer()
rem my speed factor so it runs the same on the other pc
delta.SpeedFactor = (delta.CurrentTicks-delta.FrameDelay) / (1000.0 / delta.TargetFPS)
rem if speed factor is less than zero start over
if delta.SpeedFactor <= 0 then delta.SpeedFactor = 0.00000000001
rem update the time
delta.FrameDelay = delta.CurrentTicks
rem move circle 2 units times speed factor so it stays the same on each pc
if upkey()=1 then x# = x# + 2*delta.SpeedFactor
if downkey()=1 then x# = x# - 2*delta.SpeedFactor
rem make the circle wrap around the screen
if x# > 650
x# = -10
else
if x# < -10
x# = 650
endif
endif
rem update the circle with the value changes
circle x#,y#,10
rem display debugg info
center text 320,0,"Frame limiter Delta-time Demo"
text 20,20,"delta.TargetFPS: "+str$(delta.TargetFPS)
text 20,40,"delta.CurrentTicks: "+str$(delta.CurrentTicks)
text 20,60,"delta.FrameDelay: "+str$(delta.FrameDelay)
text 20,80,"delta.SpeedFactor: "+str$(delta.SpeedFactor)
sync
loop
darkvee