MCPcopy Create free account
hub / github.com/diasurgical/devilution / GetMoveDirection

Function GetMoveDirection

SourceX/controls/game_controls.cpp:255–274  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

253}
254
255MoveDirection GetMoveDirection()
256{
257 const float stickX = leftStickX;
258 const float stickY = leftStickY;
259 MoveDirection result{ MoveDirectionX::NONE, MoveDirectionY::NONE };
260
261 if (stickY >= 0.5 || IsControllerButtonPressed(ControllerButton::BUTTON_DPAD_UP)) {
262 result.y = MoveDirectionY::UP;
263 } else if (stickY <= -0.5 || IsControllerButtonPressed(ControllerButton::BUTTON_DPAD_DOWN)) {
264 result.y = MoveDirectionY::DOWN;
265 }
266
267 if (stickX <= -0.5 || IsControllerButtonPressed(ControllerButton::BUTTON_DPAD_LEFT)) {
268 result.x = MoveDirectionX::LEFT;
269 } else if (stickX >= 0.5 || IsControllerButtonPressed(ControllerButton::BUTTON_DPAD_RIGHT)) {
270 result.x = MoveDirectionX::RIGHT;
271 }
272
273 return result;
274}
275
276} // namespace dvl

Callers 1

MovementFunction · 0.85

Calls 1

Tested by

no test coverage detected