|
-
Oct 4th, 2003, 05:03 AM
#1
Thread Starter
Fanatic Member
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:
Private Sub cmdDraw_Click()
Const pi As Double = 3.14159265358979
Const g As Double = 9.82
Dim v As Double
Dim a As Double
Dim x As Double
Dim y As Double
If edtV.Text = "" Or edtA.Text = "" Then
MsgBox "Nu glömde du igen..."
Exit Sub
End If
Me.Cls
v = edtV
a = edtA
Me.Line (0, 200)-(600, 200)
CurrentX = 0
CurrentY = 200
x = 0
Do
y = Tan(a * (pi / 180)) * x - g / (2 * v * v * Cos(a * (pi / 180)) * Cos(a * (pi / 180))) * x * x
Me.Line -(x * 5, -(y * 5) + 200)
x = x + 1
Loop Until Tan(a * (pi / 180)) * x - g / (2 * v * v * Cos(a * (pi / 180)) * Cos(a * (pi / 180))) * x * x < -1
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
-
Oct 4th, 2003, 05:38 AM
#2
Not NoteMe
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. 
-
Oct 4th, 2003, 11:41 AM
#3
So Unbanned
Since you don't use Pi directly you can make the constant pi / 180.
It'll go faster.
-
Oct 4th, 2003, 11:44 AM
#4
So Unbanned
Also...
VB Code:
'if x = 0 then y = 0
x = 0
y = 0
Do Until y < -1
Me.Line -(x * 5, -(y * 5) + 200)
x = x + 1
y = Tan(a * (pi / 180)) * x - g / (2 * v * v * Cos(a * (pi / 180)) * Cos(a * (pi / 180))) * x * x
Loop
will make it faster.
-
Oct 4th, 2003, 03:07 PM
#5
Thread Starter
Fanatic Member
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
-
Oct 5th, 2003, 06:05 AM
#6
Not NoteMe
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. 
-
Oct 5th, 2003, 08:11 AM
#7
Thread Starter
Fanatic Member
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
-
Oct 5th, 2003, 02:30 PM
#8
So Unbanned
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.
-
Oct 6th, 2003, 02:46 AM
#9
KING BODWAD XXI
-
Oct 6th, 2003, 09:54 AM
#10
Frenzied Member
"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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|