Results 1 to 5 of 5

Thread: My game needs a little tweaking.

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2005
    Posts
    62

    Question My game needs a little tweaking.

    Here's a program I have made so far. Not finished yet though. I need help. I need help on seperating the distance between one missile fired after the other. Any help?
    Attached Files Attached Files

  2. #2

    Thread Starter
    Member
    Join Date
    Jan 2005
    Posts
    62

    Re: My game needs a little tweaking.

    Well, its not really user friendly yet, so here are some instructions.
    Left and Right arrow keys: Push once, he moves slowly, push again, he moves faster.
    Up arrow: Jumps.
    Space bar: fires missile.

    Crap, sorry for the double-post. Meant to edit it.

  3. #3
    Banned Psychopathetica's Avatar
    Join Date
    Jan 2005
    Posts
    31

    Re: My game needs a little tweaking.

    Here's one thing you need. A Game Loop. Never use multiple timers. One timer alone is slow, inaccurate, and inconsistant. Even worse if it's used on XP machines because the timer goes 10 times faster than usual, making it really inaccurate and inconsistant. Matter of fact, never use timers period.

    Here's an example of a game loop:

    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function QueryPerformanceCounter Lib "Kernel32" (lpPerformanceCount As Currency) As Long
    4. Private Declare Function QueryPerformanceFrequency Lib "Kernel32" (lpPerformanceCount As Currency) As Long
    5.  
    6. Private Ticks_Per_Second As Currency
    7.  
    8. Private Start_Time As Currency
    9.  
    10. Private Running As Boolean
    11.  
    12. Private Sub Game_Loop()
    13.  
    14.      Do While Running = True
    15.  
    16.           DoEvents
    17.  
    18.           'Game code goes here
    19.  
    20.           Lock_FPS 60
    21.  
    22.           QueryPerformanceCounter Start_Time
    23.  
    24.      Loop
    25.  
    26. End Sub
    27.  
    28. Private Function Hi_Res_Timer_Initialize() As Boolean
    29.  
    30.     If QueryPerformanceFrequency(Ticks_Per_Second) = 0 Then
    31.  
    32.         Hi_Res_Timer_Initialize = False
    33.  
    34.     Else
    35.    
    36.         QueryPerformanceCounter Start_Time
    37.      
    38.         Hi_Res_Timer_Initialize = True
    39.      
    40.     End If
    41.  
    42. End Function
    43.  
    44. Private Function Lock_FPS(ByVal Target_FPS As Byte) As Single
    45.  
    46.     If Target_FPS = 0 Then Target_FPS = 1
    47.  
    48.     Static Last_Time As Currency
    49.  
    50.     Dim Current_Time As Currency
    51.  
    52.     Dim FPS As Single
    53.  
    54.     Last_Time = Start_Time - 1
    55.    
    56.     Do
    57.  
    58.         QueryPerformanceCounter Current_Time
    59.    
    60.         If (Current_Time - Last_Time) <> 0 Then FPS = Ticks_Per_Second / (Current_Time - Last_Time)
    61.    
    62.         Lock_FPS = FPS
    63.    
    64.     Loop While (FPS > Target_FPS)
    65.    
    66. End Function
    67.  
    68. Private Sub Form_Activate()
    69.  
    70.      Running = True
    71.  
    72.      Hi_Res_Timer_Initialize
    73.      
    74.      Game_Loop
    75.  
    76.      Unload Me
    77.  
    78. End Sub
    79.  
    80. Private Sub Form_Unload(Cancel As Integer)
    81.  
    82.       Running = False
    83.  
    84. End Sub

  4. #4

    Thread Starter
    Member
    Join Date
    Jan 2005
    Posts
    62

    Re: My game needs a little tweaking.

    Well, I don't think I'm quite that advanced yet...I can try. I don't really know what all the coding is for though.

  5. #5
    Banned Psychopathetica's Avatar
    Join Date
    Jan 2005
    Posts
    31

    Re: My game needs a little tweaking.

    The code isn't advanced at all. All it is, is a game loop locked at 60 FPS, with no game code. Of course I needed some extra code to lock the framerate and all of that, but other than that, its easy.

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