mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Joystick sensitivity for player movement (#11262)
This commit deprecates the forward, backward, left, and right binary inputs currently used for player movement in the PlayerControl struct. In their place, it adds the movement_speed and movement_direction values, which represents the player movement is a polar coordinate system. movement_speed is a scalar from 0.0 to 1.0. movement_direction is an angle from 0 to +-Pi: FWD 0 _ LFT / \ RGT -Pi/2 | | +Pi/2 \_/ +-Pi BCK Boolean movement bits will still be set for server telegrams and Lua script invocations to provide full backward compatibility. When generating these values from an analog input, a direction is considered active when it is 22.5 degrees away from either orthogonal axis. Co-authored-by: Markus Koch <markus@notsyncing.net> Co-authored-by: sfan5 <sfan5@live.de>
This commit is contained in:
parent
149d8fc8d6
commit
1d69a23ba4
10 changed files with 137 additions and 98 deletions
|
@ -1392,13 +1392,13 @@ int ObjectRef::l_get_player_control(lua_State *L)
|
|||
|
||||
const PlayerControl &control = player->getPlayerControl();
|
||||
lua_newtable(L);
|
||||
lua_pushboolean(L, control.up);
|
||||
lua_pushboolean(L, player->keyPressed & (1 << 0));
|
||||
lua_setfield(L, -2, "up");
|
||||
lua_pushboolean(L, control.down);
|
||||
lua_pushboolean(L, player->keyPressed & (1 << 1));
|
||||
lua_setfield(L, -2, "down");
|
||||
lua_pushboolean(L, control.left);
|
||||
lua_pushboolean(L, player->keyPressed & (1 << 2));
|
||||
lua_setfield(L, -2, "left");
|
||||
lua_pushboolean(L, control.right);
|
||||
lua_pushboolean(L, player->keyPressed & (1 << 3));
|
||||
lua_setfield(L, -2, "right");
|
||||
lua_pushboolean(L, control.jump);
|
||||
lua_setfield(L, -2, "jump");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue