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(); } }
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(); } }
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; } }