/** * Keys to a direction on the map. * * The server has always been told a world-space direction, and that contract * does not change: from inside the player's head W means "the way I am * looking", so the keys are turned by the view angle before they are sent. * In the top-down view the keys are the compass they always were. */ /** * `ax` is right on the keyboard (+1 for D), `ay` is down the screen (+1 for * S, so forward is -1). `out` is filled and returned: no allocation. */ export function moveVector(ax, ay, yaw, out = { x: 0, y: 0 }) { const cos = Math.cos(yaw); const sin = Math.sin(yaw); out.x = cos * -ay - sin * ax; out.y = sin * -ay + cos * ax; return out; }