|
-
Dec 18th, 2002, 08:02 PM
#1
Thread Starter
New Member
Beginner problem with DelayTimer
Quick question:
I have a text game and I would like to control the speed of the delay between prints with 3 buttons (Slow, normal, and fast). However, I don't know how to get the game to see the user CHANGE the speed in the MIDDLE of the game. It stays with whatever was initially selected.
I know you can't fix my problem specifically without seeing my code, but if you wanted to setup something similar, what technique/plan would you use?
Microsoft Visual C++ 6.0
Microsoft Visual Studio 6.0
JBuilder 6
-
Dec 18th, 2002, 08:12 PM
#2
Frenzied Member
try using GetTickCount and set e varialbe to the speed set
-
Dec 18th, 2002, 09:30 PM
#3
Or a timer or what ever...
-
Dec 19th, 2002, 02:13 AM
#4
it depends how you fix the delay of the game in first place.
It#s probably something like:
VB Code:
if TimeNow>TimeOld+xxx then
'continue
Else
'wait till next timeloop
end if
if you have a value for xxx change it to a variable. And it case the use clicks on one of your speedcommands change the variable
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
Dec 19th, 2002, 10:15 AM
#5
Frenzied Member
i usaly do it like this:
VB Code:
Dim TempTime as Long
While Running
If GetTickCount > TempTime Then
TempTime = GetTickCount + 10 'This is the speed
'Some Other Code!
End If
DoEvents
Wend
-
Dec 19th, 2002, 10:23 AM
#6
Originally posted by cyborg
i usaly do it like this:
VB Code:
Dim TempTime as Long
While Running
If GetTickCount > TempTime Then
TempTime = GetTickCount + 10 'This is the speed
'Some Other Code!
End If
DoEvents
Wend
That's the way to go...
-
Dec 19th, 2002, 10:24 AM
#7
PowerPoster
In most cases you just want to slow-down the game to say 60 FPS. This would be done like that:
VB Code:
Dim FPS as Long
Dim Temp as Long
'Sub Main
FPS = 60
While Active 'Main loop
'Calculate time
Temp = GetTickCount + (1000 / FPS)
'[Game code here]
'Slowdown
While Temp > GetTickCount: DoEvents: Wend
Wend
Last edited by Fox; Dec 19th, 2002 at 10:28 AM.
-
Dec 19th, 2002, 10:48 AM
#8
Frenzied Member
Doesnt that code run the 'game code' too often? or did i just misunderstod the code?
-
Dec 19th, 2002, 07:53 PM
#9
Addicted Member
You only want the graphics to update every 60 fps. You want your other game code - input, network, etc. to run while the screen isn't being updated to maximum your CPU cycles.
-
Dec 20th, 2002, 12:42 AM
#10
PowerPoster
You probably misunderstood; the loop runs the game code 60 times a second, the other time is spent into the second loop which appears on the last line
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|