Hello I have a short question,
after Implementing Indiepaths (Thanks man!) quite cool delta timing routine and with a bit of tweaking I managed to free a whole lot of ressources.
This was back on my laptop (not entirely powerful but not weak either) where the game went from 20-40fps to a stable 55. Now back on my main PC the game either proves to be entirely unplayable, or it is so slow that it is painful.
Now I already found the culprit - removing the line where the Delta is set to 1 when it goes above 1 fixes most of the problems..
I tried with vsync and without but nothing helped...
Some parts of the game with accurate timing still act weird - any help or insight on this problem would be greatly appreciated!
Graphics 800,600,32,NOSYNC
AutoMidHandle True
Type DeltaTime
Global DeltaTList :TList
Field OldTime :Int
Field ElapsedTime :Int
Field dFps :Float
Field dDelta :Float
Field CurrFps :Int
Field FPSCounter :Int
Field CurrTime :Int
Field CheckTime :Int
Method New ()
If DeltaTList = Null Then DeltaTList = New TList
DeltaTList.AddLast Self
End Method
Method Destroy ()
DeltaTList.Remove Self
End Method
Function Create:DeltaTime(Fps:Float)
Local dTime:DeltaTime = New DeltaTime
dTime.dFps = Fps
dTime.dDelta = 1000/Fps
Return dTime
End Function
Method Update()
Self.CurrTime = MilliSecs()
Self.ElapsedTime = Self.CurrTime - Self.OldTime
Self.OldTime = Self.CurrTime
If Self.CurrTime > Self.CheckTime
Self.CheckTime = Self.CurrTime + 1000
Self.CurrFps = Self.FPSCounter
Self.FPSCounter = 0
Else
Self.FPSCounter:+1
EndIf
End Method
Method FPS()
Return Self.CurrFps
End Method
Method CurrDelta:Float()
Return Double(Self.ElapsedTime)/Self.dDelta
End Method
Method SetFPS(NewFPS:Float)
Self.dFPS = NewFPS
Self.dDelta = 1000/Self.dFPS
End Method
End Type
SetMaskColor(255,0,255)
'Global blob:TImage = LoadImage("C:\blitzmax\samples\simonh\fireworks\spark.png")
Global Delta1:DeltaTime = DeltaTime.Create(35.0) ' Normal 35 FPS
Local Delta:Double
Global ScreenUpdate:Double
Global bx:Double=10
While Not KeyHit(KEY_ESCAPE)
Delta1.Update()
Delta = Delta1.CurrDelta()
If Delta > 1 Then Delta = 1 ' Delta should never be bigger than 1.
' -------------------------------GFX FUNCTIONS ---------------------------
ScreenUpdate = ScreenUpdate + Delta
If ScreenUpdate > 0.30 Then
Cls
RenderGFX(ScreenUpdate)
ScreenUpdate :- 0.3
Flip
EndIf
' ------------------------------------------------------------------------
'FlushMem
Wend
Function RenderGFX(Delta:Double=1)
DrawOval bx,100,10,10
bx=bx+(Delta * 2)
DrawText Delta1.FPS()+" FPS",10,10
If bx>799 Then bx = 0
End Function
Here is the code for the routine. Can anyone tell me what's wrong and how I can mend it ?
after Implementing Indiepaths (Thanks man!) quite cool delta timing routine and with a bit of tweaking I managed to free a whole lot of ressources.
This was back on my laptop (not entirely powerful but not weak either) where the game went from 20-40fps to a stable 55. Now back on my main PC the game either proves to be entirely unplayable, or it is so slow that it is painful.
Now I already found the culprit - removing the line where the Delta is set to 1 when it goes above 1 fixes most of the problems..
I tried with vsync and without but nothing helped...
Some parts of the game with accurate timing still act weird - any help or insight on this problem would be greatly appreciated!
Graphics 800,600,32,NOSYNC
AutoMidHandle True
Type DeltaTime
Global DeltaTList :TList
Field OldTime :Int
Field ElapsedTime :Int
Field dFps :Float
Field dDelta :Float
Field CurrFps :Int
Field FPSCounter :Int
Field CurrTime :Int
Field CheckTime :Int
Method New ()
If DeltaTList = Null Then DeltaTList = New TList
DeltaTList.AddLast Self
End Method
Method Destroy ()
DeltaTList.Remove Self
End Method
Function Create:DeltaTime(Fps:Float)
Local dTime:DeltaTime = New DeltaTime
dTime.dFps = Fps
dTime.dDelta = 1000/Fps
Return dTime
End Function
Method Update()
Self.CurrTime = MilliSecs()
Self.ElapsedTime = Self.CurrTime - Self.OldTime
Self.OldTime = Self.CurrTime
If Self.CurrTime > Self.CheckTime
Self.CheckTime = Self.CurrTime + 1000
Self.CurrFps = Self.FPSCounter
Self.FPSCounter = 0
Else
Self.FPSCounter:+1
EndIf
End Method
Method FPS()
Return Self.CurrFps
End Method
Method CurrDelta:Float()
Return Double(Self.ElapsedTime)/Self.dDelta
End Method
Method SetFPS(NewFPS:Float)
Self.dFPS = NewFPS
Self.dDelta = 1000/Self.dFPS
End Method
End Type
SetMaskColor(255,0,255)
'Global blob:TImage = LoadImage("C:\blitzmax\samples\simonh\fireworks\spark.png")
Global Delta1:DeltaTime = DeltaTime.Create(35.0) ' Normal 35 FPS
Local Delta:Double
Global ScreenUpdate:Double
Global bx:Double=10
While Not KeyHit(KEY_ESCAPE)
Delta1.Update()
Delta = Delta1.CurrDelta()
If Delta > 1 Then Delta = 1 ' Delta should never be bigger than 1.
' -------------------------------GFX FUNCTIONS ---------------------------
ScreenUpdate = ScreenUpdate + Delta
If ScreenUpdate > 0.30 Then
Cls
RenderGFX(ScreenUpdate)
ScreenUpdate :- 0.3
Flip
EndIf
' ------------------------------------------------------------------------
'FlushMem
Wend
Function RenderGFX(Delta:Double=1)
DrawOval bx,100,10,10
bx=bx+(Delta * 2)
DrawText Delta1.FPS()+" FPS",10,10
If bx>799 Then bx = 0
End Function
Here is the code for the routine. Can anyone tell me what's wrong and how I can mend it ?