Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 9, 2019, 2:54:22 PM (5 years ago)
Author:
peterf
Message:

Improved formatting and added some comments to make the code more precise

File:
1 edited

Legend:

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

    r12338 r12357  
    11#include "PacmanRed.h"
    2 //#include "Pacman.h"
    32
    43#include "core/CoreIncludes.h"
     
    1615        this->target_x=0;
    1716        this->target_z=15;
    18         this->lastPlayerPassedPoint=Vector3(0,0,0); //Vector3(70,10,-135);
     17        this->lastPlayerPassedPoint=Vector3(0,0,0);
    1918        this->isNearPlayer=false;
    2019         
     
    3130    }
    3231
    33     /*void PacmanRed::setPlayerPos(Vector3 _playerPos)
    34     {
    35         this->playerPos = _playerPos;
    36     }*/
    37 
    38 
    3932    void PacmanRed::tick(float dt)
    4033    {
    41         //std::cout<<"LemanExpress5"<<endl;
    4234        SUPER(PacmanGhost, tick, dt);
    4335
     
    4537
    4638        for(int u=0; u < 67; u++){//always check if player passed a point
    47             //if(possibleposition[u]!=Vector3(0,10,15)){
     39           
    4840                if(jeanfindpos(this->getPlayerPos(), possibleposition[u])){
    49                     //if(!findpos(possibleposition[u],Vector3(0,10,15))){
     41                   
    5042                this->lastPlayerPassedPoint=possibleposition[u];
    51                             }
    52                         //}
    53                 //}
     43                            }   
    5444            }
    55 
    56             std::cout<<this->lastPlayerPassedPoint<<endl;
    57             std::cout<<this->pointInFrontOfPlayer<<endl;
    58 
    59 
    6045
    6146        //Stop, if target arrived
    6247        if((abs(this->actuelposition.x - this->target_x)<0.5) && (abs(this->actuelposition.z - this->target_z)<0.5)){
    63             //std::cout<<"LemanExpress1"<<endl;
     48           
    6449                 this->ismoving = false;
    6550        }
     
    6752        //Move, if ghost hasn't arrived yet
    6853        if(this->ismoving){
    69             //std::cout<<"LemanExpress2"<<endl;
     54           
    7055            if(!(abs(this->actuelposition.z-target_z)<0.5)) {
    7156                velocity = Vector3(0,0,-sgn(this->actuelposition.z-this->target_z));
     
    7661                move(dt, actuelposition, velocity);
    7762            }
    78             //std::cout<<"LemanExpress4"<<endl;
     63       
    7964        }
    8065        else if(this->lastPlayerPassedPoint==Vector3(0,0,0)){
     
    8974        //Check on which position the ghost has arrived and set new target
    9075        else{
    91             std::cout<<"LemanExpress3"<<endl;
    9276
    9377            while(lockmove){};
     
    9882
    9983            Vector3 redPos=Vector3(this->target_x, 10, this->target_z);
    100             //nextMove(this->getPlayerPos(), redPos);
    101 
    102             this->pointInFrontOfPlayer=frontPosition(); //getPointInFrontOfPacman(lastPlayerPassedPoint, directionV);
    103 
     84            this->pointInFrontOfPlayer=frontPosition();
    10485
    10586            if(!findpos(this->actuelposition, lastPlayerPassedPoint)){
    10687               
    107                 /*std::cout<<this->getPlayerPos()<<endl;
    108                 std::cout<<this->lastPlayerPassedPoint<<endl;
    109                 std::cout<<this->pointInFrontOfPlayer<<endl;
    110                 std::cout<<this->actuelposition<<endl;*/
    11188            nextMove(redPos, lastPlayerPassedPoint);
    112             std::cout<<"hiuddi"<<endl;
    11389            }
    11490            else if(findpos(this->actuelposition, lastPlayerPassedPoint)){// red pacman is at lastPlayerPassedPoint
    11591
    116                 /*std::cout<<"dhdidjop"<<endl;
    117                 std::cout<<this->getPlayerPos()<<endl;
    118                 std::cout<<this->lastPlayerPassedPoint<<endl;
    119                 std::cout<<this->pointInFrontOfPlayer<<endl;
    120                 std::cout<<this->actuelposition<<endl;*/
    121 
    122                 //if(!findpos(pointInFrontOfPlayer, Vector3(0,10,15))){
    123                 nextMove(lastPlayerPassedPoint, pointInFrontOfPlayer);
    124                     //}
    125                 std::cout<<"ogslodm"<<endl;
     92            nextMove(lastPlayerPassedPoint, pointInFrontOfPlayer);
    12693            }
    127 
    12894
    12995            lockmove=false; //NEVER FORGET THIS ONE !!!!!!!
Note: See TracChangeset for help on using the changeset viewer.