本文整理汇总了C++中PlayerState::GetY方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerState::GetY方法的具体用法?C++ PlayerState::GetY怎么用?C++ PlayerState::GetY使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerState
的用法示例。
在下文中一共展示了PlayerState::GetY方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: calculatePaths
void CDynamicProgrammingStrategy::calculatePaths() {
while (!stateQueue.empty()) {
PlayerState currentState = stateQueue.front();
for (int xDeviation = -1; xDeviation <= 1; ++xDeviation) {
for (int yDeviation = -1; yDeviation <= 1; ++yDeviation) {
PlayerState newState(
currentState.GetX() + currentState.GetXVelocity() + xDeviation,
currentState.GetY() + currentState.GetYVelocity() + yDeviation,
currentState.GetXVelocity() + xDeviation,
currentState.GetYVelocity() + yDeviation
);
if (newState.GetX() < 0 || newState.GetX() >= map.sizeOnXaxis()
|| newState.GetY() < 0 || newState.GetY() >= map.sizeOnYaxis()
|| !map.canPlayerStayOnCell(newState.GetX(), newState.GetY())
|| map.hasBarrierOnPath(currentState.GetX(), currentState.GetY(),
newState.GetX(), newState.GetY())) {
continue;
}
if (minPath.GetStepCount(newState) == -1 ||
minPath.GetStepCount(newState) > minPath.GetStepCount(currentState) + 1) {
minPath.SetStepCount(newState, minPath.GetStepCount(currentState) + 1);
minPath.SetPreviousState(newState, currentState);
stateQueue.push(newState);
}
}
}
stateQueue.pop();
}
}
示例2: nextMoveForPlayer
EMovementDirection Game::nextMoveForPlayer(int playerID) {
PlayerState currentPlayer = (*players)[playerID];
if (currentPlayer.GetX() == finishPoint.first && currentPlayer.GetY() == finishPoint.second) {
//std::cout << "FINISH" << std::endl;
return EMovementDirection::FINISH_POSITION;
} else {
SNode currentStart(currentPlayer.GetX(), currentPlayer.GetY(), currentPlayer.GetXVelocity(), currentPlayer.GetYVelocity());
SNode finish(finishPoint.first, finishPoint.second, 0, 0);
SNode resultNode = aStarStrategyOnYAGSBPL->searchPath(currentStart, finish);
(*players)[playerID].changePosition(std::make_pair(resultNode.position.first, resultNode.position.second));
(*players)[playerID].changeVelocityVector(std::make_pair(resultNode.velocityVector.first, resultNode.velocityVector.second));
return resultNode.direction;
}
}
示例3: canIntersectFinishLine
bool CDynamicProgrammingStrategy::canIntersectFinishLine(PlayerState state, int &xDeviation_, int &yDeviation_) const {
for (int xDeviation = -1; xDeviation <= 1; ++xDeviation) {
for (int yDeviation = -1; yDeviation <= 1; ++yDeviation) {
int newX = state.GetX() + state.GetXVelocity() + xDeviation;
int newY = state.GetY() + state.GetYVelocity() + yDeviation;
if (newX < 0 || newX >= map.sizeOnXaxis() ||
newY < 0 || newY >= map.sizeOnYaxis()) {
continue;
}
if (map.intersectFinishLine(state.GetX(), state.GetY(), newX, newY) &&
!map.hasBarrierOnPath(state.GetX(), state.GetY(), newX, newY))
{
xDeviation_ = xDeviation;
yDeviation_ = yDeviation;
return true;
}
}
}
return false;
}
示例4: make_pair
std::pair<int, int> CDynamicProgrammingStrategy::GetNextPosition() {
PlayerState nextState = optimalPath.top();
optimalPath.pop();
return std::make_pair(nextState.GetX(), nextState.GetY());
}