Engine component responsible for distributing user input.
More...
#include <input.hpp>
|
auto | Is (const std::string &stringKey) const -> bool |
| Checks if input equals given string.
|
|
auto | Is (char charKey) const -> bool |
| Checks if input equals given character.
|
|
auto | Bigger (char charKey) const -> bool |
| Checks if given character is bigger than input.
|
|
auto | Smaller (char charKey) const -> bool |
| Checks if given character is smaller than input.
|
|
auto | Between (char start, char end) const -> bool |
| Checks if input is between range of characters.
|
|
auto | GetInt () const -> uint8_t |
| Get the first character of input as a 1-digit number.
|
|
void | CallCallbacks () |
| Distribute accumulated inputs.
|
|
|
class | Engine |
|
class | Output |
|
Engine component responsible for distributing user input.
◆ Between()
auto KTech::Input::Between |
( |
char | start, |
|
|
char | end ) const -> bool |
|
nodiscard |
Checks if input is between range of characters.
- Parameters
-
start | Start of (ASCII) character range. |
end | End of (ASCII) character range. |
- Returns
- True if between range (and
Input::input
is 1 character long), otherwise false.
◆ Bigger()
auto KTech::Input::Bigger |
( |
char | charKey | ) |
const -> bool |
|
nodiscard |
Checks if given character is bigger than input.
- Parameters
-
- Returns
- True if bigger (and
Input::input
is 1 character long), otherwise false.
◆ CallCallbacks()
void KTech::Input::CallCallbacks |
( |
| ) |
|
Distribute accumulated inputs.
Input
queues received inputs until this function is called. This very function is what calls your input callback functions.
Normally placed at the start of each game loop's iteration, with the other callback-calling functions of engine components (right now Memory::CallOnTicks()
and Time::CallInvocations()
, though this may change). For example:
{
{
map.Render();
}
{
}
}
World structure that renders Objects of Layers, and exists within Map.
Definition camera.hpp:41
void Draw(Point position=Point(0, 0), UPoint start=UPoint(0, 0), UPoint end=UPoint(0, 0), uint8_t alpha=std::numeric_limits< uint8_t >::max())
Draw the rendered image (Camera::m_image) to Output so it can be printed to the terminal.
Definition camera.cpp:182
Output output
Output engine component.
Definition engine.hpp:49
bool running
States whether the game loop should be running or not.
Definition engine.hpp:43
Time time
Time engine component.
Definition engine.hpp:50
Memory memory
Memory engine component.
Definition engine.hpp:48
Input input
Input engine component.
Definition engine.hpp:47
void CallOnTicks()
Call the virtual OnTick() functions of all registered world structures.
Definition memory.cpp:51
void Print()
Print the internal image buffer.
Definition output.cpp:264
auto ShouldRenderThisTick() -> bool
Check whether things changed and require a new render.
Definition output.cpp:357
auto ShouldPrintThisTick() const -> bool
Check whether the terminal changed and requires a new print.
Definition output.cpp:407
void WaitUntilNextTick()
Sleeps and returns when the next tick should start.
Definition time.cpp:111
void CallInvocations()
Call callback functions of finished Invocations.
Definition time.cpp:51
- See also
Memory::CallOnTicks()
-
Time::CallInvocations()
◆ GetInt()
auto KTech::Input::GetInt |
( |
| ) |
const -> uint8_t |
|
nodiscard |
Get the first character of input as a 1-digit number.
- Returns
- The first character of
Input::input
subtracted by 48 (the character '0'). Can return a value that is not 1-digit-long, so unless only digit characters ('0'-'9') can call your function, you should consider confirming with Input::Between()
and the arguments ('0', '9') that input is indeed a digit.
- See also
Input::Between()
◆ Is() [1/2]
auto KTech::Input::Is |
( |
char | charKey | ) |
const -> bool |
|
nodiscard |
Checks if input equals given character.
- Parameters
-
- Returns
- True if equal (and
Input::input
is 1 character long), otherwise false.
◆ Is() [2/2]
auto KTech::Input::Is |
( |
const std::string & | stringKey | ) |
const -> bool |
|
nodiscard |
Checks if input equals given string.
- Parameters
-
- Returns
- True if equal, otherwise false.
◆ Smaller()
auto KTech::Input::Smaller |
( |
char | charKey | ) |
const -> bool |
|
nodiscard |
Checks if given character is smaller than input.
- Parameters
-
- Returns
- True if smaller (and
Input::input
is 1 character long), otherwise false.
◆ input
std::string KTech::Input::input |
Input for the last-called callback function.
Before Input
calls your function, it will set this string to the exact input which lead to the calling of your function. It's especially useful if you have a function that can be triggered by different inputs, like a ranged callback function (created with CallbackGroup::RegisterRangedCallback()
): use this variable to evaluate the actual user input.
◆ quitKey
std::string KTech::Input::quitKey {"\x03"} |
Input that if received, breaks the input loop and sets Engine::running
to false.
By default, it's "\x03" (Ctrl+C), which is a common quit key among terminal applications. You may change it, but don't go Vim on your players.
The documentation for this class was generated from the following files:
- ktech/engine/input/input.hpp
- ktech/engine/input/input.cpp