瀏覽代碼

Switch from esdf controls to wasd, but support qwerty and azerty keyboards.

legacy
Sam Hocevar sam 14 年之前
父節點
當前提交
887e7b1690
共有 1 個檔案被更改,包括 5 行新增6 行删除
  1. +5
    -6
      src/input.cpp

+ 5
- 6
src/input.cpp 查看文件

@@ -41,12 +41,11 @@ Float2 Input::GetAxis(int axis)

/* Simulate a joystick using the keyboard. This SDL call is free. */
Uint8 *keystate = SDL_GetKeyState(NULL);
f.y -= keystate[SDLK_e];
f.y += keystate[SDLK_d];
f.x -= keystate[SDLK_s];
f.x += keystate[SDLK_f];
if (keystate[SDLK_e] + keystate[SDLK_d]
== keystate[SDLK_s] + keystate[SDLK_f])
int left = keystate[SDLK_d] - (keystate[SDLK_a] | keystate[SDLK_q]);
int up = keystate[SDLK_s] - (keystate[SDLK_w] | keystate[SDLK_z]);
f.y += up;
f.x += left;
if (left && up)
{
f.x *= invsqrt2;
f.y *= invsqrt2;


Loading…
取消
儲存