#include "PacmanRed.h" //#include "Pacman.h" #include "core/CoreIncludes.h" #include "BulletDynamics/Dynamics/btRigidBody.h" namespace orxonox{ RegisterClass(PacmanRed); PacmanRed::PacmanRed(Context* context) : PacmanGhost(context){ RegisterObject(PacmanRed); } /** @brief Method for creating a ghost through XML. */ void PacmanRed::XMLPort(Element& xmlelement, XMLPort::Mode mode) { SUPER(PacmanRed, XMLPort, xmlelement, mode); } void PacmanRed::tick(float dt) { SUPER(PacmanGhost, tick, dt); this->actuelposition = this->getPosition(); //Stop, if target arrived if((abs(this->actuelposition.x - this->target_x)<0.5) && (abs(this->actuelposition.z - this->target_z)<0.5)){ this->ismoving = false; } //Move, if ghost hasn't arrived yet if(this->ismoving){ if(!(abs(this->actuelposition.z-target_z)<0.5)) { velocity = Vector3(0,0,-sgn(this->actuelposition.z-this->target_z)); move(dt, actuelposition, velocity); } if(!(abs(this->actuelposition.x-target_x)<0.5)){ velocity = Vector3(-sgn(this->actuelposition.x-this->target_x),0,0); move(dt, actuelposition, velocity); } } //Check on which position the ghost has arrived and set new target else{ while(lockmove){}; lockmove = true; //do red behavior Vector3 purePos = setPureArrayPos(this->actuelposition); //find nearest position on the map to red pos if pacman does not move, //i.e. reached a point on the map //Why not simply use target_x and target_z ?????? nextMove(purePos, player.actuelposition); //how do we access the PLAYER variable ?????? //also, player.lastPassedPoint is maybe better } } void PacmanRed::setNewTargetRed(Vector3 goalToGo){ this->target_x = goalToGo.x; this->target_z = goalToGo.z; this->ismoving = true; } void PacmanRed::nextMove(Vector3 playerPos, Vector3 redPos){ Vector3 nextTarget; nextTarget = getShortestPath(playerPos, redPos); setNewTargetRed(nextTarget); } //save last checkpoint crossed by player /* void PacmanGelb::tick(float dt){ //last passed point of player for(int u=0; u < 67; u++){ if(findpos(this->getPosition(), possibleposition[u])){ this->lastPassedPoint=possibleposition[u]; } } } */ }