libtcod
Loading...
Searching...
No Matches
Consoles (C++)

Classes

class  TCODConsole
 Classic turn by turn game loop:TCODConsole::initRoot(80,50,"my game",false); while (!endGame && !TCODConsole::isWindowClosed()) { ... draw on TCODConsole::root TCODConsole::flush(); TCOD_key_t key; TCODConsole::waitForEvent(TCOD_EVENT_KEY_PRESS,&key,NULL,true); ... update world, using key }. More...

Functions

void tcod::blit (TCOD_Console &dest, const TCOD_Console &source, const std::array< int, 2 > &dest_xy={0, 0}, std::array< int, 4 > source_rect={0, 0, 0, 0}, float foreground_alpha=1.0f, float background_alpha=1.0f)
 Blit a region of tiles from one console to another.
void tcod::draw_rect (TCOD_Console &console, const std::array< int, 4 > &rect, int ch, std::optional< TCOD_ColorRGB > fg, std::optional< TCOD_ColorRGB > bg, TCOD_bkgnd_flag_t flag=TCOD_BKGND_SET)
 Fill a region with the given graphic.
void tcod::draw_frame (TCOD_Console &console, const std::array< int, 4 > &rect, const std::array< int, 9 > &decoration, std::optional< TCOD_ColorRGB > fg, std::optional< TCOD_ColorRGB > bg, TCOD_bkgnd_flag_t flag=TCOD_BKGND_SET, bool clear=true)
 Draw a decorative frame.
std::vector< tcod::ConsolePtrtcod::load_xp (const std::filesystem::path &path)
 Load an array of consoles from a REXPaint file.
void tcod::save_xp (const std::vector< const TCOD_Console * > &consoles, const std::filesystem::path &path, int compress_level=9)
 Save an array of consoles to a REXPaint file.

Detailed Description

Function Documentation

◆ blit()

void tcod::blit ( TCOD_Console & dest,
const TCOD_Console & source,
const std::array< int, 2 > & dest_xy = {0, 0},
std::array< int, 4 > source_rect = {0, 0, 0, 0},
float foreground_alpha = 1.0f,
float background_alpha = 1.0f )
inline

Blit a region of tiles from one console to another.

Parameters
destThe destination console.
sourceThe source console to blit from.
dest_xyThe upper-left position of the destination console to blit to.
source_rectThe source region {left, top, width, height} to blit from. A width or height of zero will use the entire console.
foreground_alpha
background_alpha

◆ draw_frame()

void tcod::draw_frame ( TCOD_Console & console,
const std::array< int, 4 > & rect,
const std::array< int, 9 > & decoration,
std::optional< TCOD_ColorRGB > fg,
std::optional< TCOD_ColorRGB > bg,
TCOD_bkgnd_flag_t flag = TCOD_BKGND_SET,
bool clear = true )
inline

Draw a decorative frame.

Parameters
consoleA reference to a TCOD_Console.
rectAn {x, y, width, height} rectangle, starting from the upper-left-most tile as zero.
decorationThe codepoints to use for the frame in row-major order.
fgThe foreground color. The printed text is set to this color. If std::nullopt then the foreground will be left unchanged, inheriting the previous value of the tile.
bgThe background color. The background tile under the printed text is set to this color. If std::nullopt then the background will be left unchanged.
flagThe background blending flag.
clearIf true then the center area will be cleared with the center decoration.

decoration is given the codepoints to be used for the edges, corners, and fill of the frame in this order:

0 1 2
3 4 5
6 7 8
auto console = tcod::Console{80, 50};
static constexpr std::array<int, 9> LEGEND = {'0', '1', '2', '3', '4', '5', '6', '7', '8'};
tcod::draw_frame(console, {0, 0, 3, 3}, LEGEND, {{255, 255, 255}}, {{0, 0, 0}});
A managed libtcod console containing a grid of tiles with {ch, fg, bg} information.
Definition console_types.hpp:80
void draw_frame(TCOD_Console &console, const std::array< int, 4 > &rect, const std::array< int, 9 > &decoration, std::optional< TCOD_ColorRGB > fg, std::optional< TCOD_ColorRGB > bg, TCOD_bkgnd_flag_t flag=TCOD_BKGND_SET, bool clear=true)
Draw a decorative frame.
Definition console_drawing.h:222
embed:rst:leading-asterisk 
.. versionadded:: 1.19

◆ draw_rect()

void tcod::draw_rect ( TCOD_Console & console,
const std::array< int, 4 > & rect,
int ch,
std::optional< TCOD_ColorRGB > fg,
std::optional< TCOD_ColorRGB > bg,
TCOD_bkgnd_flag_t flag = TCOD_BKGND_SET )
inline

Fill a region with the given graphic.

Parameters
consoleA reference to a TCOD_Console.
rectAn {x, y, width, height} rectangle, starting from the upper-left-most tile as zero.
chThe character to draw. If zero then the characters in the drawing region will not be changed.
fgThe foreground color. The printed text is set to this color. If std::nullopt then the foreground will be left unchanged, inheriting the previous value of the tile.
bgThe background color. The background tile under the printed text is set to this color. If std::nullopt then the background will be left unchanged.
flagThe background blending flag.
auto console = tcod::Console{80, 50};
// Draw a red background without replacing any foreground glyphs/colors.
tcod::draw_rect(console, {2, 2, 24, 24}, 0, std::nullopt, tcod::ColorRGB{255, 0, 0});
// Draw a horizontal bar.
tcod::draw_rect(console, {8, 8, 16, 1}, '-', {{255, 255, 255}}, std::nullopt);
void draw_rect(TCOD_Console &console, const std::array< int, 4 > &rect, int ch, std::optional< TCOD_ColorRGB > fg, std::optional< TCOD_ColorRGB > bg, TCOD_bkgnd_flag_t flag=TCOD_BKGND_SET)
Fill a region with the given graphic.
Definition console_drawing.h:182
embed:rst:leading-asterisk 
.. versionadded:: 1.19

◆ load_xp()

std::vector< tcod::ConsolePtr > tcod::load_xp ( const std::filesystem::path & path)
inline

Load an array of consoles from a REXPaint file.

Parameters
pathThe path to the REXPaint file to load.
Returns
Returns a vector of consoles.
embed:rst:leading-asterisk 
.. versionadded:: 1.18

◆ save_xp()

void tcod::save_xp ( const std::vector< const TCOD_Console * > & consoles,
const std::filesystem::path & path,
int compress_level = 9 )
inline

Save an array of consoles to a REXPaint file.

Parameters
consolesA vector of consoles to save.
pathThe path to write the REXPaint file to.
compress_levelA compression level for the zlib library.
embed:rst:leading-asterisk 
.. versionadded:: 1.18