Results 1 to 6 of 6

Thread: Speed problems...

  1. #1

    Thread Starter
    Frenzied Member CyberCarsten's Avatar
    Join Date
    Sep 1999
    Location
    Aalborg Ø, Denmark
    Posts
    1,544

    Speed problems...

    Hey guys!
    I'm making a lander game, byt I cant get the speed right when i try to slow the ship down, and when it falls....I have tried looking at the lander game here from VB world, but I couldn't figure it out...

    VB Code:
    1. Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
    2. Dim Speed As Single
    3. Dim Direction As Integer
    4.  
    5.  
    6.  
    7. Private Sub Timer1_Timer()
    8.  
    9.     If (Picture1.Left > LandingPad.Left - Picture1.Width - Picture1.Height) And ((Picture1.Top _
    10.         > LandingPad.Top - Picture1.Height) And Picture1.Top < Picture1.Top + Picture1.Height) Then
    11.               Timer1.Enabled = False
    12.               If Speed > 1 Then
    13.                 Print "Ship crashed!"
    14.             Else
    15.                 Print "Ship saved!"
    16.             End If
    17. End If
    18.  
    19.  
    20. If GetAsyncKeyState(vbKeyLeft) Then
    21.     Picture1.Left = Picture1.Left - 20
    22. End If
    23.  
    24. If GetAsyncKeyState(vbKeyRight) Then
    25.     Picture1.Left = Picture1.Left + 20
    26. End If
    27.  
    28. If GetAsyncKeyState(vbKeyUp) Then
    29.   Speed = Speed - 1.5 / 60
    30.   Me.Caption = Speed
    31.     Direction = Direction - 20
    32.     Picture1.Top = Direction
    33. ElseIf Not GetAsyncKeyState(vbKeyUp) Then
    34.  
    35. If Speed >= 15 Then
    36.     Speed = 15
    37. End If
    38. Speed = Speed + 1.5 / 60
    39. Me.Caption = Speed
    40. Direction = Direction + 40
    41. Picture1.Top = Direction
    42. End If
    43.  
    44. End Sub
    razor
    Software Engineer Student, Aalborg University, Denmark
    http://www.cs.auc.dk

    My email at AUC: will get a new email soon
    My website: http://www.razorsoftware.net


    Windows XP Pro/ Gentoo Linux (Laptop)
    Windows XP Pro (Home PC)

  2. #2
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    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
    Post the project in a zip
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    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."

  3. #3

    Thread Starter
    Frenzied Member CyberCarsten's Avatar
    Join Date
    Sep 1999
    Location
    Aalborg Ø, Denmark
    Posts
    1,544
    The project
    razor
    Software Engineer Student, Aalborg University, Denmark
    http://www.cs.auc.dk

    My email at AUC: will get a new email soon
    My website: http://www.razorsoftware.net


    Windows XP Pro/ Gentoo Linux (Laptop)
    Windows XP Pro (Home PC)

  4. #4
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    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
    Well... sorry, but that's not the way you make a Lander game (this way it's too easy )

    It should go like this:
    The ship has a vertical and a horizontal speed. Each frame the ship is moved by these 2 speeds. If you press the Up key, the vertical speed is decreased so the ship will move up. If you press the Down key, the vertical speed is increased so the ship will move down. Same way for the Left and Right. The greater the speed, the faster it'll move. And to make it harder, you can have gravity - every frame the vertical speed is increased a bit, so the ship will move down unless it has enough speed (moving up). Get it?

    Read the lander game article again, it explains this a bit better than me
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    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."

  5. #5

    Thread Starter
    Frenzied Member CyberCarsten's Avatar
    Join Date
    Sep 1999
    Location
    Aalborg Ø, Denmark
    Posts
    1,544
    Ok Thanks
    razor
    Software Engineer Student, Aalborg University, Denmark
    http://www.cs.auc.dk

    My email at AUC: will get a new email soon
    My website: http://www.razorsoftware.net


    Windows XP Pro/ Gentoo Linux (Laptop)
    Windows XP Pro (Home PC)

  6. #6
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    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
    You're welcome
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    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."

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