Blitz3D Framework - IDEal, any good?
Blitz3D Forums/Blitz3D Programming/Blitz3D Framework - IDEal, any good?
| ||
I was wondering if this frame work is good. I experianced flickering while using it, but that maybe because i don't use it properly. Also i sort of wondered why this is nessesary, why can't i just run a loop without doing all this? After all, why free CPU if we need it?Graphics3D 640,480 Global Camera=CreateCamera () Const GameUPS=60 ; Updates per second Local Period=1000/GameUPS Local FrameTime=MilliSecs()-Period Local Tween#, Ticks,i,Remaining,StartTime,Elapsed While Not KeyHit(1) StartTime = MilliSecs() Repeat Elapsed=MilliSecs()-FrameTime Until Elapsed Ticks=Elapsed / Period Tween=Float(Elapsed Mod Period)/Float(Period) For i=1 To Ticks FrameTime=FrameTime+Period If i=Ticks Then CaptureWorld End If UpdateGame() UpdateWorld Next RenderWorld Tween Remaining = Period - (MilliSecs() - StartTime) If Remaining > 1 Then Delay (Remaining-1) ; Free some CPU time End If Flip Wend End Function UpdateGame() ; ... End Function |
| ||
Also i sort of wondered why this is nessesary, why can't i just run a loop without doing all this? So your game runs at the same speed on any PC. Render tweening ensures that the screen is updated at the same rate on every PC, regardless of how fast the game logic is going.Its bad practice to have your game running 20x faster on a new PC than it does on an older system, since it'll be unplayable on one or the other. I don't see the point trying to code for 60fps, personally. I usually lock it to 30fps. Gives you twice as much processor time to get stuff done, with far less risk of hitting a CPU bottleneck. |
| ||
I still don't see the point of the following line:Repeat Elapsed=MilliSecs()-FrameTime Until Elapsed [code] Is it just me, or does that only ever loop once, so it could be replaced by the following: [code] Elapsed=MilliSecs()-FrameTime ...or is that to ensure that Elapsed isn't zero? |
| ||
@GfK, ah, right... how could i forget about that. Thank you for your input! |