casse-brick latest
Ce projet est réalisé dans le cadre du cours de Programmation Avancée en M1 Informatique de l'université de Strasbourg.
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes
CollidingObject Class Referenceabstract

The CollidingObject class represents a generic colliding object. More...

#include <CollidingObject.h>

Inheritance diagram for CollidingObject:
Brique MovingObject WALL Hexagon Rectangle Triangle Ball PLATFORM

Public Member Functions

 CollidingObject (int x, int y, int radius, const std::string &id)
 Constructs a new CollidingObject with a circular collider.
 
 CollidingObject (int x, int y, int width, int height, const std::string &id)
 Constructs a new CollidingObject with a rectangular collider.
 
 CollidingObject (int x, int y, int width, int height, bool isTop, const std::string &id)
 Constructs a new CollidingObject with a triangular collider.
 
 CollidingObject (int x, int y, int width, int height, int edges, const std::string &id)
 Constructs a new CollidingObject with a hexagonal collider.
 
std::shared_ptr< CollidergetCollider ()
 Gets the collider associated with the object.
 
virtual void handleCollisions (point collision)=0
 Handles collisions with other objects.
 
virtual void render (std::shared_ptr< SDL_Renderer > renderer, SDL_Color color1, SDL_Color color2)=0
 Renders the object on the screen.
 

Protected Attributes

std::shared_ptr< Collidercollider
 The collider associated with the object.
 

Detailed Description

The CollidingObject class represents a generic colliding object.

The CollidingObject class provides functionality for handling collisions and rendering in a game environment.

Definition at line 377 of file CollidingObject.h.

Constructor & Destructor Documentation

◆ CollidingObject() [1/4]

CollidingObject::CollidingObject ( int  x,
int  y,
int  radius,
const std::string &  id 
)
inline

Constructs a new CollidingObject with a circular collider.

Parameters
xThe x-coordinate of the object's position.
yThe y-coordinate of the object's position.
radiusThe radius of the circular collider.
idThe unique identifier of the collider.

Definition at line 390 of file CollidingObject.h.

◆ CollidingObject() [2/4]

CollidingObject::CollidingObject ( int  x,
int  y,
int  width,
int  height,
const std::string &  id 
)
inline

Constructs a new CollidingObject with a rectangular collider.

Parameters
xThe x-coordinate of the object's position.
yThe y-coordinate of the object's position.
widthThe width of the rectangular collider.
heightThe height of the rectangular collider.
idThe unique identifier of the collider.

Definition at line 404 of file CollidingObject.h.

◆ CollidingObject() [3/4]

CollidingObject::CollidingObject ( int  x,
int  y,
int  width,
int  height,
bool  isTop,
const std::string &  id 
)
inline

Constructs a new CollidingObject with a triangular collider.

Parameters
xThe x-coordinate of the object's position.
yThe y-coordinate of the object's position.
widthThe width of the triangular collider.
heightThe height of the triangular collider.
isTopFlag indicating whether the object is a top object.
idThe unique identifier of the collider.

Definition at line 419 of file CollidingObject.h.

◆ CollidingObject() [4/4]

CollidingObject::CollidingObject ( int  x,
int  y,
int  width,
int  height,
int  edges,
const std::string &  id 
)
inline

Constructs a new CollidingObject with a hexagonal collider.

Parameters
xThe x-coordinate of the object's position.
yThe y-coordinate of the object's position.
widthThe width of the hexagonal collider.
heightThe height of the hexagonal collider.
edgesThe number of edges of the hexagon.
idThe unique identifier of the collider.

Definition at line 444 of file CollidingObject.h.

Member Function Documentation

◆ getCollider()

std::shared_ptr< Collider > CollidingObject::getCollider ( )

Gets the collider associated with the object.

Returns
A shared pointer to the collider.

Definition at line 16 of file CollidingObject.cpp.

◆ handleCollisions()

virtual void CollidingObject::handleCollisions ( point  collision)
pure virtual

Handles collisions with other objects.

Parameters
collisionThe point of collision.

Implemented in Ball, Brique, PLATFORM, and WALL.

◆ render()

virtual void CollidingObject::render ( std::shared_ptr< SDL_Renderer >  renderer,
SDL_Color  color1,
SDL_Color  color2 
)
pure virtual

Renders the object on the screen.

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

Implemented in Ball, Hexagon, PLATFORM, Rectangle, Triangle, and WALL.

Field Documentation

◆ collider

std::shared_ptr<Collider> CollidingObject::collider
protected

The collider associated with the object.

Definition at line 379 of file CollidingObject.h.


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