From 60072c1d8089ffd3294e76636198d14710be95b8 Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Sat, 9 Sep 2017 07:55:22 +0100 Subject: Restructuring --- yage/physics/collider.h | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 yage/physics/collider.h (limited to 'yage/physics/collider.h') diff --git a/yage/physics/collider.h b/yage/physics/collider.h new file mode 100644 index 00000000..2fd2ff89 --- /dev/null +++ b/yage/physics/collider.h @@ -0,0 +1,43 @@ +/* ---------------------------------------------------------------------------- + * collider.h + * + * Copyright (c) 2017 Yann Herklotz Grave -- MIT License + * See file LICENSE for more details + * ---------------------------------------------------------------------------- + */ + +#ifndef YAGE_PHYSICS_COLLIDER_H +#define YAGE_PHYSICS_COLLIDER_H + +#include + +namespace yage +{ + +// The Collider class helps collision detection by providing a general shape +// for different shapes to have their own collision algorithms. +class Collider +{ +protected: + // position of the object + glm::vec2 position_; + + // size of the object + glm::vec2 size_; + +public: + Collider(const glm::vec2 &position, const glm::vec2 &size) + : position_(position), size_(size) + { + } + + // function that checks if two colliders are colliding + virtual bool collides(const Collider &collider) const = 0; + + // function that returns if a point is inside the shape + virtual bool inside(const glm::vec2 &point) const = 0; +}; + +} // namespace yage + +#endif -- cgit