From 0fdb0405b6567aed4cd00637f79410ceeafd2e3b Mon Sep 17 00:00:00 2001 From: roy Date: Mon, 29 Jun 2026 21:32:00 +0300 Subject: Added background color options. Added README.md. --- terminal-game-utils.hpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'terminal-game-utils.hpp') diff --git a/terminal-game-utils.hpp b/terminal-game-utils.hpp index 0e41074..328ff63 100644 --- a/terminal-game-utils.hpp +++ b/terminal-game-utils.hpp @@ -6,7 +6,7 @@ #include #include -namespace TGU { +namespace tgu { inline struct termios orig_termios; @@ -152,7 +152,7 @@ inline GameKey GetKeyPress() { return KeyMap[keypress_string]; } -// Terminal color printers: +// Text printers: inline void TextGreen() { std::cout << "\033[32m"; } @@ -160,12 +160,24 @@ inline void TextRed() { std::cout << "\033[31m"; } inline void TextBlue() { std::cout << "\033[34m"; } -inline void TextReset() { std::cout << "\033[0m"; } - inline void TextRGB(int r, int g, int b) { std::cout << std::format("\033[38;2;{};{};{}m", r, g, b); }; +// Background printers: + +inline void BGGreen() { std::cout << "\033[42m"; } + +inline void BGRed() { std::cout << "\033[41m"; } + +inline void BGBlue() { std::cout << "\033[44m"; } + +inline void BGRGB(int r, int g, int b) { + std::cout << std::format("\033[48;2;{};{};{}m", r, g, b); +} + +inline void TerminalColorReset() { std::cout << "\033[0m"; } + // Game buffer printers: inline void EnterGameBuffer() { std::cout << "\033[?1049h"; } @@ -175,4 +187,4 @@ inline void LeaveGameBuffer() { std::cout << "\033[?1049l"; } inline void MoveCursor(int row, int col) { std::cout << "\033[" << row << ";" << col << "H" << std::flush; } -}; // namespace TGU +}; // namespace tgu -- cgit v1.3.1