Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 24, 2018, 3:36:40 PM (7 years ago)
Author:
dreherm
Message:

Testversion 1

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.cc

    r11979 r11992  
    2121 *
    2222 *   Author:
    23  *      Oli Scheuss
     23 *      Marc Dreher
    2424 *   Co-authors:
    25  *      Damian 'Mozork' Frick
     25 *      ..
    2626 *
    2727 */
     
    6262    /**
    6363    @brief
    64         Destructor. Destroys controller, if present.
     64        Destructor. Destroys ghost, if present.
    6565    */
    6666    PacmanGhost::~PacmanGhost()
     
    7171    /**
    7272    @brief
    73         Method for creating a AutonomousDrone through XML.
     73        Method for creating a ghost through XML.
    7474    */
    7575    void PacmanGhost::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     
    7979
    8080
    81 
     81    //All positions in the map, see documentation
    8282    Vector3 possibleposition[] = {Vector3(20,10,245),Vector3(215,10,245),Vector3(215,10,195),Vector3(185,10,195),Vector3(135,10,195), //0-4
    8383        Vector3(185,10,150),Vector3(135,10,150),Vector3(215,10,150),Vector3(215,10,105),Vector3(135,10,105), //5-9
     
    9797    /**
    9898    @brief
    99         Defines which actions the AutonomousDrone has to take in each tick.
     99        Defines which actions the ghost has to take in each tick.
    100100    @param dt
    101101        The length of the tick.
     
    104104    {
    105105        SUPER(PacmanGhost, tick, dt);
    106 
    107         //setorientation
    108106
    109107        this->actuelposition = this->getPosition();
     
    340338    }
    341339
     340    //Random choice of new target (not used in game, but useful)
    342341    void PacmanGhost::setnewTarget(int firstdec){
    343342       
     
    352351    }
    353352
     353    //Random choice of new target
    354354    void PacmanGhost::setnewTarget(int firstdec, int seconddec){
    355355           decision = rand()%2;
     
    369369    }
    370370
     371    //Random choice of new target
    371372    void PacmanGhost::setnewTarget(int firstdec, int seconddec, int thirddec){
    372373       
     
    392393        }
    393394
     395    //Random choice of new target
    394396    void PacmanGhost::setnewTarget(int firstdec, int seconddec, int thirddec, int fourthdec){
    395397       
     
    420422        }
    421423
     424    //Change this with other ghost
    422425    void PacmanGhost::changewith(PacmanGhost* otherghost){
    423426
    424427        while(lockmove){};
    425         lockmove = true;
     428        lockmove = true;    //Prevent change of target while ghost is changed
    426429
    427430        otherghost->setPosition(this->getPosition());
    428431        this->setPosition(0,-20,0);
    429         otherghost->target_x = this->target_x;   //Probleme bei parallelen Porzessen
     432        otherghost->target_x = this->target_x;   
    430433        otherghost->target_z = this->target_z;
    431434        otherghost->ismoving = this->ismoving;
     
    437440    }
    438441
    439 
     442    //Move ghost with rotation
    440443    void PacmanGhost::move(float dt, Vector3 actuelposition, Vector3 velocity){
    441444        if(!dontmove){
    442445            this->setPosition(Vector3(actuelposition.x+speed*velocity.x*dt,10,actuelposition.z+speed*velocity.z*dt));
     446       
     447        //Rotate ghost in the direction of movement
    443448        if((abs(abs(velocity.x)-1)<0.1) && (abs(velocity.z-0)<0.1))
    444449            if(velocity.x<0){
     
    455460                 this->setOrientation(Quaternion(Radian(0), Vector3(0, 1, 0))); 
    456461            }
    457             this->getOrientation();
    458462                     
    459463     }
    460464    }
    461465
     466    //Check if there is a collision
    462467    bool PacmanGhost::findpos(Vector3 one, Vector3 other){
    463468       if((abs(one.x - other.x)<0.5) && (abs(one.y - other.y)<0.5) && (abs(one.z - other.z)<0.5)) return true;
     
    465470    }
    466471
     472    //Change ability to move
    467473    void PacmanGhost::changemovability(){
    468474        if(dontmove){
     
    473479    }
    474480
     481    //ResetGhost
    475482    void PacmanGhost::resetGhost(){
    476483   
     
    484491    }
    485492
     493    //Increase speed of ghosts
    486494    void PacmanGhost::levelupvelo(){
    487495        speed ++;
Note: See TracChangeset for help on using the changeset viewer.