hi,
im making a paratrooper type game and i was wondering how
you get the bullet (an image) to shoot in accordance with the angle of the gun (a line). help woul be apreciated.
-thanks
-t_dawolf
Printable View
hi,
im making a paratrooper type game and i was wondering how
you get the bullet (an image) to shoot in accordance with the angle of the gun (a line). help woul be apreciated.
-thanks
-t_dawolf
Make two variables for two dimensions, use cos(angle) for x and sin(angle) for y, angle should be in radians
ok,
what do i do once thats done?
-thanks
-t_dawolf
Have a mainloop or timer to move the bullet(s) according to the speed(s)
ok,
i got the timer thing but they still go straight up.
im still a little confsed on how to get the angle.
is their a property that would show me the angle?
-thanks
-t_dawolf
Just use the angle when you initialize your bullet, and its direction, after that use the speedx and speedy, to move the bullet. you set the angle by your ow
Angle is not what you findout, or calculate, you set it, it depends on which direction you want to fire.
im sorry
you msut think im the biggest idiot in the world,
but i don't get it. how do i set it to go to a different
place with every possible angle? do i have to do it manually?
their must be an easier way. even if you don't respond,
thanks for your help.
-thanks
-t_dawolf
It depends on your type of game. Is the player going to click on a certain point and the bullet has to fly through that or will they rotate a "turret" left and right and enter a power level?
well,
you move the turret with the arrows, and you press the space
bar to shoot, it goes off the screen no matter what unless
it hits a plane or paratrooper.
-thanks
-t_dawolf
Here's how you can set the angle by pressing keys
Code:Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyLeft
angle = angle + 0.1
Case vbKeyRight
angle = angle - 0.1
End Sub
Sorry, forgot.
Put a End select before End sub
thanks
ill try that once i get home and then get back to you.
-thanks
-t_dawolf
ok,
im at my wits end trying to get this. there has got to be
a way! so if anyone out there knows how, please, please tell me.
-thanks
-t_dawolf
p.s.
the code didn't work
p.s.
thanks for all your help anyways
-t_dawolf
Anyone have a good algorithm on moving the bullet if
you know x1,y1, x2 and y2?
That depends on what does x1,x2 y1,y2 are.
Basically you need to know a set of speed in x and y vectors, an angle and general velocity, or the startcord and endcord+velocity. if i think right, what you're missing is the velocity and you can have a method that does it
x1 and y1 is the starting point, x2 ans y2 is the ending point, the velocity is of no importance..
so how would i get the angle from x1 and y1 to x2 and y2?'
i can't think of anything offhand.
-thanks
-t_dawolf
Why do you want to know the angle anyway? That's if you have a specified direction to shoot your bullet from and you will calculate the coordinates based on that angle.
Anyway i'm going to explain how to get that damn angle:
atn stands for arcus tangens, if you want to knowCode:angle=atn((y1-y2)/(x1-x2))