コード例 #1
0
ファイル: WorldManager.cpp プロジェクト: schen59/Pong
void WorldManager::updateLeftPlayer(PaddleMove direction) {
	Paddle *leftPlayer = mWorld->getLeftPlayer();
	if (direction == MOVE_DOWN && !isLeftPlayerHitBottomWall()) {
		leftPlayer->setDirection(PADDLE_DIRECTION_DOWN);
	} else if (direction == MOVE_UP && !isLeftPlayerHitTopWall()) {
		leftPlayer->setDirection(PADDLE_DIRECTION_UP);
	} else {
		leftPlayer->stop();
	}
}
コード例 #2
0
ファイル: WorldManager.cpp プロジェクト: schen59/Pong
void WorldManager::updateRightPlayer(PaddleMove direction) {
	Paddle *rightPlayer = mWorld->getRightPlayer();
	if (direction == MOVE_DOWN && !isRightPlayerHitBottomWall()) {
		rightPlayer->setDirection(Ogre::Vector3(0, -1, 0));
	} else if (direction == MOVE_UP && !isRightPlayerHitTopWall()) {
		rightPlayer->setDirection(Ogre::Vector3(0, 1, 0));
	} else {
		rightPlayer->stop();
	}
}
コード例 #3
0
ファイル: AIManager.cpp プロジェクト: schen59/Pong
void AIManager::calculateNextMoveSimple() {
	Paddle* leftPlayer = mWorld->getLeftPlayer();
	Wall* bottomWall = mWorld->getBottomWall();
	Wall* topWall = mWorld->getTopWall();
	if (leftPlayer->hitVerticallyWith(bottomWall)) {
		leftPlayer->setDirection(PADDLE_DIRECTION_UP);
	} 
	if (leftPlayer->hitVerticallyWith(topWall)) {
		leftPlayer->setDirection(PADDLE_DIRECTION_DOWN);
	}
	if (leftPlayer->getDirection() == PADDLE_DIRECTION_DOWN) {
		mNextMove = MOVE_DOWN;
	} else {
		mNextMove = MOVE_UP;
	}
}