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 | Private Attributes
PLATFORM Class Reference

The PLATFORM class represents a movable platform object. More...

#include <platform.h>

Inheritance diagram for PLATFORM:
MovingObject CollidingObject

Public Member Functions

 PLATFORM (std::shared_ptr< SDL_Renderer > renderer, int x, int y, int min, int max, int speed)
 Constructs a new PLATFORM object with specified parameters.
 
void input (SDL_KeyboardEvent event, bool up)
 Handles input events for moving the platform.
 
void render (std::shared_ptr< SDL_Renderer > renderer, SDL_Color color1, SDL_Color color2) override
 Renders the platform on the screen.
 
void handleCollisions (point collision) override
 Handles collisions with other objects.
 
void move () override
 Moves the platform horizontally.
 
- Public Member Functions inherited from MovingObject
 MovingObject (int x, int y, int radius, const std::string &id)
 Constructs a new MovingObject with a circular collider.
 
 MovingObject (int x, int y, int width, int height, const std::string &id)
 Constructs a new MovingObject with a rectangular collider.
 
virtual void move ()=0
 Moves the object.
 
- Public Member Functions inherited from CollidingObject
 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.
 

Private Attributes

int max_width
 The maximum width of the platform's movement range.
 
int min_width
 The minimum width of the platform's movement range.
 
int speed
 The speed at which the platform moves.
 
std::shared_ptr< SDL_Renderer > renderer
 A shared pointer to the SDL renderer.
 

Additional Inherited Members

- Data Fields inherited from MovingObject
point Velocity
 The velocity of the object.
 
- Protected Attributes inherited from CollidingObject
std::shared_ptr< Collidercollider
 The collider associated with the object.
 

Detailed Description

The PLATFORM class represents a movable platform object.

The PLATFORM class inherits from the MovingObject class and represents a platform that can move horizontally.

Definition at line 20 of file platform.h.

Constructor & Destructor Documentation

◆ PLATFORM()

PLATFORM::PLATFORM ( std::shared_ptr< SDL_Renderer >  renderer,
int  x,
int  y,
int  min,
int  max,
int  speed 
)

Constructs a new PLATFORM object with specified parameters.

Parameters
rendererA shared pointer to the SDL renderer used for rendering.
xThe initial x-coordinate of the platform's position.
yThe initial y-coordinate of the platform's position.
minThe minimum width of the platform's movement range.
maxThe maximum width of the platform's movement range.
speedThe speed at which the platform moves.

Definition at line 9 of file platform.cpp.

Member Function Documentation

◆ handleCollisions()

void PLATFORM::handleCollisions ( point  collision)
inlineoverridevirtual

Handles collisions with other objects.

Parameters
collisionThe point of collision.

Implements CollidingObject.

Definition at line 62 of file platform.h.

◆ input()

void PLATFORM::input ( SDL_KeyboardEvent  event,
bool  up 
)

Handles input events for moving the platform.

Parameters
eventThe SDL keyboard event.
upA boolean indicating whether the keyboard key has been released or pressed.

Definition at line 13 of file platform.cpp.

◆ move()

void PLATFORM::move ( )
overridevirtual

Moves the platform horizontally.

Implements MovingObject.

Definition at line 31 of file platform.cpp.

◆ render()

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

Renders the platform on the screen.

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

Implements CollidingObject.

Definition at line 26 of file platform.cpp.

Field Documentation

◆ max_width

int PLATFORM::max_width
private

The maximum width of the platform's movement range.

Definition at line 22 of file platform.h.

◆ min_width

int PLATFORM::min_width
private

The minimum width of the platform's movement range.

Definition at line 23 of file platform.h.

◆ renderer

std::shared_ptr<SDL_Renderer> PLATFORM::renderer
private

A shared pointer to the SDL renderer.

Definition at line 25 of file platform.h.

◆ speed

int PLATFORM::speed
private

The speed at which the platform moves.

Definition at line 24 of file platform.h.


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