Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11945


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

Afraid Test 7

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

Legend:

Unmodified
Added
Removed
  • code/branches/3DPacman_FS18/data/levels/3DPacman.oxw

    r11933 r11945  
    6060
    6161
    62 
    63 
     62<PacmanGhost position="0,-20,0" >
     63    <attached>
     64        <Model position="0,0,0" mesh="PacmanGhostAfraid.mesh" scale="5" />
     65    </attached>
     66</PacmanGhost>
    6467
    6568<PacmanGhost position="0,-20,0" >
     
    6972</PacmanGhost>
    7073
    71 <PacmanPointAfraid position="215,10,195">
     74<PacmanGhost position="0,-20,0" >
    7275    <attached>
    73         <Model position="0,0,0" mesh="PacmanPointAfraid.mesh" scale="5" />
     76        <Model position="0,0,0" mesh="PacmanGhostAfraid.mesh" scale="5" />
    7477    </attached>
    75 </PacmanPointAfraid>
     78</PacmanGhost>
    7679
     80<PacmanGhost position="0,-20,0" >
     81    <attached>
     82        <Model position="0,0,0" mesh="PacmanGhostAfraid.mesh" scale="5" />
     83    </attached>
     84</PacmanGhost>
    7785
    7886
  • 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
  • code/branches/3DPacman_FS18/src/modules/pacman/Pacman.h

    r11944 r11945  
    8181            int getPoints();
    8282            void setAfraid();
     83            void setNormal();
    8384
    8485
  • code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.cc

    r11944 r11945  
    5151       
    5252        this->actuelposition = this->getPosition();
     53
     54        if(findpos(actuelposition, Vector3(0,-20,0)))
     55            dontmove = true;
    5356       
    5457        this->target_x = actuelposition.x;
     
    414417        }
    415418
     419    void changewith(PacmanGhost* otherghost){
     420        otherghost->setPosition(this->getPosition());
     421        this->setPosition(0,-20,0);
     422        otherghost->target_x = this->target_x;   //Probleme bei parallelen Porzessen
     423        otherghost->target_y = this->target_y;
     424        otherghost->ismoving = this->ismoving;
     425
     426        this->dontmove = true;
     427        otherghost->dontmove = false;
     428    }
    416429
    417430
     
    422435
    423436    bool PacmanGhost::findpos(Vector3 one, Vector3 other){
    424        if((abs(one.x - other.x)<0.5) && (abs(one.z - other.z)<0.5)) return true;
     437       if((abs(one.x - other.x)<0.5) && (abs(one.y - other.y)<0.5) && (abs(one.z - other.z)<0.5)) return true;
    425438        return false;
    426439    }
  • code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.h

    r11940 r11945  
    5555            void setnewTarget(int firstdec, int seconddec, int thirddec);
    5656            void setnewTarget(int firstdec, int seconddec, int thirddec, int fourthdec);
    57 
     57            void changewith(PacmanGhost* otherghost);
    5858
    5959            bool findpos(Vector3 one, Vector3 other);     
    6060            void changemovability();
    6161            bool dontmove = false;
    62         private:
     62
     63            Vector3 actuelposition;
    6364            bool ismoving = false;
    64             int decision = 0; //Gives the random which way information to the ghost.
    6565            int target_x = 0;
    6666            int target_z = 0;
    67             Vector3 actuelposition;
     67           
     68        private:
     69            int decision = 0; //Gives the random which way information to the ghost.
    6870            Vector3 velocity;
    6971            Vector3 resetposition = Vector3(0,10,15);
Note: See TracChangeset for help on using the changeset viewer.