Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 29, 2014, 1:21:53 PM (10 years ago)
Author:
richtero
Message:

CMakeList added

Location:
code/branches/minigame4DHS14
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/minigame4DHS14/data/levels/4Dtest.oxw

    r10096 r10100  
    6060    </Mini4DgameCenterpoint>
    6161
    62 
    63         <!-- Blinking Slot Selector -->
     62        <!-- Blinking Slot Selector
    6463        <BlinkingBillboard position="0,0,0" frequency=0.6 amplitude=0.4 material="Flares/lensflare" colour="1,1,0.05">
    6564          <events>
     
    7574          </events>
    7675        </BlinkingBillboard>
    77 
     76        -->
    7877    <!-- Planet in the middle
    7978    <Planet
  • code/branches/minigame4DHS14/src/modules/mini4Dgame/Mini4Dgame.cc

    r10097 r10100  
    6262        RegisterObject(Mini4Dgame);
    6363
    64         this->center_ = 0;
    65         this->player_[0] = NULL;
    66         this->player_[1] = NULL;
     64        this->center_ = NULL;
     65        //TODO: player Null setzen
    6766    }
    6867
     
    134133    }
    135134
    136 ---------------------------------------------------------------------------------------------------------------------------------
    137135
    138136    /**
     
    142140    void Mini4Dgame::spawnPlayersIfRequested()
    143141    {
    144         // Spawn a human player.
     142        // first spawn human players to assign always the left bat to the player in singleplayer
    145143        for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
    146144            if (it->first->isHumanPlayer() && (it->first->isReadyToSpawn() || this->bForceSpawn_))
    147145                this->spawnPlayer(it->first);
    148     }
    149    
    150     bool Tetris::playerLeft(PlayerInfo* player)
    151     {
    152         bool left = Gametype::playerLeft(player);
    153         if(player && player->isHumanPlayer())
    154         {
    155             if(this->activeBrick_ != NULL)
    156             {
    157                 this->player_->stopControl();
    158             }
    159             this->cleanup();
    160         }
    161         return left;
     146        // now spawn bots
     147        for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
     148            if (!it->first->isHumanPlayer() && (it->first->isReadyToSpawn() || this->bForceSpawn_))
     149                this->spawnPlayer(it->first);
    162150    }
    163151
     
    168156        The player to be spawned.
    169157    */
    170     void Tetris::spawnPlayer(PlayerInfo* player)
     158    void Mini4Dgame::spawnPlayer(PlayerInfo* player)
    171159    {
    172160        assert(player);
    173161
    174         if(this->player_ == NULL)
     162        if(false)//this->player_ == NULL)
    175163        {
    176             this->player_ = player;
     164            //this->player_ = player;
    177165            this->players_[player].state_ = PlayerState::Alive;
    178166        }
    179     }
    180 
    181 
    182 
    183     void Tetris::startBrick(void)
    184     {
    185         if(this->player_ == NULL)
    186             return;
    187 
    188         unsigned int cameraIndex = 0;
    189         if(this->activeBrick_ != NULL)
    190         {
    191             // Get camera settings
    192             cameraIndex = this->activeBrick_->getCurrentCameraIndex();
    193             this->player_->stopControl();
    194             // destroy old active brick
    195             this->activeBrick_->destroy();
    196         }
    197 
    198         // Make the last brick to be created the active brick.
    199         this->activeBrick_ = this->futureBrick_;
    200         this->futureBrick_ = 0;
    201 
    202         // set its position
    203         this->player_->startControl(this->activeBrick_);
    204         float xPos = (this->center_->getWidth()/2 + ((this->center_->getWidth() % 2)*2-1)/2.0f)*this->center_->getStoneSize();
    205         float yPos = (this->center_->getHeight()-0.5f)*this->center_->getStoneSize();
    206         this->activeBrick_->setPosition(xPos, yPos, 0.0f);
    207         this->activeBrick_->setVelocity(0.0f, -this->center_->getStoneSpeed(), 0.0f);
    208         this->activeBrick_->setCameraPosition(cameraIndex);
    209 
    210         // create a new future brick
    211         this->createBrick();
    212 
    213         // check if the new brick is in a valid position, otherwise end the game
    214         if (!this->isValidBrickPosition(this->activeBrick_))
    215             this->end();
    216     }
    217 
    218     void Tetris::createBrick(void)             //TODO: random rotation offset between 0 and 3 (times 90°)
    219     {
    220         // create new futureBrick_
    221         this->futureBrick_ = new TetrisBrick(this->center_->getContext());
    222 
    223 
    224         // Apply the stone template to the stone.
    225         this->futureBrick_->addTemplate(this->center_->getBrickTemplate());
    226 
    227         // Attach the brick to the Centerpoint and set the position of the brick to be at the left side.
    228         this->center_->attach(this->futureBrick_);
    229         float xPos = (this->center_->getWidth()*1.6f + ((this->center_->getWidth() % 2)*2-1)/2.0f)*this->center_->getStoneSize();
    230         float yPos = (this->center_->getHeight()-5.1f)*this->center_->getStoneSize();
    231        
    232         this->futureBrick_->setPosition(xPos, yPos, 0.0f);
    233         this->futureBrick_->setGame(this);
    234167    }
    235168
     
    241174        Returns a pointer to the player. If there is no player, NULL is returned.
    242175    */
    243     PlayerInfo* Tetris::getPlayer(void) const
     176    //TODO: colors
     177    PlayerInfo* Mini4Dgame::getPlayer(int color) const
    244178    {
    245         return this->player_;
     179        return players[color];
     180        //for(int i=0;i<NUMBEROFPLAYERS;i++)
     181                //if(color == this->mini4DgamePlayers[i].color)
     182                        //return this->mini4DgamePlayers[i].info;
    246183    }
    247184
    248     /*TetrisCenterpoint* Tetris::getCenterpoint(void) const
    249     {
    250         return this->center_;
    251     }*/
    252 
    253     /**
    254     @brief Set the TetrisCenterpoint (the playing field).
    255     @param center A pointer to the TetrisCenterpoint to be set.
    256     */
    257     void Tetris::setCenterpoint(TetrisCenterpoint* center)
    258     {
    259         this->center_ = center;
    260     }
    261 
    262     /**
    263     @brief Check each row if it is full. Removes all full rows. Update
    264     @brief Manages score.
    265     */
    266     void Tetris::findFullRows()
    267     {
    268         unsigned int correctPosition = 0;
    269         unsigned int stonesPerRow = 0;
    270         for (unsigned int row = 0; row < this->center_->getHeight(); row++)
    271         {
    272             stonesPerRow = 0;
    273             for(std::list<SmartPtr<TetrisStone> >::iterator it = this->stones_.begin(); it != this->stones_.end(); )
    274             {
    275                 std::list<SmartPtr<TetrisStone> >::iterator it_temp = it++;
    276                 correctPosition = static_cast<unsigned int>(((*it_temp)->getPosition().y - 5)/this->center_->getStoneSize());
    277                 if(correctPosition == row)
    278                 {
    279                     stonesPerRow++;
    280                     if(stonesPerRow == this->center_->getWidth())
    281                     {
    282                         clearRow(row);
    283                         row--; //the row counter has to be decreased in order to detect multiple rows!
    284                         this->playerScored(this->player_);// add points
    285                         //increase the stone's speed
    286                         this->center_->setStoneSpeed(this->center_->getStoneSpeed()+1.0f);
    287                     }
    288                 }
    289             }
    290         }
    291     }
    292 
    293     void Tetris::clearRow(unsigned int row)
    294     {// clear the full row
    295         for(std::list<SmartPtr<TetrisStone> >::iterator it = this->stones_.begin(); it != this->stones_.end(); )
    296         {
    297             if(static_cast<unsigned int>(((*it)->getPosition().y - 5)/this->center_->getStoneSize()) == row)
    298             {
    299                 (*it)->destroy();
    300                 this->stones_.erase(it++);
    301             }
    302             else
    303                 ++it;
    304         }
    305       // adjust height of stones above the deleted row //TODO: check if this could be a source of a bug.
    306         for(std::list<SmartPtr<TetrisStone> >::iterator it = this->stones_.begin(); it != this->stones_.end(); ++it)
    307         {
    308             if(static_cast<unsigned int>(((*it)->getPosition().y - 5)/this->center_->getStoneSize()) > row)
    309                 (*it)->setPosition((*it)->getPosition()-Vector3(0,10,0));
    310         }
    311 
    312     }
    313 
    314 
    315185}
  • code/branches/minigame4DHS14/src/modules/mini4Dgame/Mini4Dgame.h

    r10097 r10100  
    3939namespace orxonox
    4040{
    41 
    4241    /**
    4342    @brief
     
    5655
    5756            virtual void spawnPlayer(PlayerInfo* player); //!< Spawns the input player.
    58             virtual bool playerLeft(PlayerInfo* player);
    5957
    6058            void setCenterpoint(Mini4DgameCenterpoint* center)
    6159                { this->center_ = center; }
    6260
    63             PlayerInfo* getLeftPlayer() const; //!< Get the left player.
    64             PlayerInfo* getRightPlayer() const; //!< Get the right player.
     61//TODO: enum colors
     62            PlayerInfo* getPlayer(int color) const; //!< Get the player with the specified color.
    6563
    6664
     
    7472            void cleanup(void); //!< Cleans up the Gametype by destroying the ball and the bats.
    7573
    76             PlayerInfo* player_[2];//!< The two players
     74          PlayerInfo* players[3];
    7775
    7876            WeakPtr<Mini4DgameCenterpoint> center_; //!< The playing field.
Note: See TracChangeset for help on using the changeset viewer.