VectorAngle
Jump to navigation
Jump to search
fixed VectorAngle (int x, int y)
Usage
Returns the fixed point angle of the vector (x,y). Angles are measured from the east and moving counterclockwise.
This function is more commonly known as atan2. To get the value of atan(x), use VectorAngle(1.0, x)
Parameters
- x, y: Coordinates of the end point of the vector.
Return value
Fixed point angle of the vector (x,y).
Examples
This script will print a little ^ at the bottom of the player's screen pointing at the actor with TID set to 1:
script 1 ENTER { int vang, angle; while(TRUE) { vang = VectorAngle (GetActorX (1) - GetActorX (0), GetActorY (1) - GetActorY (0)); angle = (vang - GetActorAngle (0) + 1.0) % 1.0; if (angle < 0.2 || angle > 0.8) { int sx = 320 - (320 * Sin (angle) / Cos (angle)); SetHudSize (640, 480, 0); HudMessage (s:"^"; HUDMSG_PLAIN, 1, CR_RED, sx * 1.0, 480.2, 0); } else { HudMessage (s:""; HUDMSG_PLAIN, 1, 0, 0, 0, 0); } Delay (1); } }