From db4bcc0073fa1042e9779453af1dcdef7582fbd1 Mon Sep 17 00:00:00 2001 From: Matthew Kosarek Date: Sun, 18 Apr 2021 15:10:25 -0400 Subject: Have 2D pill collisions working pretty well now --- frontend/shared_cpp/WebglHelper.h | 6 ++++++ frontend/shared_cpp/mathlib.h | 7 +++++++ 2 files changed, 13 insertions(+) create mode 100644 frontend/shared_cpp/WebglHelper.h (limited to 'frontend/shared_cpp') diff --git a/frontend/shared_cpp/WebglHelper.h b/frontend/shared_cpp/WebglHelper.h new file mode 100644 index 0000000..dbdb23f --- /dev/null +++ b/frontend/shared_cpp/WebglHelper.h @@ -0,0 +1,6 @@ +#pragma once +#include "mathlib.h" + +struct OrthographicRenderer; + +void render2DArrow(Vector2 start, Vector2 end, OrthographicRenderer* renderer); diff --git a/frontend/shared_cpp/mathlib.h b/frontend/shared_cpp/mathlib.h index 383c880..b9f3fee 100644 --- a/frontend/shared_cpp/mathlib.h +++ b/frontend/shared_cpp/mathlib.h @@ -57,6 +57,13 @@ struct Vector2 { return { -y, x }; } + Vector2 rotate(float angle) { + return { + x * cosf(angle) - y * sinf(angle), + x * sinf(angle) + y * cosf(angle) + }; + } + void printDebug(const char* name) { printf("%s=Vector2(%f, %f)\n", name, x, y); } -- cgit v1.2.1