08-16-2022, 12:53 AM
Hi all,
I'm in the middle of making my Explorer game with scrolling maps. The game uses the mouse to use your sword with. But I'm stuck at what the equation is to make a limited line (sword) from your character toward the area you point your mouse at. I can easily make a line from your character to the mouse coordinates, but I can't make it a limited length. Does anyone out there know how to do this? I think I will keep the sword at 100 pixels long. Let's say the guy is XX by YY coordinates (never mind the scrolling map part, that should be easy to add). And let's say the mouse is using mouseX and mouseY. I just want the sword to reach toward that mouse point but only 100 pixels toward it and no more. Thanks.
I'm in the middle of making my Explorer game with scrolling maps. The game uses the mouse to use your sword with. But I'm stuck at what the equation is to make a limited line (sword) from your character toward the area you point your mouse at. I can easily make a line from your character to the mouse coordinates, but I can't make it a limited length. Does anyone out there know how to do this? I think I will keep the sword at 100 pixels long. Let's say the guy is XX by YY coordinates (never mind the scrolling map part, that should be easy to add). And let's say the mouse is using mouseX and mouseY. I just want the sword to reach toward that mouse point but only 100 pixels toward it and no more. Thanks.