NWengine 0.9
Loading...
Searching...
No Matches
Collider.h
1#pragma once
2#include "GameObject.h"
3
7class Collider : public GameComponent {
8private:
9
10public:
15 static std::string GetType() { return "Collider"; }
16
17 GameObject* attachedObj;
18
19 fVec2 offset = fVec2(0.0f, 0.0f);
20
26
32 fVec2 GetEdgePosition(int index);
33
34 Collider() {};
36
37 std::vector<fVec2> edges = { fVec2(100,100), fVec2(-100,100), fVec2(-100,-100), fVec2(100,-100) }; // Trigonometric orientation
38
45 bool Sat(Collider* other, fVec2* depthBuffer = nullptr);
46
53 bool isColliding(Collider* other, fVec2* depthBuffer = nullptr);
54
55 void Start() override;
56
57 int Serialize(std::fstream* data, int offset) override;
58
59 int Deserialize(std::fstream* data, int offset) override;
60};
Defines the GameObject class and its related components.
The Collider class represents a base collider component.
Definition Collider.h:7
bool isColliding(Collider *other, fVec2 *depthBuffer=nullptr)
Check if this collider is colliding with another collider.
Definition Collider.cpp:81
int Serialize(std::fstream *data, int offset) override
Serialize the object and write it to the file.
Definition Collider.cpp:100
fVec2 GetPosition()
Get the position of the collider.
Definition Collider.cpp:27
fVec2 GetEdgePosition(int index)
Get the position of a specific edge of the collider.
Definition Collider.cpp:32
int Deserialize(std::fstream *data, int offset) override
Deserialize the object from the file.
Definition Collider.cpp:106
void Start() override
Start the game component.
Definition Collider.cpp:11
bool Sat(Collider *other, fVec2 *depthBuffer=nullptr)
Check if this collider is colliding with another collider using the Separating Axis Theorem (SAT).
Definition Collider.cpp:37
static std::string GetType()
Get the type of the collider.
Definition Collider.h:15
Base class for game components.
Definition GameObject.h:29
Class representing a game object.
Definition GameObject.h:68