Windows has nothing to do with it. :-P

by OLPC (no login)


I think RPG was saying the problem is due to threads, not that it is unsolvable. Either way, there is an easy fix.
For my programs I just have to put one Sleep line in the main program loop, and a Sleep line in the menu. You just have to make sure a Sleep line is run a few times a second, so functions such as Input, which will run for several seconds while the user is typing something, will need a Sleep line. Functions such as Inkey won't need to call Sleep, since it is used in the main program loop, which does the Sleeping. (The code at the end of this post shows how to keep a consistent frame rate in a game.)
With multiple threads, you just have to make sure each thread Sleeps.
In FreeBasic, the "invisible" (2nd) thread for updating the display uses something like Sleep (I'm not sure exactly how), so it only updates the screen 60x per second.

Sub game_play
Dim As Double t

t = Timer

game.key = Inkey
If game.key = Chr(27) Then
Get (0, 0) - (screenx - 1, screeny - 1), game_graphic
Select Case utility_menu(utility_menu_ingame, false)
Case 2
game.quit = true
End Select
End If



t = 25 + (t - Timer) * 1000
If t > 0 Then Sleep t
Loop Until game.quit Or game.won Or game.lost

End Sub

Posted on Jan 29, 2008, 1:51 PM

Respond to this message   

Return to Index

Response TitleAuthor and Date
oh forgive me!mennonite on Jan 29
 also how well does wait &h3da, 8 work for this?mennonite on Jan 29
  Not sure...OLPC on Jan 29
   i'll be sure to try it with qb64 latermennonite on Jan 29
 PrioritiesOLPC on Jan 29
  coolmennonite on Jan 29
   In Windows 2000, it's...OLPC on Jan 29
    *thanks, same in xpmennonite on Jan 29

 Copyright © 1999-2018 Network54. All rights reserved.   Terms of Use   Privacy Statement