diff options
author | metamuffin <metamuffin@disroot.org> | 2024-06-17 01:06:14 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-06-17 01:06:14 +0200 |
commit | fe164b52e7dd3468e53c8d5d4883b432cce18fbf (patch) | |
tree | 2eae77e893c007f314adbb459773fba451238d89 /test-client/util.ts | |
parent | e37231630488e5b54741d68edc45890a62c5610d (diff) | |
download | hurrycurry-fe164b52e7dd3468e53c8d5d4883b432cce18fbf.tar hurrycurry-fe164b52e7dd3468e53c8d5d4883b432cce18fbf.tar.bz2 hurrycurry-fe164b52e7dd3468e53c8d5d4883b432cce18fbf.tar.zst |
basic movement
Diffstat (limited to 'test-client/util.ts')
-rw-r--r-- | test-client/util.ts | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/test-client/util.ts b/test-client/util.ts new file mode 100644 index 00000000..994e6acf --- /dev/null +++ b/test-client/util.ts @@ -0,0 +1,4 @@ +export interface V2 { x: number, y: number } +export function length(p: V2): number { return Math.sqrt(p.x * p.x + p.y * p.y) } +export function normalize_mut(p: V2) { const l = length(p); if (l == 0) return; p.x /= l; p.y /= l } +export function normalize(p: V2): V2 { let l = length(p); if (l == 0) l = 1; return { x: p.x / l, y: p.y / l } } |