Results 1 to 10 of 10

Thread: Beginner problem with DelayTimer

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2002
    Posts
    8

    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

  2. #2
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    try using GetTickCount and set e varialbe to the speed set
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  3. #3
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Or a timer or what ever...

  4. #4
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863
    it depends how you fix the delay of the game in first place.
    It#s probably something like:

    VB Code:
    1. if TimeNow>TimeOld+xxx then
    2.   'continue
    3. Else
    4.   'wait till next timeloop
    5. 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!

  5. #5
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    i usaly do it like this:

    VB Code:
    1. Dim TempTime as Long
    2.  
    3. While Running
    4.     If GetTickCount > TempTime Then
    5.         TempTime = GetTickCount + 10 'This is the speed
    6.         'Some Other Code!
    7.     End If
    8.     DoEvents
    9. Wend
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  6. #6
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Originally posted by cyborg
    i usaly do it like this:

    VB Code:
    1. Dim TempTime as Long
    2.  
    3. While Running
    4.     If GetTickCount > TempTime Then
    5.         TempTime = GetTickCount + 10 'This is the speed
    6.         'Some Other Code!
    7.     End If
    8.     DoEvents
    9. Wend

    That's the way to go...

  7. #7
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    In most cases you just want to slow-down the game to say 60 FPS. This would be done like that:

    VB Code:
    1. Dim FPS as Long
    2. Dim Temp as Long
    3.  
    4. 'Sub Main
    5. FPS = 60
    6.  
    7. While Active 'Main loop
    8.     'Calculate time
    9.     Temp = GetTickCount + (1000 / FPS)
    10.  
    11.     '[Game code here]
    12.    
    13.     'Slowdown
    14.     While Temp > GetTickCount: DoEvents: Wend
    15. Wend
    Last edited by Fox; Dec 19th, 2002 at 10:28 AM.

  8. #8
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    Doesnt that code run the 'game code' too often? or did i just misunderstod the code?
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  9. #9
    Addicted Member
    Join Date
    Aug 2002
    Location
    Baltimore, MD
    Posts
    230
    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.

  10. #10
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    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
  •  



Click Here to Expand Forum to Full Width