Yet Another Game Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
collider.h
Go to the documentation of this file.
1 
10 #pragma once
11 
12 #include <glm/glm.hpp>
13 
14 namespace yage
15 {
16 
17 // The Collider class helps collision detection by providing a general shape
18 // for different shapes to have their own collision algorithms.
19 class Collider
20 {
21 protected:
22  // position of the object
23  glm::vec2 position_;
24 
25  // size of the object
26  glm::vec2 size_;
27 
28 public:
29  Collider(const glm::vec2 &position, const glm::vec2 &size)
30  : position_(position), size_(size)
31  {
32  }
33 
34  // function that checks if two colliders are colliding
35  virtual bool collides(const Collider &collider) const = 0;
36 
37  // function that returns if a point is inside the shape
38  virtual bool inside(const glm::vec2 &point) const = 0;
39 };
40 
41 } // namespace yage
Collider(const glm::vec2 &position, const glm::vec2 &size)
Definition: collider.h:29
glm::vec2 position_
Definition: collider.h:23
virtual bool collides(const Collider &collider) const =0
virtual bool inside(const glm::vec2 &point) const =0
glm::vec2 size_
Definition: collider.h:26
Definition: collider.h:19