Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 21, 2019, 7:58:47 PM (5 years ago)
Author:
peterf
Message:

improved red pacman behavior, but still segmentation fault sometimes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/3DPacman_FS19/src/modules/pacman/PacmanRed.cc

    r12317 r12318  
    1717        this->target_z=15;
    1818        this->lastPlayerPassedPoint=Vector3(70,10,-135);
     19        this->isNearPlayer=false;
    1920         
    2021    }
     
    4243    void PacmanRed::tick(float dt)
    4344    {
     45        std::cout<<"LemanExpress5"<<endl;
    4446        SUPER(PacmanGhost, tick, dt);
    4547
     
    5254            }
    5355
    54        
     56
     57        /*if((playerFindPos(this->actuelposition, this->getPlayerPos()))&&(isNearPlayer==false)){
     58            isNearPlayer=true;
     59            setNewTargetRed(this->getPlayerPos());
     60        }
     61        else if (!(playerFindPos(this->actuelposition, this->getPlayerPos())&&(isNearPlayer==true))){
     62            isNearPlayer=false;
     63            setNewTargetRed(this->pointInFrontOfPlayer);
     64        }*/
     65
     66
     67
     68
    5569        //Stop, if target arrived
    5670        if((abs(this->actuelposition.x - this->target_x)<0.5) && (abs(this->actuelposition.z - this->target_z)<0.5)){
     71            std::cout<<"LemanExpress1"<<endl;
    5772                 this->ismoving = false;
    5873        }
     
    6075        //Move, if ghost hasn't arrived yet
    6176        if(this->ismoving){
     77            std::cout<<"LemanExpress2"<<endl;
    6278            if(!(abs(this->actuelposition.z-target_z)<0.5)) {
    6379                velocity = Vector3(0,0,-sgn(this->actuelposition.z-this->target_z));
     
    6884                move(dt, actuelposition, velocity);
    6985            }
     86            std::cout<<"LemanExpress4"<<endl;
    7087        }
    71        
     88
    7289        //Check on which position the ghost has arrived and set new target
    7390        else{
     91            std::cout<<"LemanExpress3"<<endl;
    7492
    7593            while(lockmove){};
     
    83101
    84102            int directionV = findPlayerTravDir (lastPlayerPassedPoint, this->getPlayerPos());
     103            this->pointInFrontOfPlayer=getPointInFrontOfPacman(lastPlayerPassedPoint, directionV);
    85104
    86105
    87             if(this->actuelposition!=lastPlayerPassedPoint){
     106            if(!findpos(this->actuelposition, lastPlayerPassedPoint)){
    88107               
    89108                std::cout<<this->getPlayerPos()<<endl;
    90109                std::cout<<this->lastPlayerPassedPoint<<endl;
    91                 std::cout<<getPointInFrontOfPacman(lastPlayerPassedPoint, directionV)<<endl;
     110                std::cout<<this->pointInFrontOfPlayer<<endl;
     111                std::cout<<this->actuelposition<<endl;
    92112            nextMove(redPos, lastPlayerPassedPoint);
     113            std::cout<<"hiuddi"<<endl;
    93114            }
    94             else{// red pacman is at lastPlayerPassedPoint
     115            else if(findpos(this->actuelposition, lastPlayerPassedPoint)){// red pacman is at lastPlayerPassedPoint
    95116
    96             //int directionV = findPlayerTravDir (lastPlayerPassedPoint, this->getPlayerPos());
     117                std::cout<<"dhdidjop"<<endl;
     118                std::cout<<this->getPlayerPos()<<endl;
     119                std::cout<<this->lastPlayerPassedPoint<<endl;
     120                std::cout<<this->pointInFrontOfPlayer<<endl;
     121                std::cout<<this->actuelposition<<endl;
    97122
    98             Vector3 pointInFrontOfPlayer = getPointInFrontOfPacman(lastPlayerPassedPoint, directionV);
    99 
    100             nextMove(redPos, pointInFrontOfPlayer);
    101 
    102             //nextMove(this->getPlayerPos(), redPos);
     123                nextMove(lastPlayerPassedPoint, pointInFrontOfPlayer);
     124                std::cout<<"ogslodm"<<endl;
    103125            }
    104126
Note: See TracChangeset for help on using the changeset viewer.