Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/adi3120/Fazen2d/llms.txt

Use this file to discover all available pages before exploring further.

Text writes a std::wstring into consecutive console cells starting at (x, y), setting each cell’s Char.UnicodeChar and Attributes fields directly in the ConsoleHandler back-buffer. Unlike the geometry primitives, Text does not go through Point::draw() — it writes to the buffer directly in a tight loop, so there is no built-in bounds check. It provides two construction paths: a wide-string literal overload and an integer overload that converts the number to a wstring via std::wostringstream, making it convenient for live score or counter displays.
#include "include/headers/Text.h"
Text.h pulls in <sstream> and <string> and brings std::wstring into scope.

Constructors

From a wide string

Text(float x, float y, wstring s, short color);
x
float
required
Starting column for the first character of the string.
y
float
required
Row at which the string is rendered. All characters share the same row.
s
wstring
required
The wide-character string to display. Use L"..." wide string literals. Supports any Unicode code points representable as wchar_t.
color
short
required
A ConsoleColor enum value applied to every character in the string (e.g. whiteF, yellowF).

From an integer

Text(float x, float y, int b, short color);
x
float
required
Starting column for the rendered number string.
y
float
required
Row at which the number is rendered.
b
int
required
Integer value converted to a wstring via std::wostringstream and stored as the internal string. Use setValue(int) to update it each frame.
color
short
required
A ConsoleColor enum value applied to every digit character.

Methods

MethodReturnsDescription
draw()voidIterates over the internal wstring, writing each wchar_t and the color attribute into consecutive back-buffer cells at row y starting from column x.
setValue(wstring s)voidReplaces the displayed string with a new wide-string value.
setValue(int b)voidConverts b to a wstring via std::wostringstream and replaces the displayed string. Useful for live integer counters.
setPosX(float) / getPosX()void / floatStarting column of the text.
setPosY(float) / getPosY()void / floatRow of the text.
setColor(short) / getColor()void / shortColor attribute applied to every character.
getValue()wstringReturns the current wstring value stored in the object.

Example

#include "include/headers/Fazen.h"

Text title(2.0f, 1.0f, L"Fazen2d Demo", whiteF);
Text score(2.0f, 3.0f, 0, yellowF);   // displays "0" initially

// Inside the game loop:
score.setValue(currentScore);          // update integer display each frame

game.graphics.draw(title);
game.graphics.draw(score);
Use wide string literals (L"...") for all Text values. You can embed Unicode code points directly in the literal: L"\u2665 Health: 100" renders as ♥ Health: 100. Any wchar_t-representable character is valid — block elements, box-drawing characters, and emoji all work as long as the console font supports them.
Text::draw() writes directly to the back-buffer without a bounds check. If x + value.length() exceeds ConsoleHandler::GetConsoleWidth(), the write wraps into the next row or beyond the buffer end, causing visual corruption or a buffer overrun. Always verify that (int)x + (int)value.size() <= ConsoleHandler::GetConsoleWidth() before drawing near the right edge.

Build docs developers (and LLMs) love