Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11933 for code


Ignore:
Timestamp:
May 3, 2018, 3:45:20 PM (6 years ago)
Author:
dreherm
Message:

Afraid Ghosts

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

Legend:

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

    r11931 r11933  
    5959</PacmanGhost>
    6060
     61
     62
     63
     64
     65<PacmanGhost position="0,-20,0" >
     66    <attached>
     67        <Model position="0,0,0" mesh="PacmanGhostAfraid.mesh" scale="5" />
     68    </attached>
     69</PacmanGhost>
     70
     71<PacmanPointAfraid position="215,10,195">
     72    <attached>
     73        <Model position="0,0,0" mesh="PacmanPointAfraid.mesh" scale="5" />
     74    </attached>
     75</PacmanPointAfraid>
     76
     77
     78
     79
    6180<!-- POINTS -->
    6281<PacmanPointSphere position="0,10,0">
     
    7897</PacmanPointSphere>
    7998
     99<PacmanPointAfraid position="215,10,195">
     100    <attached>
     101        <Model position="0,0,0" mesh="PacmanPointAfraid.mesh" scale="5" />
     102    </attached>
     103</PacmanPointAfraid>
    80104
    81105<!-- Map -->
  • code/branches/3DPacman_FS18/src/modules/pacman/Pacman.cc

    r11931 r11933  
    9696        }
    9797
     98        for(PacmanPointAfraid* next : ObjectList<PacmanPointAfraid>()){
     99            if(collis(next->getPosition(), currentPosition)){
     100                setAfraid();
     101            }
     102        }
     103
    98104    }
    99105
     
    106112
    107113    void Pacman::catched(){
     114
     115    if(!afraid) {
    108116        if(!lives) this->end();
    109117        --lives;
    110118        this->posreset();
     119        }
     120    else{
     121
     122        for(int nrghost = 0; nrghost<3; ++nrghost){
     123        bcolli = collis(ghosts[nrghost]->getPosition(), currentPosition);
     124        if(bcolli) ghosts[nrghost]->resetGhost();
     125        bcolli = false;
     126        }
     127      }
     128    }
     129
     130    void setAfraid(){
     131        afraid = true;
    111132    }
    112133
  • code/branches/3DPacman_FS18/src/modules/pacman/Pacman.h

    r11931 r11933  
    3939#include "PacmanGhost.h"
    4040#include "PacmanPointSphere.h"
     41#include "PacmanPointAfraid.h"
    4142#include "Highscore.h"
    4243//#include "PlayerInfo.h"
     
    9596            int totallevelpoint = 3;
    9697            //bool firstGame;
     98            bool afraid = false;
     99            float timer = 0;
    97100           
    98101       private:
  • code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.cc

    r11931 r11933  
    417417
    418418    void PacmanGhost::move(float dt, Vector3 actuelposition, Vector3 velocity){
    419         this->setPosition(Vector3(actuelposition.x+20*velocity.x*dt,10,actuelposition.z+20*velocity.z*dt));
     419        if(!dontmove)
     420            this->setPosition(Vector3(actuelposition.x+20*velocity.x*dt,10,actuelposition.z+20*velocity.z*dt));
    420421    }
    421422
     
    423424       if((abs(one.x - other.x)<0.5) && (abs(one.z - other.z)<0.5)) return true;
    424425        return false;
     426    }
     427
     428    void changemovability(){
     429        if(dontmove){
     430         dontmove = false;}
     431        else{
     432         dontmove = true;   
     433        }
    425434    }
    426435
  • code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.h

    r11931 r11933  
    5858
    5959            bool findpos(Vector3 one, Vector3 other);     
    60 
     60            void changemovability();
    6161
    6262        private:
     63            bool dontmove = false;
    6364            bool ismoving = false;
    6465            int decision = 0; //Gives the random which way information to the ghost.
Note: See TracChangeset for help on using the changeset viewer.