How do you plot an arc?

You know those games where you input angle and velocity and shoot at each other? I am trying to make one but can't figure out the math to make the shots arc. I know that it is something to do with trigenometry (cos, sin, and tan) but I need help!


Comments

  • : You know those games where you input angle and velocity and shoot at each other? I am trying to make one but can't figure out the math to make the shots arc. I know that it is something to do with trigenometry (cos, sin, and tan) but I need help!
    :

    Well..

    Do like this:

    ' bullet coordinates
    dim bulletX as double, bulletY as double
    ' bullet's speed in x and y direction
    dim bSpeedX as double, bSpeedY as double
    ' angle and power
    dim angle as double, power as double

    print "Enter angle: "
    input angle

    print "Power : "
    input power

    bSpeedX = cos(angle * 3.141592 / 180) * power
    bSpeedY = sin(angle * 3.141592 / 180) * power

    ' move bullet
    bulletX = bulletX + bSpeedX
    bulletY = bulletY + bSpeedY


    That's it..

    Now if you enter angle of 0(zero) and power of 10,
    bullet will fly to the right 10 pixels a time.
    cos and sin use radians, so you must convert angle from
    degrees to radians (angle * PI / 180)

    Hope that helped..



Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories