mirror of
https://gitee.com/yanmu_ym/cpp.git
synced 2026-02-09 20:34:56 +08:00
MAKE
This commit is contained in:
69
Make/2048/game-input.cpp
Normal file
69
Make/2048/game-input.cpp
Normal file
@@ -0,0 +1,69 @@
|
||||
#include "game-input.hpp"
|
||||
#include "global.hpp"
|
||||
|
||||
namespace Game {
|
||||
namespace Input {
|
||||
bool check_input_ansi(char c, intendedmove_t &intendedmove) {
|
||||
using namespace Keypress::Code;
|
||||
if (c == CODE_ANSI_TRIGGER_1) {
|
||||
getKeypressDownInput(c);
|
||||
if (c == CODE_ANSI_TRIGGER_2) {
|
||||
getKeypressDownInput(c);
|
||||
switch (c) {
|
||||
case CODE_ANSI_UP:
|
||||
intendedmove[FLAG_MOVE_UP] = true;
|
||||
return false;
|
||||
case CODE_ANSI_DOWN:
|
||||
intendedmove[FLAG_MOVE_DOWN] = true;
|
||||
return false;
|
||||
case CODE_ANSI_RIGHT:
|
||||
intendedmove[FLAG_MOVE_RIGHT] = true;
|
||||
return false;
|
||||
case CODE_ANSI_LEFT:
|
||||
intendedmove[FLAG_MOVE_LEFT] = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool check_input_vim(char c, intendedmove_t &intendedmove) {
|
||||
using namespace Keypress::Code;
|
||||
switch (toupper(c)) {
|
||||
case CODE_VIM_UP:
|
||||
intendedmove[FLAG_MOVE_UP] = true;
|
||||
return false;
|
||||
case CODE_VIM_LEFT:
|
||||
intendedmove[FLAG_MOVE_LEFT] = true;
|
||||
return false;
|
||||
case CODE_VIM_DOWN:
|
||||
intendedmove[FLAG_MOVE_DOWN] = true;
|
||||
return false;
|
||||
case CODE_VIM_RIGHT:
|
||||
intendedmove[FLAG_MOVE_RIGHT] = true;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool check_input_wasd(char c, intendedmove_t &intendedmove) {
|
||||
using namespace Keypress::Code;
|
||||
switch (toupper(c)) {
|
||||
case CODE_WASD_UP:
|
||||
intendedmove[FLAG_MOVE_UP] = true;
|
||||
return false;
|
||||
case CODE_WASD_LEFT:
|
||||
intendedmove[FLAG_MOVE_LEFT] = true;
|
||||
return false;
|
||||
case CODE_WASD_DOWN:
|
||||
intendedmove[FLAG_MOVE_DOWN] = true;
|
||||
return false;
|
||||
case CODE_WASD_RIGHT:
|
||||
intendedmove[FLAG_MOVE_RIGHT] = true;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} // namespace Input
|
||||
} // namespace Game
|
||||
Reference in New Issue
Block a user