diff options
| author | roy <[email protected]> | 2026-07-03 18:13:34 +0300 |
|---|---|---|
| committer | roy <[email protected]> | 2026-07-03 18:13:34 +0300 |
| commit | f3f7c3157c887380781ce15d892ccb39a43456bc (patch) | |
| tree | 0753df2f919b60be0642b966a70208d6224a686e /terminal-game-utils.hpp | |
| parent | 43d0e1563ed212b9ddd189d8891d72ac165c9a02 (diff) | |
Fixed 0-indexing for moving cursor
Diffstat (limited to 'terminal-game-utils.hpp')
| -rw-r--r-- | terminal-game-utils.hpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/terminal-game-utils.hpp b/terminal-game-utils.hpp index 328ff63..189a7de 100644 --- a/terminal-game-utils.hpp +++ b/terminal-game-utils.hpp @@ -1,3 +1,4 @@ +#include <format> #include <iostream> #include <map> #include <ostream> @@ -146,10 +147,9 @@ inline GameKey GetKeyPress() { keypress_string += c; } - if (KeyMap.count(keypress_string)) + if (KeyMap.find(keypress_string) != KeyMap.end()) return KeyMap[keypress_string]; - - return KeyMap[keypress_string]; + return GameKey::INVALID; } // Text printers: @@ -185,6 +185,6 @@ inline void EnterGameBuffer() { std::cout << "\033[?1049h"; } inline void LeaveGameBuffer() { std::cout << "\033[?1049l"; } inline void MoveCursor(int row, int col) { - std::cout << "\033[" << row << ";" << col << "H" << std::flush; + std::cout << "\033[" << (row + 1) << ";" << (col + 1) << "H" << std::flush; } }; // namespace tgu |
