Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 5, 2018, 12:12:36 AM (7 years ago)
Author:
dreherm
Message:

Afraid Test 7

File:
1 edited

Legend:

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

    r11944 r11945  
    7070            if(timer<=0){
    7171                afraid = false;
    72                 timer = 0;
     72                this->setNormal();
    7373            }
    7474        }
     
    8888
    8989        bcolli = false;
    90         for(int nrghost = 0; (nrghost<3) && (!bcolli); ++nrghost){
     90        for(int nrghost = 0; (nrghost<8) && (!bcolli); ++nrghost){
    9191            bcolli = collis(ghosts[nrghost]->getPosition(), currentPosition);
    9292            //orxout() << "GHOST" << nrghost << ghosts[nrghost]->getPosition() << endl;
     
    127127        }
    128128    else{
    129         for(int nrghost = 0; nrghost<3; ++nrghost){
     129        for(int nrghost = 0; nrghost<8; ++nrghost){
    130130        bcolli = collis(ghosts[nrghost]->getPosition(), currentPosition);
    131131        if(bcolli) ghosts[nrghost]->resetGhost();
     
    136136
    137137    void Pacman::setAfraid(){
    138         afraid = true;
     138
    139139        timer = 10; //Set timer to 10 seconds
     140
     141        //Change normal Ghosts with afraid ones
     142        if(!afraid){
     143            ghosts[0]->changewith(ghosts[4]);
     144            ghosts[1]->changewith(ghosts[5]);
     145            ghosts[2]->changewith(ghosts[6]);
     146            ghosts[3]->changewith(ghosts[7]);
     147        }
     148
     149        afraid = true;
     150    }
     151
     152    void Pacman::setNormal(){
     153
     154        timer = 0;
     155
     156        //Change normal Ghosts with afraid ones
     157        if(afraid){
     158            ghosts[4]->changewith(ghosts[0]);
     159            ghosts[5]->changewith(ghosts[1]);
     160            ghosts[6]->changewith(ghosts[2]);
     161            ghosts[7]->changewith(ghosts[3]);
     162        }
     163
     164        afraid = false;
    140165    }
    141166
Note: See TracChangeset for help on using the changeset viewer.