Results 1 to 20 of 20

Thread: making the bullet go diagonal

  1. #1
    Guest

    Unhappy

    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

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Make two variables for two dimensions, use cos(angle) for x and sin(angle) for y, angle should be in radians
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3
    Guest

    Unhappy

    ok,

    what do i do once thats done?

    -thanks

    -t_dawolf

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Have a mainloop or timer to move the bullet(s) according to the speed(s)
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  5. #5
    Guest

    Question

    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

  6. #6
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  7. #7
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Angle is not what you findout, or calculate, you set it, it depends on which direction you want to fire.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  8. #8
    Guest
    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

  9. #9
    Hyperactive Member
    Join Date
    Mar 2000
    Posts
    292
    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?
    "People who think they know everything are a great annoyance to those of us who do."

  10. #10
    Guest
    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

  11. #11
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  12. #12
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Sorry, forgot.
    Put a End select before End sub
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  13. #13
    Guest

    Wink

    thanks

    ill try that once i get home and then get back to you.

    -thanks

    -t_dawolf

  14. #14
    Guest

    Angry

    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

  15. #15
    Guest
    p.s.

    thanks for all your help anyways

    -t_dawolf

  16. #16
    New Member
    Join Date
    May 2000
    Posts
    14
    Anyone have a good algorithm on moving the bullet if
    you know x1,y1, x2 and y2?
    Well, it's a pentium parrot, besides, it's only a decimal.

  17. #17
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  18. #18
    New Member
    Join Date
    May 2000
    Posts
    14
    x1 and y1 is the starting point, x2 ans y2 is the ending point, the velocity is of no importance..
    Well, it's a pentium parrot, besides, it's only a decimal.

  19. #19
    Guest
    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

  20. #20
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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:
    Code:
    angle=atn((y1-y2)/(x1-x2))
    atn stands for arcus tangens, if you want to know
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

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