In my game loop, I have it Sleep for 50ms on each loop so the speed is appropriate for my machine. However, when I install in on other machines, 50ms may be too fast or too slow.
I realize I can give the user a speed up/slow down capability, but my game really needs to be a "standard" speed, so it looks the same on each machine -- otherwise the game dynamic is thrown off.
So anyone have a recommended, tried and true way to do this before I start experimenting?
to help confuse matters you can use the below code for simple games:
Private Sub Form_Load()
Dim count As Double ' set up count
count2 = Timer ' count2 = timer function
For count = 1 To 1000000 ' count from 1 to 1000000
Next count ' then
Inter = Timer - count2 ' take count2 from timer and store it as tmrInterval
Inter = Inter * 400 ' times tmrInterval by 400
Timer1.Interval = Inter
MsgBox ("Game speed = " & Inter)
MsgBox ("player 1 controls = d:up c:down x:left v:right")
MsgBox ("player 2 controls = up:up down:down left:left right:right")
End Sub
The attatched file is a game i made for a pal to help him through his course!
Might wanna put that DrawStuff call into the If block. No need to redraw if nothing's been refreshed yet, and redrawing too often tends to slow yer comp a bit.. ;[
To understand recursion, one must first understand the concept of recursion.
Simply redraw as fast as you can, and in your game loop, do something like this:
Static LastTick as Long
Dim CurrentTick as Long, NextTime as Long, Framerate as Long
Framerate = 60 ' 60fps
CurrentTick = GetTickCount
If LastTick = 0 Then LastTick = CurrentTick
NextTime = LastTick + (1000 / (Framerate))
If CurrentTick >= NextTime Then
LastTick = CurrentTick
UpdateData ' Move all your sprites and stuff.
End If
Redraw ' Redraw.
I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
Posts
1,457
Hey Sas, you said RPGMaker forums? The web page doesn't seem to work, so I can't get to them
To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systemshere.
Jotaf's Theories!
"Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."