Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11900


Ignore:
Timestamp:
Apr 24, 2018, 1:10:36 PM (6 years ago)
Author:
dreherm
Message:

Add Ghost movements

Location:
code/branches/3DPacman_FS18
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/3DPacman_FS18/data/levels/templates/PacmanGelb.oxt

    r11898 r11900  
    3535   collisionType     = "dynamic"
    3636   mass              = 80
    37    linearDamping     = 0.7
     37   linearDamping     = 0.9
    3838   angularDamping    = 0.9999999
    3939  >
  • code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.cc

    r11898 r11900  
    8181
    8282   
    83     Vector3 possibleposition[] = {Vector3(0,10,245),Vector3(215,10,245),Vector3(215,10,210)};
     83    Vector3 possibleposition[] = {Vector3(175,10,245),Vector3(215,10,245),Vector3(215,10,195),Vector3(185,10,195),Vector3(135,10,195),
     84        Vector3(185,10,150),Vector3(135,10,145),Vector3(215,10,150)};
    8485
    8586    /**
     
    105106        if(this->ismoving){
    106107            if(!(abs(this->actuelposition.z-target_z)<0.1)) {
    107                 velocity = Vector3(-sgn(this->actuelposition.x-this->target_x),0,-sgn(this->actuelposition.z-this->target_z));
     108                velocity = Vector3(0,0,-sgn(this->actuelposition.z-this->target_z));
    108109                move(dt, actuelposition, velocity);
    109110            }   
    110111            if(!(abs(this->actuelposition.x-target_x)<0.1)){
    111                 velocity = Vector3(-sgn(this->actuelposition.x-this->target_x),0,-sgn(this->actuelposition.z-this->target_z));
     112                velocity = Vector3(-sgn(this->actuelposition.x-this->target_x),0,0);
    112113                move(dt, actuelposition, velocity);
    113114            }
     
    116117        //Check on which position ghost has arrived and set new target
    117118         else{
    118             if((abs(this->actuelposition.x - possibleposition[0].x)<0.1) && (abs(this->actuelposition.z - possibleposition[0].z)<0.1)){
     119            if(findpos(actuelposition,possibleposition[0])){
    119120                decision = rand()%1;
    120121            switch(decision){
     
    123124                    this->target_z = possibleposition[1].z;
    124125                    this->ismoving = true;
     126                    break;
    125127            }
    126128           
    127129            }
    128             else if((abs(actuelposition.x - possibleposition[1].x)<0.1) && (abs(actuelposition.z - possibleposition[1].z)<0.1)){
     130            else if(findpos(actuelposition,possibleposition[1])){
    129131                decision = rand()%2;
    130132            switch(decision){
     
    137139                    this->target_x = possibleposition[2].x;
    138140                    this->target_z = possibleposition[2].z;
    139                     this->ismoving = true;   
    140             }
    141 
    142             }
    143             if((abs(this->actuelposition.x - possibleposition[2].x)<0.1) && (abs(this->actuelposition.z - possibleposition[2].z)<0.1)){
    144                 decision = rand()%1;
     141                    this->ismoving = true;
     142                    break;   
     143            }
     144
     145            }
     146            else if(findpos(actuelposition,possibleposition[2])){
     147                decision = rand()%2;
    145148            switch(decision){
    146149                case 0:
     
    148151                    this->target_z = possibleposition[1].z;
    149152                    this->ismoving = true;
     153                    break;
     154                case 1:
     155                    this->target_x = possibleposition[3].x;
     156                    this->target_z = possibleposition[3].z;
     157                    this->ismoving = true;
     158                    break;
    150159            }
    151160           
    152161            }
     162
     163            else if(findpos(actuelposition,possibleposition[3])){
     164                decision = rand()%3;
     165            switch(decision){
     166                case 0:
     167                    this->target_x = possibleposition[2].x;
     168                    this->target_z = possibleposition[2].z;
     169                    this->ismoving = true;
     170                    break;
     171                case 1:
     172                    this->target_x = possibleposition[4].x;
     173                    this->target_z = possibleposition[4].z;
     174                    this->ismoving = true;
     175                    break;
     176                case 2:
     177                    this->target_x = possibleposition[5].x;
     178                    this->target_z = possibleposition[5].z;
     179                    this->ismoving = true;
     180                    break;       
     181            }
     182            }
     183
     184            else if(findpos(actuelposition,possibleposition[4])){
     185                decision = rand()%2;
     186            switch(decision){
     187                case 0:
     188                    this->target_x = possibleposition[3].x;
     189                    this->target_z = possibleposition[3].z;
     190                    this->ismoving = true;
     191                    break;
     192                case 1:
     193                    this->target_x = possibleposition[6].x;
     194                    this->target_z = possibleposition[6].z;
     195                    this->ismoving = true;
     196                    break;
     197            }
     198            }
     199
     200            else if(findpos(actuelposition,possibleposition[5])){
     201                decision = rand()%2;
     202            switch(decision){
     203                case 0:
     204                    this->target_x = possibleposition[3].x;
     205                    this->target_z = possibleposition[3].z;
     206                    this->ismoving = true;
     207                    break;
     208                case 1:
     209                    this->target_x = possibleposition[7].x;
     210                    this->target_z = possibleposition[7].z;
     211                    this->ismoving = true;
     212                    break;
     213            }
     214            }
     215
     216            else if(findpos(actuelposition,possibleposition[6])){
     217                decision = rand()%1;
     218            switch(decision){
     219                case 0:
     220                    this->target_x = possibleposition[4].x;
     221                    this->target_z = possibleposition[4].z;
     222                    this->ismoving = true;
     223                    break;
     224            }
     225            }
     226
     227            else if(findpos(actuelposition,possibleposition[7])){
     228                decision = rand()%1;
     229            switch(decision){
     230                case 0:
     231                    this->target_x = possibleposition[5].x;
     232                    this->target_z = possibleposition[5].z;
     233                    this->ismoving = true;
     234                    break;
     235            }
     236            }
     237
    153238
    154239            else{
     
    163248    }
    164249
     250    bool PacmanGhost::findpos(Vector3 one, Vector3 other){
     251        if((abs(one.x - other.x)<0.1) && (abs(one.z - other.z)<0.1)) return true;
     252        return false;
     253    }
     254
    165255    void PacmanGhost::resetGhost(){
    166256        this->setPosition(resetposition);
  • code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.h

    r11898 r11900  
    5151            void resetGhost();
    5252
     53            bool findpos(Vector3 one, Vector3 other);
     54
    5355            inline void setResetPosition(Vector3 rpos)
    5456                { this->resetposition = rpos; }   
Note: See TracChangeset for help on using the changeset viewer.