VBGamer |
|||||||||||||||||||||||||||
RE: David... The Gilb (1 reply, 0 views) (2000-Aug-2) 1) Jay Wheeler - a program can easily run too fast on some computers - or too slow... If the movement of your game elements and the animation of your game elements is based on a per frame basis, then if the game is running on a faster PC than it was designed for, it will become unplayable. However if the movement and animation of screen elements was based on time, then it would not matter how fast the host computer was. I once looked into this... I wrote a tutorial on it and I was working on a Pacman clone which would use these concepts with my CDXVB7 library. It was a little tricky, but eventually I got the idea to work and the results were quite pleasing. I dont think I ever released that code however...
Anyways - a frame limiter. Your game should have a main game loop - if not, redesign your game :-)
dim curtime as long, nexttime as long, fps as long
' Change this value to alter the fps
fps = 60
curtime = timegettime()
nexttime = curtime
do while doevents()
curtime = timegettime()
if curtime >= nexttime then
' Execute game code here
nexttime = curtime + (1000 / fps)
end if
loop
If you put that code in around your game loop then all should be well. :-)
Hope that helps.
Gilb.
|