From 1a08dd2bd6839f0be4b12dc5317ab0b00ca23ae1 Mon Sep 17 00:00:00 2001 From: Matthew Kosarek Date: Tue, 16 Mar 2021 22:03:10 -0400 Subject: Proper update loop for a WebAssembly scene running --- frontend/_wasm/mathlib.h | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'frontend/_wasm/mathlib.h') diff --git a/frontend/_wasm/mathlib.h b/frontend/_wasm/mathlib.h index bc84b72..93ddbbd 100644 --- a/frontend/_wasm/mathlib.h +++ b/frontend/_wasm/mathlib.h @@ -86,6 +86,13 @@ struct Mat4x4 { return result; } + Mat4x4 translateByVec2(Vector2 v) { + Mat4x4 result = copy(); + result.m[12] += v.x; + result.m[13] += v.y; + return result; + } + Mat4x4 rotate2D(float angle) { Mat4x4 result = copy(); result.m[0] = cos(angle); @@ -112,4 +119,12 @@ struct Mat4x4 { result.m[13] = -(top + bottom) / (top - bottom); return result; } -}; \ No newline at end of file + + void print() { + printf("[ "); + for (int idx = 0; idx < 16; idx++) { + printf("%d, ", idx); + } + printf(" ]\n"); + } +}; -- cgit v1.2.1