Sista v3.0.0-alpha.1
Sista is a C++ lightweight OS-agnostic library for terminal animations and videogames
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
sista::Pawn Class Reference

Represents an object on the field with a symbol, coordinates, and ANSI settings. More...

#include <pawn.hpp>

Collaboration diagram for sista::Pawn:
Collaboration graph
[legend]

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
 

Detailed Description

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.

Note
Pawns do not manage their own movement; this is handled by the Field class.
See also
Coordinates
ANSISettings
Field

Constructor & Destructor Documentation

◆ Pawn()

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

Parameters
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.

◆ ~Pawn()

virtual sista::Pawn::~Pawn ( )
inlinevirtual

Virtual destructor.

Member Function Documentation

◆ getCoordinates() [1/2]

Coordinates sista::Pawn::getCoordinates ( ) const

Gets the coordinates of the pawn.

Returns
The Coordinates of the pawn.

◆ getCoordinates() [2/2]

void sista::Pawn::getCoordinates ( Coordinates coordinates_) const

Gets the coordinates of the pawn.

Parameters
coordinates_A reference to a Coordinates object to store the pawn's coordinates.

◆ getSettings() [1/2]

ANSISettings sista::Pawn::getSettings ( ) const

Gets the ANSI settings of the pawn.

Returns
The ANSISettings of the pawn.

◆ getSettings() [2/2]

void sista::Pawn::getSettings ( ANSISettings settings_) const

Gets the ANSI settings of the pawn.

Parameters
settings_A reference to an ANSISettings object to store the pawn's settings.

◆ getSymbol()

char sista::Pawn::getSymbol ( ) const

Gets the symbol of the pawn.

Returns
The character symbol of the pawn.

◆ print()

void sista::Pawn::print ( ) const
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.

See also
ANSISettings::apply

◆ setCoordinates()

void sista::Pawn::setCoordinates ( const Coordinates coordinates_)

Sets the coordinates of the pawn.

Parameters
coordinates_The new Coordinates for the pawn.

◆ setSettings()

void sista::Pawn::setSettings ( const ANSISettings settings_)

Sets the ANSI settings of the pawn.

Parameters
settings_The new ANSISettings for the pawn.

◆ setSymbol()

void sista::Pawn::setSymbol ( char  symbol_)

Sets the symbol of the pawn.

Parameters
symbol_The new character symbol for the pawn.
Note
The symbol should be a printable character.
This method is a sheer setter, it does not handle reprinting the pawn on the field.

Member Data Documentation

◆ coordinates

Coordinates sista::Pawn::coordinates
protected

The character symbol representing the pawn

◆ settings

ANSISettings sista::Pawn::settings
protected

The coordinates of the pawn relatively to the field

◆ symbol

char sista::Pawn::symbol
protected

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