()
| 260 | // ============================================================ |
| 261 | |
| 262 | export function getMovementInput(): { x: number; y: number } { |
| 263 | let x = 0; |
| 264 | let y = 0; |
| 265 | |
| 266 | // WASD |
| 267 | if (isKeyDown(Key.D)) x += 1; |
| 268 | if (isKeyDown(Key.A)) x -= 1; |
| 269 | if (isKeyDown(Key.S)) y += 1; |
| 270 | if (isKeyDown(Key.W)) y -= 1; |
| 271 | |
| 272 | // Arrow keys |
| 273 | if (isKeyDown(Key.RIGHT)) x += 1; |
| 274 | if (isKeyDown(Key.LEFT)) x -= 1; |
| 275 | if (isKeyDown(Key.DOWN)) y += 1; |
| 276 | if (isKeyDown(Key.UP)) y -= 1; |
| 277 | |
| 278 | // Gamepad axes (overrides if non-zero) |
| 279 | const gx = getGamepadAxis(0); |
| 280 | const gy = getGamepadAxis(1); |
| 281 | if (Math.abs(gx) > 0.1 || Math.abs(gy) > 0.1) { |
| 282 | x = gx; |
| 283 | y = gy; |
| 284 | } |
| 285 | |
| 286 | // Clamp |
| 287 | const len = Math.sqrt(x * x + y * y); |
| 288 | if (len > 1) { |
| 289 | x /= len; |
| 290 | y /= len; |
| 291 | } |
| 292 | |
| 293 | return { x, y }; |
| 294 | } |
nothing calls this directly
no test coverage detected