This shows the effect of varying FPS rates.
Also, check the flip timer delay when you hold down LMB. This is the time wasted waiting for the next vertical blank interrupt. This can be a good few milliseconds when using Flip True or VWait, precious time that could be spent updating say AI e.t.c
Also, check the flip timer delay when you hold down LMB. This is the time wasted waiting for the next vertical blank interrupt. This can be a good few milliseconds when using Flip True or VWait, precious time that could be spent updating say AI e.t.c
Global delta.tDeltaTime = CreateDeltaTime() Graphics 800,600,32,2 i=CreateImage(64,64) SetBuffer ImageBuffer(i) Color 60,60,60 Rect 0,0,64,64 Color 127,127,127 Rect 0,0,32,32,1 : Rect 32,32,32,32,1 SetBuffer BackBuffer() Color 255,255,255 s.tSprite = CreateSpriteType(i) startTime = MilliSecs() While Not KeyHit(1) UpdateSprites() If s\x>=800 timeTaken = (MilliSecs() - startTime) startTime = MilliSecs() s\x = 0 End If Cls DrawSprites() Text 0,0,"fps: "+delta\currFPS Text 0,20,"last trip across screen took "+timeTaken+"ms , (should be approx 8000ms)" Text 0,40,"Hold LMB to 'Flip True'. When using Flip True, this is the time 'wasted' by the flip command" Text 0,60,"waiting for the next vertical blank: "+lastFlipTimer+"ms" Text MouseX()-300,MouseY()+16,"Move mouse left/right to adjust the delay: "+MouseX()/15+"ms" flipTimer=MilliSecs() Flip MouseDown(1) lastFlipTimer=MilliSecs() - flipTimer UpdateDeltaTime(delta) Delay MouseX()/15 Wend Type tDeltaTime Field deltaTime# Field lastTime,frameTime,frames,currFPS End Type Type tSprite Field image% Field x#,y# Field vx# End Type Function CreateSpriteType.tSprite(img) s.tSprite = New tSprite s\x = 0 : s\y = 350 s\image = img s\vx = 100 ;100 pixels *per second* (at this speed, time to cross 800 pixels = 8000ms) Return s End Function Function UpdateSprites() Local s.tSprite For s = Each tSprite s\x = s\x + s\vx * delta\deltaTime ;any value that changes over time should be multiplied by 'deltaTime' ;s\rot = s\rot + addrot * delta\deltaTime Next End Function Function DrawSprites() Local s.tSprite For s = Each tSprite DrawImage s\image,s\x,s\y Next End Function Function CreateDeltaTime.tDeltaTime() Local d.tDeltaTime = New tDeltaTime d\lastTime = MilliSecs() d\frameTime = 0 Return d End Function Function UpdateDeltaTime(d.tDeltaTime) Local timeNow = MilliSecs() d\deltaTime = (timeNow - d\lastTime) * .001 ; .001 = (1.0 / 1000ms) = the lowest resolution of Millisecs() d\lastTime = timeNow d\frames = d\frames + 1 If timeNow - d\frameTime > 999 d\frameTime = d\lastTime d\currFPS = d\frames d\frames = 0 End If End Function