/** Called when a mouse click happens. If the click happened while the mouse * was hovering on top of a challenge, the kart will be teleported to * the challenge. * \param x,y Mouse coordinates. */ void OverWorld::onMouseClick(int x, int y) { const OverworldChallenge *challenge = ((RaceGUIOverworld*)getRaceGUI())->getCurrentChallenge(); if(challenge) { // Use the 'get closest start point' rescue function // from WorldWithRank by setting the kart's position to // be the location of the challenge bubble. AbstractKart* kart = getKart(0); kart->setXYZ(challenge->m_position); unsigned int index = getRescuePositionIndex(kart); btTransform s = getRescueTransform(index); const btVector3 &xyz = s.getOrigin(); float angle = atan2(challenge->m_position.X - xyz[0], challenge->m_position.Z - xyz[2]); s.setRotation( btQuaternion(btVector3(0.0f, 1.0f, 0.0f), angle) ); moveKartTo(kart, s); return; } } // onMouseClick
/** Places a kart that is rescued. It calls getRescuePositionIndex to find * to which rescue position the kart should be moved, then getRescueTransform * to get the position and rotation of this rescue position, and then moves * the kart. * \param kart The kart that is rescued. */ void World::moveKartAfterRescue(AbstractKart* kart) { unsigned int index = getRescuePositionIndex(kart); btTransform t = getRescueTransform(index); moveKartTo(kart, t); } // moveKartAfterRescue