opengenerals/processor/logic/PlayerMove.cpp
2024-02-11 00:34:05 +08:00

27 lines
440 B
C++

#include <cstdint>
#include "PlayerMove.h"
#include "pc/commcode.h"
bool PlayerMove::isValid(pos_t w, pos_t h) const {
if (x >= h || y >= w)
return false;
if ((int)dir >= 4)
return false;
auto xx = tx(), yy = ty();
if (xx >= h || yy >= w)
return false;
return true;
}
pos_t PlayerMove::tx() const {
return x + direction_dx[(std::size_t)dir];
}
pos_t PlayerMove::ty() const {
return y + direction_dy[(std::size_t)dir];
}