void PlayerObject::move(const Ogre::FrameEvent &evt) { Ogre::Vector3 initialPosition = objectNode->getPosition(); Ogre::Vector3 destination = walkTo; Ogre::Real distance; Ogre::Real move; if (initialPosition != destination) { mDirection = destination - initialPosition; distance = mDirection.normalise(); move = mWalkSpeed * evt.timeSinceLastFrame; distance -= move; rotatePlayer(); if (distance <= 0.0f) { objectNode->setPosition(destination); setIdleAnimation(); } // if else { objectNode->translate(mDirection * move); if (!withinWorld()) { objectNode->setPosition(initialPosition); walkTo = initialPosition; setIdleAnimation(); } // if else { setWalkAnimation(); SoundManager::getInstance().PLAYER_FOOTSTEP_SOUND->stop(); SoundManager::getInstance().PLAYER_FOOTSTEP_SOUND->play(); } // else } // else } // if } // move
GridWorld::Tile* GridWorld::getTileAt(unsigned int x, unsigned int y) const{ return withinWorld(x, y) ? world[y*width+x] : NULL; }
GridWorld::Tile* GridWorld::getTileAt(unsigned int x, unsigned int y) const{ return withinWorld(x, y) ? (world.at(y*width + x)) : NULL; }