Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11915


Ignore:
Timestamp:
Apr 26, 2018, 4:11:19 PM (6 years ago)
Author:
dreherm
Message:

Game playable

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

Legend:

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

    r11898 r11915  
    1616?>
    1717
    18 <Level>
     18<Level
     19  plugins = pacman
     20  gametype = Pacman
     21>
    1922
    2023  <templates>
     
    3134    <SpawnPoint team=0 position="0,10,245" lookat="0,0,0" spawnclass=PacmanGelb pawndesign=PacmanGelb />
    3235
    33 <PacmanGhost position="215,10,245" resetposition="215,10,220">
     36
     37<PacmanGhost position="135,10,15" resetposition="135,10,15">
    3438    <attached>
    3539        <Model position="0,0,0" mesh="PacmanGhostRed.mesh" scale="5" />
     
    3741</PacmanGhost>
    3842
    39 <PacmanGhost position="215,10,245" resetposition="215,10,220">
     43<PacmanGhost position="135,10,15" resetposition="135,10,15">
    4044    <attached>
    4145        <Model position="0,0,0" mesh="PacmanGhostBlue.mesh" scale="5" />
     
    4347</PacmanGhost>
    4448
    45 <PacmanGhost position="215,10,245" resetposition="215,10,220">
     49<PacmanGhost position="135,10,15" resetposition="135,10,15">
    4650    <attached>
    4751        <Model position="0,0,0" mesh="PacmanGhostOrange.mesh" scale="5" />
     
    4953</PacmanGhost>
    5054
    51 <PacmanGhost position="215,10,245" resetposition="215,10,220">
     55<PacmanGhost position="135,10,15" resetposition="135,10,15">
    5256    <attached>
    5357        <Model position="0,0,0" mesh="PacmanGhostPink.mesh" scale="5" />
     
    5559</PacmanGhost>
    5660
    57 <PacmanPointSphere position="0,10,0" resetposition="0,10,0">
     61<PacmanPointSphere position="0,10,0">
     62    <attached>
     63        <Model position="0,0,0" mesh="PacmanPointSphere.mesh" scale="5" />
     64    </attached>
     65</PacmanPointSphere>
     66
     67<PacmanPointSphere position="215,10,245">
     68    <attached>
     69        <Model position="0,0,0" mesh="PacmanPointSphere.mesh" scale="5" />
     70    </attached>
     71</PacmanPointSphere>
     72
     73<PacmanPointSphere position="215,10,195">
    5874    <attached>
    5975        <Model position="0,0,0" mesh="PacmanPointSphere.mesh" scale="5" />
  • code/branches/3DPacman_FS18/src/modules/pacman/CMakeLists.txt

    r11898 r11915  
    1 SET_SOURCE_FILES(PICKUP_SRC_FILES
    2  
     1SET_SOURCE_FILES(Pacman_SRC_FILES
    32  Pacman.cc
    43  PacmanGhost.cc
     
    76)
    87
    9 ORXONOX_ADD_LIBRARY(Pacman
    10   MODULE
     8ORXONOX_ADD_LIBRARY(pacman
     9  PLUGIN
    1110  FIND_HEADER_FILES
    1211  TOLUA_FILES
     
    1716    orxonox
    1817    objects
    19     pickup
    20   SOURCE_FILES ${PICKUP_SRC_FILES}
     18  SOURCE_FILES ${Pacman_SRC_FILES}
    2119)
  • code/branches/3DPacman_FS18/src/modules/pacman/Pacman.cc

    r11898 r11915  
    3838namespace orxonox
    3939{
    40     RegisterUnloadableClass(Pacman);
     40    RegisterClass(Pacman);
    4141
    4242    Pacman::Pacman(Context* context) : Deathmatch(context)
     
    4444        RegisterObject(Pacman);
    4545
    46         lives = 3;
     46        lives = 10;
    4747        point = 0;
    4848        level = 1;
     
    5757
    5858    PacmanGhost* ghosts[4];
    59     PacmanPointSphere* spheres[1];
    6059
    6160
    6261    void Pacman::tick(float dt)
    6362    {
     63        SUPER(Pacman, tick, dt);
     64
    6465        int i = 0;
    6566        for(PacmanGhost* nextghost : ObjectList<PacmanGhost>()){
     
    7475        }
    7576
     77
    7678        bcolli = false;
    7779        for(int nrghost = 0; (nrghost<3) && (!bcolli); ++nrghost){
    7880            bcolli = collis(ghosts[nrghost]->getPosition(), currentPosition);
     81            //orxout() << "GHOST" << nrghost << ghosts[nrghost]->getPosition() << endl;
    7982        }
     83
    8084        if(bcolli){
    81             this->catched();
     85          this->catched();
    8286        }
    8387
     
    8993        }
    9094
    91         SUPER(Pacman, tick, dt);
    92 
    9395    }
    9496
    9597
    9698    bool Pacman::collis(Vector3 one, Vector3 other){
    97         if((abs(one.x-other.x)<0.1) && (abs(one.x-other.x)<0.1) && (abs(one.x-other.x)<0.1))
     99        if((abs(one.x-other.x)<7) && (abs(one.y-other.y)<7) && (abs(one.z-other.z)<7))
    98100            return true;
    99101        return false;
     
    107109
    108110    void Pacman::posreset(){
    109         int i = 0;
    110111        for(PacmanGhost* nextghost : ObjectList<PacmanGhost>()){
    111112            nextghost->resetGhost();
    112             i++;
    113113        }
    114114        player->setPosition(startposplayer);
     
    118118        ++point;
    119119        if(point == totallevelpoint) this->levelUp();
    120 
    121120        Vector3 postaken = taken->getPosition();
    122121        postaken.y = -50;
     
    141140    void Pacman::start()
    142141    {
    143         orxout() << "start" << endl;
    144        
    145142        Deathmatch::start();
    146     }
    147 
    148     void Pacman::playerPreSpawn(PlayerInfo* player)
    149     {
    150         //PlayerInfo* playerInfo_;
    151         //this->playerInfo_ = player;
    152         if(lives <= 0)
    153         {
    154             this->end();
    155         }
    156143    }
    157144
  • code/branches/3DPacman_FS18/src/modules/pacman/Pacman.h

    r11898 r11915  
    7272            virtual void tick(float dt) override;
    7373
    74             virtual void playerPreSpawn(PlayerInfo* player) override;
    75 
    7674            void levelUp();
    7775            bool collis(Vector3 one, Vector3 other);
     
    9593            bool bcolli = false;
    9694            Vector3 startposplayer = Vector3(0,10,245);
    97             int totallevelpoint = 1;
     95            int totallevelpoint = 3;
    9896           
    9997       private:
  • code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.cc

    r11904 r11915  
    5050        this->setCollisionType(CollisionType::Dynamic);
    5151
    52         this->resetposition = Vector3(0,20,245); //Set Default start position
     52        this->resetposition = this->getPosition(); //Set Default start position
    5353       
    5454        this->actuelposition = this->getPosition();
     
    8181
    8282   
    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)};
     83    Vector3 possibleposition[] = {Vector3(20,10,245),Vector3(215,10,245),Vector3(215,10,195),Vector3(185,10,195),Vector3(135,10,195), //0-4
     84        Vector3(185,10,150),Vector3(135,10,150),Vector3(215,10,150),Vector3(215,10,105),Vector3(135,10,105), //5-9
     85        Vector3(135,10,15),Vector3(135,10,-85),Vector3(215,10,-85),Vector3(135,10,-135),Vector3(215,10,-135), //10-14
     86        Vector3(215,10,-195),Vector3(135,10,-195),Vector3(20,10,195),Vector3(-20,10,195),Vector3(-20,10,245), //15-19
     87        Vector3(-215,10,245),Vector3(-215,10,195),Vector3(-185,10,195),Vector3(-135,10,195),Vector3(-70,10,195), //20-24
     88        Vector3(70,10,195),Vector3(70,10,150),Vector3(20,10,150),Vector3(-20,10,150),Vector3(-70,10,150), //25-29
     89        Vector3(-135,10,150),Vector3(-185,10,150),Vector3(-215,10,150),Vector3(-215,10,105),Vector3(-135,10,105) //30-34
     90    };
    8591
    8692    /**
     
    99105       
    100106        //Stop, if target arrived
    101         if((abs(this->actuelposition.x - this->target_x)<0.1) && (abs(this->actuelposition.z - this->target_z)<0.1)){
     107        if((abs(this->actuelposition.x - this->target_x)<0.5) && (abs(this->actuelposition.z - this->target_z)<0.5)){
    102108                 this->ismoving = false;
    103109        }
     
    105111        //Move, if ghost hasn't arrived yet
    106112        if(this->ismoving){
    107             if(!(abs(this->actuelposition.z-target_z)<0.1)) {
    108                 velocity = Vector3(0,0,-sgn(this->actuelposition.z-this->target_z));
     113            if(!(abs(this->actuelposition.z-target_z)<0.5)) {
     114                velocity = Vector3(0,0,-sgn(this->actuelposition.z-this->target_z)*2);
    109115                move(dt, actuelposition, velocity);
    110116            }   
    111             if(!(abs(this->actuelposition.x-target_x)<0.1)){
    112                 velocity = Vector3(-sgn(this->actuelposition.x-this->target_x),0,0);
     117            if(!(abs(this->actuelposition.x-target_x)<0.5)){
     118                velocity = Vector3(-sgn(this->actuelposition.x-this->target_x)*2,0,0);
    113119                move(dt, actuelposition, velocity);
    114120            }
     
    118124         else{
    119125            if(findpos(actuelposition,possibleposition[0])){
    120                 setnewTarget(1);
     126                setnewTarget(1,17,19);
    121127            }
    122128            else if(findpos(actuelposition,possibleposition[1])){
     
    136142            }
    137143            else if(findpos(actuelposition,possibleposition[6])){
    138                 setnewTarget(4);
     144                setnewTarget(4,9,26);
    139145            }
    140146            else if(findpos(actuelposition,possibleposition[7])){
    141                 setnewTarget(5);
     147                setnewTarget(5,8);
     148            }
     149            else if(findpos(actuelposition,possibleposition[8])){
     150                setnewTarget(7,9);
     151            }
     152            else if(findpos(actuelposition,possibleposition[9])){
     153                setnewTarget(6,8,10); //38
     154            }
     155            else if(findpos(actuelposition,possibleposition[10])){
     156                setnewTarget(9,11); //45,9
     157            }
     158            else if(findpos(actuelposition,possibleposition[11])){
     159                setnewTarget(10,12,13);
     160            }
     161            else if(findpos(actuelposition,possibleposition[12])){
     162                setnewTarget(11,14);
     163            }
     164            else if(findpos(actuelposition,possibleposition[13])){
     165                setnewTarget(11,14,16); //61
     166            }
     167            else if(findpos(actuelposition,possibleposition[14])){
     168                setnewTarget(12,13,15);
     169            }
     170            else if(findpos(actuelposition,possibleposition[15])){
     171                setnewTarget(14,16);
     172            }
     173            else if(findpos(actuelposition,possibleposition[16])){
     174                setnewTarget(13,15); //62
     175            }
     176            else if(findpos(actuelposition,possibleposition[17])){
     177                setnewTarget(0,25);
     178            }
     179            else if(findpos(actuelposition,possibleposition[18])){
     180                setnewTarget(19,24);
     181            }
     182            else if(findpos(actuelposition,possibleposition[19])){
     183                setnewTarget(0,18,20);
     184            }
     185            else if(findpos(actuelposition,possibleposition[20])){
     186                setnewTarget(19,21);
     187            }
     188            else if(findpos(actuelposition,possibleposition[21])){
     189                setnewTarget(20,22);
     190            }
     191            else if(findpos(actuelposition,possibleposition[22])){
     192                setnewTarget(21,23,31);
     193            }
     194            else if(findpos(actuelposition,possibleposition[23])){
     195                setnewTarget(22,30);
     196            }
     197            else if(findpos(actuelposition,possibleposition[24])){
     198                setnewTarget(18,29);
     199            }
     200            else if(findpos(actuelposition,possibleposition[25])){
     201                setnewTarget(17,26);
     202            }
     203            else if(findpos(actuelposition,possibleposition[26])){
     204                setnewTarget(6,25,27);
     205            }
     206            else if(findpos(actuelposition,possibleposition[27])){
     207                setnewTarget(26,28);//37
     208            }
     209            else if(findpos(actuelposition,possibleposition[28])){
     210                setnewTarget(27,29); //36
     211            }
     212            else if(findpos(actuelposition,possibleposition[29])){
     213                setnewTarget(24,28,30);
     214            }
     215            else if(findpos(actuelposition,possibleposition[30])){
     216                setnewTarget(23,29,34);
     217            }
     218            else if(findpos(actuelposition,possibleposition[31])){
     219                setnewTarget(22,32);
     220            }
     221            else if(findpos(actuelposition,possibleposition[32])){
     222                setnewTarget(31,33);
     223            }
     224            else if(findpos(actuelposition,possibleposition[33])){
     225                setnewTarget(32,34);
     226            }
     227            else if(findpos(actuelposition,possibleposition[34])){
     228                setnewTarget(30,33);//35,42
    142229            }
    143230
     
    230317
    231318    bool PacmanGhost::findpos(Vector3 one, Vector3 other){
    232         if((abs(one.x - other.x)<0.1) && (abs(one.z - other.z)<0.1)) return true;
     319        if((abs(one.x - other.x)<0.5) && (abs(one.z - other.z)<0.5)) return true;
    233320        return false;
    234321    }
    235322
    236323    void PacmanGhost::resetGhost(){
    237         this->setPosition(resetposition);
     324        this->setPosition(this->resetposition);
     325        this->ismoving = false;
     326        this->actuelposition = this->getPosition();
     327       
     328        this->target_x = actuelposition.x;
     329        this->target_z = actuelposition.z;
    238330    }
    239331}
    240 
    241 /*
    242 //Check on which position ghost has arrived and set new target
    243          else{
    244             if(findpos(actuelposition,possibleposition[0])){
    245                 decision = rand()%1;
    246             switch(decision){
    247                 case 0:
    248                     this->target_x = possibleposition[1].x;
    249                     this->target_z = possibleposition[1].z;
    250                     this->ismoving = true;
    251                     break;
    252             }
    253            
    254             }
    255             else if(findpos(actuelposition,possibleposition[1])){
    256                 decision = rand()%2;
    257             switch(decision){
    258                 case 0:
    259                     this->target_x = possibleposition[0].x;
    260                     this->target_z = possibleposition[0].z;
    261                     this->ismoving = true;
    262                     break;
    263                 case 1:
    264                     this->target_x = possibleposition[2].x;
    265                     this->target_z = possibleposition[2].z;
    266                     this->ismoving = true;
    267                     break;   
    268             }
    269 
    270             }
    271             else if(findpos(actuelposition,possibleposition[2])){
    272                 decision = rand()%2;
    273             switch(decision){
    274                 case 0:
    275                     this->target_x = possibleposition[1].x;
    276                     this->target_z = possibleposition[1].z;
    277                     this->ismoving = true;
    278                     break;
    279                 case 1:
    280                     this->target_x = possibleposition[3].x;
    281                     this->target_z = possibleposition[3].z;
    282                     this->ismoving = true;
    283                     break;
    284             }
    285            
    286             }
    287 
    288             else if(findpos(actuelposition,possibleposition[3])){
    289                 decision = rand()%3;
    290             switch(decision){
    291                 case 0:
    292                     this->target_x = possibleposition[2].x;
    293                     this->target_z = possibleposition[2].z;
    294                     this->ismoving = true;
    295                     break;
    296                 case 1:
    297                     this->target_x = possibleposition[4].x;
    298                     this->target_z = possibleposition[4].z;
    299                     this->ismoving = true;
    300                     break;
    301                 case 2:
    302                     this->target_x = possibleposition[5].x;
    303                     this->target_z = possibleposition[5].z;
    304                     this->ismoving = true;
    305                     break;       
    306             }
    307             }
    308 
    309             else if(findpos(actuelposition,possibleposition[4])){
    310                 decision = rand()%2;
    311             switch(decision){
    312                 case 0:
    313                     this->target_x = possibleposition[3].x;
    314                     this->target_z = possibleposition[3].z;
    315                     this->ismoving = true;
    316                     break;
    317                 case 1:
    318                     this->target_x = possibleposition[6].x;
    319                     this->target_z = possibleposition[6].z;
    320                     this->ismoving = true;
    321                     break;
    322             }
    323             }
    324 
    325             else if(findpos(actuelposition,possibleposition[5])){
    326                 decision = rand()%2;
    327             switch(decision){
    328                 case 0:
    329                     this->target_x = possibleposition[3].x;
    330                     this->target_z = possibleposition[3].z;
    331                     this->ismoving = true;
    332                     break;
    333                 case 1:
    334                     this->target_x = possibleposition[7].x;
    335                     this->target_z = possibleposition[7].z;
    336                     this->ismoving = true;
    337                     break;
    338             }
    339             }
    340 
    341             else if(findpos(actuelposition,possibleposition[6])){
    342                 decision = rand()%1;
    343             switch(decision){
    344                 case 0:
    345                     this->target_x = possibleposition[4].x;
    346                     this->target_z = possibleposition[4].z;
    347                     this->ismoving = true;
    348                     break;
    349             }
    350             }
    351 
    352             else if(findpos(actuelposition,possibleposition[7])){
    353                 decision = rand()%1;
    354             switch(decision){
    355                 case 0:
    356                     this->target_x = possibleposition[5].x;
    357                     this->target_z = possibleposition[5].z;
    358                     this->ismoving = true;
    359                     break;
    360             }
    361             }
    362 
    363 
    364             else{
    365             } //End of Position table
    366             */
  • code/branches/3DPacman_FS18/src/modules/pacman/PacmanPointSphere.cc

    r11898 r11915  
    6464    {
    6565        SUPER(PacmanPointSphere, XMLPort, xmlelement, mode);
    66 
    67         XMLPortParam(PacmanPointSphere, "resetposition", setResetPosition, getResetPosition, xmlelement, mode);
    6866    }
    6967
  • code/branches/3DPacman_FS18/src/modules/pacman/PacmanPointSphere.h

    r11898 r11915  
    4949            bool taken(Vector3 playerpos);
    5050            void resetPacmanPointSphere();
    51 
    52             inline void setResetPosition(Vector3 rpos)
    53                 { this->resetposition = rpos; }   
    54            
    55             inline Vector3 getResetPosition()
    56                { return this->resetposition; }       
    57 
    5851        private:
    5952           
Note: See TracChangeset for help on using the changeset viewer.