ChessPlusPlus  WIP
cplusplus.com Community Project
chesspp::gfx::GraphicsHandler Class Reference

Handles drawing graphics, such as pieces, trajectories, and boards. More...

#include <Graphics.hpp>

Public Member Functions

 GraphicsHandler (sf::RenderWindow &display, config::ResourcesConfig &resc, config::BoardConfig &bc)
 Constructs for a specific sf::RenderWindow given the resource and board configurations. More...
 
void drawBackground ()
 Draws the board background. More...
 
void drawSpriteAtCell (sf::Sprite &s, std::size_t x, std::size_t y)
 Draws any sprite in the center of cell at (x, y). More...
 
void drawPiece (piece::Piece const &p)
 Draws a piece at its real location. More...
 
void drawPieceAt (piece::Piece const &p, sf::Vector2i const &pos)
 Draws a piece at a different location than it actually is. More...
 
void drawTrajectory (piece::Piece const &p, bool enemy=false)
 Draws a piece's trajectory moves and capturing moves. More...
 
void drawBoard (board::Board const &b)
 Draws a board and its pieces. More...
 

Detailed Description

Handles drawing graphics, such as pieces, trajectories, and boards.

Constructor & Destructor Documentation

chesspp::gfx::GraphicsHandler::GraphicsHandler ( sf::RenderWindow &  display,
config::ResourcesConfig resc,
config::BoardConfig bc 
)

Constructs for a specific sf::RenderWindow given the resource and board configurations.

Parameters
displayThe sf::RenderWindow, must outlive this instance.
rescThe chesspp::config::ResourcesConfig, must outlive this instance.
bcThe chesspp::config::BoardConfig, must outlive this instance.

Member Function Documentation

void chesspp::gfx::GraphicsHandler::drawBackground ( )

Draws the board background.

void chesspp::gfx::GraphicsHandler::drawBoard ( board::Board const &  b)

Draws a board and its pieces.

Parameters
bThe board to draw.
void chesspp::gfx::GraphicsHandler::drawPiece ( piece::Piece const &  p)

Draws a piece at its real location.

Parameters
pThe piece to draw.
void chesspp::gfx::GraphicsHandler::drawPieceAt ( piece::Piece const &  p,
sf::Vector2i const &  pos 
)

Draws a piece at a different location than it actually is.

Parameters
pThe piece to draw.
posThe location to draw the piece at.
void chesspp::gfx::GraphicsHandler::drawSpriteAtCell ( sf::Sprite &  s,
std::size_t  x,
std::size_t  y 
)

Draws any sprite in the center of cell at (x, y).

Parameters
sThe sprite to draw, centered on (x, y). Changes the sprite's position.
void chesspp::gfx::GraphicsHandler::drawTrajectory ( piece::Piece const &  p,
bool  enemy = false 
)

Draws a piece's trajectory moves and capturing moves.

Parameters
pThe piece for which to draw trajectory and capturings.
enemytrue if the piece is an enemy piece, false otherwise.

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