frame limiting code by mark modified for 2d prob?

Blitz3D Forums/Blitz3D Beginners Area/frame limiting code by mark modified for 2d prob?

GameCoder(Posted 2004) [#1]
This is the code I have so far. As I understand it and was told by Cyberseth the drawgame() function should be outside the frame limmiting code just before flip false. But the thing is I'm having problems with the FPS. If I change the global fps from say 60 to 10, the game still runs at 78 fps. Its like its not being affected.

Here is the code for the loop I have. Its just a simple loop with an updateintro() function that updates the intro screen and text that I display.


Graphics 800,600
setbuffer backbuffer()

global gameFPS = 50

framePeriod = 1000 / gameFPS
frameTime = MilliSecs () - framePeriod

Repeat

	Repeat
		frameElapsed = MilliSecs () - frameTime
	Until frameElapsed

	frameTicks = frameElapsed / framePeriod

	
	For frameLimit = 1 To frameTicks

		frameTime = frameTime + framePeriod
		
		
			
	Next

				drawgame()()

	Flip  ;<<< if flip false, game goes to warp drive mode

Until KeyHit(1) = True 



drawgame() function is immediatley before flip. The thing is when I change the global gameFPS from 50 to 10 or 30 the fps within the game remains at a steady 78. If I put "flip false" the games fps skyrockets to between 588 & 988.

What Am I doing wrong?


jfk EO-11110(Posted 2004) [#2]
Maybe you need to replace

Repeat
frameElapsed = MilliSecs () - frameTime
Until frameElapsed

by

Repeat
frameElapsed = frametime - MilliSecs()
Until frameElapsed

?

BTW what the heck means "drawgame()()"? :°)


Matty(Posted 2004) [#3]
Or you could do this:If millisecs()>FrameTime then DrawGame():FrameTime=Millisecs()+FramePeriod


Odds On(Posted 2004) [#4]
Amon, it's not so much the FPS that you're limiting, it's the speed of the game execution. Basically you are telling Blitz to execute the game code at a set framerate, but render/draw graphics as fast as it possibly can.


GameCoder(Posted 2004) [#5]
thx for the replies guys. thx Chris fuller it makes sense now. As for the

drawgame()()


Its a game based on hooters ;P