NWengine 0.9
Loading...
Searching...
No Matches
Collider Class Reference

The Collider class represents a base collider component. More...

#include <Collider.h>

Inheritance diagram for Collider:
GameComponent Serialized

Public Member Functions

fVec2 GetPosition ()
 Get the position of the collider.
 
fVec2 GetEdgePosition (int index)
 Get the position of a specific edge of the collider.
 
 Collider (GameObject *go)
 
bool Sat (Collider *other, fVec2 *depthBuffer=nullptr)
 Check if this collider is colliding with another collider using the Separating Axis Theorem (SAT).
 
bool isColliding (Collider *other, fVec2 *depthBuffer=nullptr)
 Check if this collider is colliding with another collider.
 
void Start () override
 Start the game component.
 
int Serialize (std::fstream *data, int offset) override
 Serialize the object and write it to the file.
 
int Deserialize (std::fstream *data, int offset) override
 Deserialize the object from the file.
 
- Public Member Functions inherited from GameComponent
virtual void Update ()
 Update the game component.
 
virtual void SetGameObject (void *go)
 Set the GameObject associated with the game component.
 
virtual voidGetGameObject ()
 Get the GameObject associated with the game component.
 
virtual ~GameComponent ()
 Destructor for the game component.
 
- Public Member Functions inherited from Serialized
 Serialized ()
 Default constructor for Serialized class.
 

Static Public Member Functions

static std::string GetType ()
 Get the type of the collider.
 
- Static Public Member Functions inherited from GameComponent
static std::string GetType ()
 Get the type of the game component.
 

Public Attributes

GameObjectattachedObj
 
fVec2 offset = fVec2(0.0f, 0.0f)
 
std::vector< fVec2edges = { fVec2(100,100), fVec2(-100,100), fVec2(-100,-100), fVec2(100,-100) }
 

Detailed Description

The Collider class represents a base collider component.

Represents a collider component that can be attached to a game object.

Member Function Documentation

◆ Deserialize()

int Collider::Deserialize ( std::fstream * data,
int offset )
overridevirtual

Deserialize the object from the file.

Parameters
dataThe file stream to read the serialized data from.
offsetThe offset in the file to start reading the serialized data.
Returns
The number of bytes read from the file, or -1 if an error occurred.

Reimplemented from Serialized.

◆ GetEdgePosition()

fVec2 Collider::GetEdgePosition ( int index)

Get the position of a specific edge of the collider.

Parameters
indexThe index of the edge.
Returns
The position of the edge.

◆ GetPosition()

fVec2 Collider::GetPosition ( )

Get the position of the collider.

Returns
The position of the collider.

◆ GetType()

static std::string Collider::GetType ( )
inlinestatic

Get the type of the collider.

Returns
The type of the collider.

◆ isColliding()

bool Collider::isColliding ( Collider * other,
fVec2 * depthBuffer = nullptr )

Check if this collider is colliding with another collider.

Parameters
otherThe other collider to check against.
depthBufferA pointer to a vector to store the collision depth.
Returns
True if the colliders are colliding, false otherwise.

◆ Sat()

bool Collider::Sat ( Collider * other,
fVec2 * depthBuffer = nullptr )

Check if this collider is colliding with another collider using the Separating Axis Theorem (SAT).

Parameters
otherThe other collider to check against.
depthBufferA pointer to a vector to store the collision depth.
Returns
True if the colliders are colliding, false otherwise.

◆ Serialize()

int Collider::Serialize ( std::fstream * data,
int offset )
overridevirtual

Serialize the object and write it to the file.

Parameters
dataThe file stream to write the serialized data to.
offsetThe offset in the file to start writing the serialized data.
Returns
The number of bytes written to the file, or -1 if an error occurred.

Reimplemented from Serialized.

◆ Start()

void Collider::Start ( )
overridevirtual

Start the game component.

Reimplemented from GameComponent.


The documentation for this class was generated from the following files: