casse-brick
Loading...
Searching...
No Matches
Public Member Functions | Data Fields
TriangleCollider Class Reference

The TriangleCollider class represents a triangular collider object. More...

#include <CollidingObject.h>

Inheritance diagram for TriangleCollider:
Collider

Public Member Functions

 TriangleCollider (point p, int h, int w, point p1, point p2, point p3, std::string id)
 Constructs a new TriangleCollider object with specified parameters.
 
std::tuple< bool, float, float > collided (const Collider &other) const override
 Checks for collision with another collider.
 
std::string getType () const override
 Gets the type of the collider.
 
void fillTriangle (const std::shared_ptr< SDL_Renderer > &renderer)
 Fills the triangle shape with the current renderer.
 
void render (std::shared_ptr< SDL_Renderer > renderer, SDL_Color color1, SDL_Color color2) override
 Renders the collider on the screen.
 
- Public Member Functions inherited from Collider
void move (point newPoint)
 Moves the collider to a new position.
 
void moveTo (point newPoint)
 Moves the collider to an absolute position.
 
virtual ~Collider ()=default
 Virtual destructor for the Collider class.
 
virtual std::tuple< bool, float, float > collided (const Collider &other) const =0
 Checks for collision with another collider.
 
virtual std::string getType () const =0
 Gets the type of the collider.
 
virtual void render (std::shared_ptr< SDL_Renderer > renderer, SDL_Color color1, SDL_Color color2)=0
 Renders the collider on the screen.
 

Data Fields

std::vector< pointcorner
 The vertices of the triangular collider.
 
int height
 The height of the triangular collider.
 
int width
 The width of the triangular collider.
 
- Data Fields inherited from Collider
std::string id
 The unique identifier of the collider.
 
point p
 The position of the collider.
 

Detailed Description

The TriangleCollider class represents a triangular collider object.

The TriangleCollider class inherits from the Collider class and represents a collider with a triangular shape.

Definition at line 201 of file CollidingObject.h.

Constructor & Destructor Documentation

◆ TriangleCollider()

TriangleCollider::TriangleCollider ( point  p,
int  h,
int  w,
point  p1,
point  p2,
point  p3,
std::string  id 
)
inline

Constructs a new TriangleCollider object with specified parameters.

Parameters
pThe position of the triangular collider.
hThe height of the triangular collider.
wThe width of the triangular collider.
p1The first vertex of the triangle.
p2The second vertex of the triangle.
p3The third vertex of the triangle.
idThe unique identifier of the collider.

Definition at line 218 of file CollidingObject.h.

Member Function Documentation

◆ collided()

std::tuple< bool, float, float > TriangleCollider::collided ( const Collider other) const
overridevirtual

Checks for collision with another collider.

Parameters
otherThe other collider to check for collision with.
Returns
A tuple containing a boolean indicating collision, and optional float values for collision parameters.

Implements Collider.

Definition at line 227 of file CollidingObject.cpp.

◆ fillTriangle()

void TriangleCollider::fillTriangle ( const std::shared_ptr< SDL_Renderer > &  renderer)

Fills the triangle shape with the current renderer.

Parameters
rendererA shared pointer to the SDL renderer used for rendering.

Definition at line 250 of file CollidingObject.cpp.

◆ getType()

std::string TriangleCollider::getType ( ) const
overridevirtual

Gets the type of the collider.

Returns
A string representing the type of the collider.

Implements Collider.

Definition at line 246 of file CollidingObject.cpp.

◆ render()

void TriangleCollider::render ( std::shared_ptr< SDL_Renderer >  renderer,
SDL_Color  color1,
SDL_Color  color2 
)
overridevirtual

Renders the collider on the screen.

Parameters
rendererA shared pointer to the SDL renderer used for rendering.
color1The primary color of the collider.
color2The secondary color of the collider.

Implements Collider.

Definition at line 264 of file CollidingObject.cpp.

Field Documentation

◆ corner

std::vector<point> TriangleCollider::corner

The vertices of the triangular collider.

Definition at line 203 of file CollidingObject.h.

◆ height

int TriangleCollider::height

The height of the triangular collider.

Definition at line 204 of file CollidingObject.h.

◆ width

int TriangleCollider::width

The width of the triangular collider.

Definition at line 205 of file CollidingObject.h.


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