-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
default f11 key behavior add a "things to know" page to docs more readable documentation for functions
- Loading branch information
1 parent
500ac1b
commit 0ce2845
Showing
21 changed files
with
237 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/mirrors-clang-format | ||
rev: v16.0.5 | ||
hooks: | ||
- id: clang-format | ||
files: \.(c|cc|cpp|h|hpp|cxx|hh|hpp|tpp)$ | ||
- repo: https://github.com/pre-commit/mirrors-clang-format | ||
rev: v16.0.5 | ||
hooks: | ||
- id: clang-format | ||
files: \.(c|cc|cpp|h|hpp|cxx|hh|hpp|tpp)$ | ||
exclude: ^example/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
Things To Know | ||
============== | ||
|
||
This section contains information that you should be aware of when using Kraken Engine. | ||
|
||
Constant Prefixes | ||
~~~~~~~~~~~~~~~~~ | ||
|
||
When working with keyboard, mouse, and controller input, you will notice that the constants for the keys and buttons have prefixes. | ||
The prefixes are as follows: | ||
|
||
- ``K_`` for keyboard keycode constants | ||
- ``S_`` for keyboard scancode constants | ||
- ``M_`` for mouse button constants | ||
- ``C_`` for controller button constants | ||
|
||
For example, to check if the ``A`` button on a controller is pressed, you would use the following code: | ||
|
||
.. code-block:: cpp | ||
if (kn::controller::isPressed(kn::C_A)) { | ||
std::cout << "A button is pressed!" << std::endl; | ||
} | ||
Keycode VS Scancode | ||
~~~~~~~~~~~~~~~~~~~ | ||
|
||
Kraken Engine uses keycodes and scancodes to represent keyboard input. | ||
Keycodes are the character that the key represents, while scancodes are the physical location of the key on the keyboard. | ||
For example, the ``A`` key on a QWERTY keyboard has a keycode of ``K_a`` and a scancode of ``S_a``. | ||
|
||
If you are unsure which one to use, it is recommended to use keycodes in the event loop and scancodes for gameplay input. | ||
|
||
Here is a comparison of keycodes and scancodes for different scenarios: | ||
|
||
.. list-table:: | ||
:widths: 25 50 50 | ||
:header-rows: 1 | ||
|
||
* - Scenario | ||
- Keycode (``K_``) | ||
- Scancode (``S_``) | ||
* - Menu navigation | ||
- ✅ Layout-specific (intuitive keys) | ||
- ❌ Might mismatch user expectations | ||
* - Text input | ||
- ✅ Matches user's layout | ||
- ❌ Breaks for non-QWERTY layouts | ||
* - Gameplay movement | ||
- ❌ Layout-dependent inconsistency | ||
- ✅ Consistent across layouts | ||
* - Debug tools | ||
- ❌ User layout might vary | ||
- ✅ Always maps to physical key | ||
|
||
|
||
.. note:: This page is a work in progress and will be updated as more information becomes available. |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
input | ||
===== | ||
|
||
.. warning:: | ||
|
||
This namespace is still in development and is subject to change at any time. | ||
|
||
Description | ||
----------- | ||
|
||
The **input** namespace lets you create binds for different kinds of input. | ||
|
||
Usage | ||
----- | ||
|
||
.. code-block:: cpp | ||
/* Bind the 'left' action to: | ||
- The 'a' key | ||
- The left arrow key | ||
- The left stick (negative direction) on a controller | ||
*/ | ||
kn::input::bind( | ||
"left", | ||
{ | ||
kn::InputAction(kn::S_a), | ||
kn::InputAction(kn::S_LEFT), | ||
kn::InputAction(kn::C_AXIS_LEFTX, false), | ||
} | ||
); | ||
/* Bind the 'right' action to: | ||
- The 'd' key | ||
- The right arrow key | ||
- The left stick (positive direction) on a controller | ||
*/ | ||
kn::input::bind( | ||
"right", | ||
{ | ||
kn::InputAction(kn::S_d), | ||
kn::InputAction(kn::S_RIGHT), | ||
kn::InputAction(kn::C_AXIS_LEFTX, true), | ||
} | ||
); | ||
/* Bind the 'jump' action to: | ||
- The space key | ||
- The 'a' button on a controller | ||
*/ | ||
kn::input::bind( | ||
"jump", | ||
{ | ||
kn::InputAction(kn::S_SPACE), | ||
kn::InputAction(kn::C_A), | ||
} | ||
); | ||
// Check if the 'jump' action is pressed | ||
if (onGround) { | ||
if (kn::input::isPressed("jump")) { | ||
onGround = false; | ||
// Handle jump action | ||
} | ||
} | ||
// Get the direction of the 'left' and 'right' actions | ||
const double xDirection = kn::input::getDirection("left", "right").x; | ||
Members | ||
------- | ||
|
||
.. doxygenstruct:: kn::InputAction | ||
:members: | ||
|
||
Functions | ||
--------- | ||
|
||
.. doxygenfunction:: kn::input::bind | ||
|
||
.. doxygenfunction:: kn::input::unbind | ||
|
||
.. doxygenfunction:: kn::input::getDirection | ||
|
||
.. doxygenfunction:: kn::input::isPressed | ||
|
||
.. note:: Functions for getting input actions that were just pressed or just released are planned for the future. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.