Equation For Specific Line Length Needed
#5
Steve, I thought that would be the case too, but I couldn't get that to work for some reason, maybe I did it wrong. But mostly, I know that equation but I still don't know how it works. B+'s equation works perfectly with the added camera.x and camera.y in the beginning. Here, this is what I have for the sword. lhandx and lhandy keeps the sword in his moving left hand. I brought the length down from 100 to 75 to make it look better.

Code: (Select All)
    'Sword
    swordx = player.x + camera.x + lhandx
    swordy = player.y + camera.y + lhandy

    a = _Atan2(mousey - swordy, mousex - swordx)
    sx = swordx + 75 * Cos(a)
    sy = swordy + 75 * Sin(a)
    Line (swordx, swordy)-(sx, sy), &HFFFFFF00
Reply


Messages In This Thread
RE: Equation For Specific Line Length Needed - by SierraKen - 08-16-2022, 03:45 PM



Users browsing this thread: 2 Guest(s)