本文整理汇总了C++中PlayerState::compare_directions方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerState::compare_directions方法的具体用法?C++ PlayerState::compare_directions怎么用?C++ PlayerState::compare_directions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerState
的用法示例。
在下文中一共展示了PlayerState::compare_directions方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateState
void ControlMethod::updateState(PlayerSlot &slot, PlayerState &state, const float dt) {
_updateState(slot, state, dt);
int dirs = 0;
dirs += state.left;
dirs += state.right;
dirs += state.up;
dirs += state.down;
int old_dirs = 0;
old_dirs += _old_state.left;
old_dirs += _old_state.right;
old_dirs += _old_state.up;
old_dirs += _old_state.down;
if (state.compare_directions(_old_state) || (old_dirs != 2 || dirs != 1)) {
_old_state = state;
return;
}
if (!_release_set) {
//LOG_DEBUG(("setting release timer"));
_release_timer.reset();
_release_set = true;
state = _old_state;
return;
} else if (_release_timer.tick(dt)) {
//LOG_DEBUG(("release timer stopped"));
_old_state = state;
_release_set = false;
} else {
if ((!state.left && _old_state.left) || (!state.right && _old_state.right)) {
if ((!state.up && _old_state.up) || (!state.down && _old_state.down)) {
LOG_DEBUG(("atomically update diagonal"));
_old_state = state;
_release_set = false;
return;
}
}
state = _old_state;
return;
}
}