Sista v3.0.0-alpha.1
Sista is a C++ lightweight OS-agnostic library for terminal animations and videogames
|
Represents an object on the field with a symbol, coordinates, and ANSI settings. More...
#include <pawn.hpp>
Public Member Functions | |
Pawn (char, const Coordinates &, const ANSISettings &) | |
Constructor to initialize the pawn with a symbol, coordinates, and ANSI settings. | |
virtual | ~Pawn () |
Virtual destructor. | |
void | setCoordinates (const Coordinates &) |
Sets the coordinates of the pawn. | |
void | getCoordinates (Coordinates &) const |
Gets the coordinates of the pawn. | |
Coordinates | getCoordinates () const |
Gets the coordinates of the pawn. | |
void | setSettings (const ANSISettings &) |
Sets the ANSI settings of the pawn. | |
void | getSettings (ANSISettings &) const |
Gets the ANSI settings of the pawn. | |
ANSISettings | getSettings () const |
Gets the ANSI settings of the pawn. | |
void | setSymbol (char) |
Sets the symbol of the pawn. | |
char | getSymbol () const |
Gets the symbol of the pawn. | |
virtual void | print () const |
Prints the pawn to the terminal with its associated ANSI settings. | |
Protected Attributes | |
char | symbol |
Coordinates | coordinates |
ANSISettings | settings |
Represents an object on the field with a symbol, coordinates, and ANSI settings.
The Pawn class encapsulates a character symbol, its position on the field using Coordinates, and its appearance using ANSISettings. It provides methods to set and get these properties, as well as a method to print the pawn to the terminal with its associated ANSI settings.
The Pawn class is designed to be subclassed for specific types of pawns with additional behavior. Examples of subclasses could include players, enemies, or items in a videogame.
sista::Pawn::Pawn | ( | char | symbol_, |
const Coordinates & | coordinates_, | ||
const ANSISettings & | settings_ | ||
) |
Constructor to initialize the pawn with a symbol, coordinates, and ANSI settings.
The ANSI settings for the pawn
symbol_ | The character symbol for the pawn. |
coordinates_ | The Coordinates representing the pawn's position on the field. |
settings_ | The ANSISettings for the pawn's appearance. |
|
inlinevirtual |
Virtual destructor.
Coordinates sista::Pawn::getCoordinates | ( | ) | const |
Gets the coordinates of the pawn.
void sista::Pawn::getCoordinates | ( | Coordinates & | coordinates_ | ) | const |
Gets the coordinates of the pawn.
coordinates_ | A reference to a Coordinates object to store the pawn's coordinates. |
ANSISettings sista::Pawn::getSettings | ( | ) | const |
Gets the ANSI settings of the pawn.
void sista::Pawn::getSettings | ( | ANSISettings & | settings_ | ) | const |
Gets the ANSI settings of the pawn.
settings_ | A reference to an ANSISettings object to store the pawn's settings. |
char sista::Pawn::getSymbol | ( | ) | const |
Gets the symbol of the pawn.
|
virtual |
Prints the pawn to the terminal with its associated ANSI settings.
This method applies the pawn's ANSI settings (foreground color, background color, and attribute) and then prints the pawn's symbol to the terminal. The settings will be visible on characters printed after this call until they are reset or changed.
void sista::Pawn::setCoordinates | ( | const Coordinates & | coordinates_ | ) |
Sets the coordinates of the pawn.
coordinates_ | The new Coordinates for the pawn. |
void sista::Pawn::setSettings | ( | const ANSISettings & | settings_ | ) |
Sets the ANSI settings of the pawn.
settings_ | The new ANSISettings for the pawn. |
void sista::Pawn::setSymbol | ( | char | symbol_ | ) |
Sets the symbol of the pawn.
symbol_ | The new character symbol for the pawn. |
|
protected |
The character symbol representing the pawn
|
protected |
The coordinates of the pawn relatively to the field
|
protected |