Results 1 to 10 of 10

Thread: Projectiles with wind

  1. #1

    Thread Starter
    Fanatic Member McCain's Avatar
    Join Date
    Jan 2002
    Location
    Sweden/Denmark
    Posts
    802

    Projectiles with wind

    Hi,
    I'm trying to make a game like "Gorilla". Don't know if you've ever played it, but you're two players (two gorillas) and you are standing ontop of tall buildings. You are then supposed to throw bananas on each other. You enter the speed and angle of the banana to make it go over the buildings and hit the other gorilla. And there is also wind blowing in different directions all the time that you have to take in count when you decide what angle and speed you're going to use.

    I know how to calculate the path of the banana if you don't care about wind. But I have no idea what to do when there is wind blowing. Can anyone help, please?

    Currently I have this code (just to see if it'll work)
    VB Code:
    1. Private Sub cmdDraw_Click()
    2.     Const pi As Double = 3.14159265358979
    3.     Const g As Double = 9.82
    4.     Dim v As Double
    5.     Dim a As Double
    6.     Dim x As Double
    7.     Dim y As Double
    8.    
    9.     If edtV.Text = "" Or edtA.Text = "" Then
    10.         MsgBox "Nu glömde du igen..."
    11.         Exit Sub
    12.     End If
    13.    
    14.     Me.Cls
    15.    
    16.     v = edtV
    17.     a = edtA
    18.  
    19.     Me.Line (0, 200)-(600, 200)
    20.     CurrentX = 0
    21.     CurrentY = 200
    22.    
    23.     x = 0
    24.     Do
    25.         y = Tan(a * (pi / 180)) * x - g / (2 * v * v * Cos(a * (pi / 180)) * Cos(a * (pi / 180))) * x * x
    26.         Me.Line -(x * 5, -(y * 5) + 200)
    27.         x = x + 1
    28.     Loop Until Tan(a * (pi / 180)) * x - g / (2 * v * v * Cos(a * (pi / 180)) * Cos(a * (pi / 180))) * x * x < -1
    29. End Sub
    Never argue with fools, they will only drag you down to their level, and beat you with experience.

    Q: How do you tell an experienced hacker from a novice?
    A: The latter thinks there's 1000 bytes in a kilobyte, while the former is sure there's 1024 meters in a kilometer

  2. #2
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    Not too sure, but try experimenting with this as a formula for y:

    Tan(a * (pi / 180)) * (x+W) - g / (2 * v * v * Cos(a * (pi / 180)) * Cos(a * (pi / 180))) * (x+W) * (x+W)


    As you see, i've replaced x with x+W. I'm not sure whether this will work, but try giving w different values and see what the curve does.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  3. #3
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    Since you don't use Pi directly you can make the constant pi / 180.

    It'll go faster.

  4. #4
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    Also...

    VB Code:
    1. 'if x = 0 then y = 0
    2.         x = 0
    3.         y = 0
    4.     Do Until y < -1
    5.         Me.Line -(x * 5, -(y * 5) + 200)
    6.         x = x + 1
    7.         y = Tan(a * (pi / 180)) * x - g / (2 * v * v * Cos(a * (pi / 180)) * Cos(a * (pi / 180))) * x * x
    8.     Loop

    will make it faster.

  5. #5

    Thread Starter
    Fanatic Member McCain's Avatar
    Join Date
    Jan 2002
    Location
    Sweden/Denmark
    Posts
    802
    DiGiTaIErRoR: Thanks for the speed tips
    SLH: Can it realy be that easy? Shouldn't size and weight of the projectile have a factor in how much the wind will affect it?
    Never argue with fools, they will only drag you down to their level, and beat you with experience.

    Q: How do you tell an experienced hacker from a novice?
    A: The latter thinks there's 1000 bytes in a kilobyte, while the former is sure there's 1024 meters in a kilometer

  6. #6
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    As you don't have any size/weight variables in your code i assumed that sort of thing didn't matter. I don't know what the modifications would be if you wanted to properly simulate the physics, i was just suggesting a way of doing it without physics.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  7. #7

    Thread Starter
    Fanatic Member McCain's Avatar
    Join Date
    Jan 2002
    Location
    Sweden/Denmark
    Posts
    802
    Ohh, sorry for the misunderstanding.
    I didn't add size or weight because I didn't know how to add them to a formula.
    I did some searching on the net for a formula that takes wind into the calculation. I found a few but they were all in English and I didn't quite understand them. I couldn't find any in my language (Swedish)...
    So I guess this is kinda hard... If any physics experts read this post - please help me.
    Never argue with fools, they will only drag you down to their level, and beat you with experience.

    Q: How do you tell an experienced hacker from a novice?
    A: The latter thinks there's 1000 bytes in a kilobyte, while the former is sure there's 1024 meters in a kilometer

  8. #8
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    Well.

    If a plane is going 200 MPH north, and there's a 100 MPH wind blowing south, the plane goes 100 MPH. If the wind blew south to north, the plane would go 300 MPH.

    You have to use trig functions(sin,cos,tan) to calculate for variable degree winds.

  9. #9
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176
    You could add a new element

    Aerodynamics

    Last edited by BodwadUK; Oct 6th, 2003 at 03:10 AM.
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

  10. #10
    Frenzied Member vbNeo's Avatar
    Join Date
    May 2002
    Location
    Jutland, Denmark
    Posts
    1,994
    Originally posted by BodwadUK
    You could add a new element

    Aerodynamics

    "Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
    - Zack de la Rocha


    Hear me roar.

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