ID:153869
![]() Nov 19 2002, 7:37 pm
|
|
I want to have a variable that goes from 1 to 360 (or 0 to 359 if you're a proper programmer). Then, using a proc, set that variable to the appropriate degree facing a target, so that were the variable used to represents an arrow pointing in that direction, it would be pointing at the target. Yeah. I have no idea how to do that. Can anyone help?
|
I remember Malver trying something like that out for Bizlof War : Ti. He got it but he didn't keep it. It took to long to turn :P but .. if you want help with that try Malver next time he is on or something.
|
Here is a very basic way of doing it (although it isn't exceptionally pretty) and you could probably use estimations (in 5 degree increments) then store those in a list for easy access.
mob var/degree = 0 verb Arrow() overlays = list(image(turn('arrow.dmi',-degree),usr)) ChngArrow(var/deg as num) overlays = list(image(turn('arrow.dmi',-deg),usr)) Have the arrow pointing due east (0 degrees) in the actual icon and this will adjust it as most people are used to (90 degrees pointing up, 180 degrees pointing west, and 270 degrees pointing south). |
Foomer wrote:
I want to have a variable that goes from 1 to 360 (or 0 to 359 if you're a proper programmer). Then, using a proc, set that variable to the appropriate degree facing a target, so that were the variable used to represents an arrow pointing in that direction, it would be pointing at the target. Yeah. I have no idea how to do that. Can anyone help? This is off the top of my head so it may only work for 0-90 degrees. degree = arctan((target.y - source.y) / (target.x - source.x)) 0 degrees will be to the right of the source and as the degrees increases it should go counter-clockwise. |
If I remember right, I think you have to calculate an arctangent to determine the heading from one point to another. If no one comes up with a helpful response, email me at [email protected] and I'll dig up an example tonight.