Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 18, 2019, 3:00:44 PM (5 years ago)
Author:
ahuwyler
Message:

A Stone is in the game/ Templates are ajusted

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.cc

    r12305 r12307  
    6868        this->center_ = nullptr;
    6969        this->ball_ = nullptr;
    70         this->bat_[0] = nullptr;
    7170        this->futureWall_ = nullptr;
    72 
    73         //this->setHUDTemplate("pongHUD");
     71        this->player_ = nullptr;
     72       
     73
     74        this->setHUDTemplate("OrxoBloxHUD");
    7475        //Error when specified
    7576
     
    7879        this->starttimer_.stopTimer();
    7980
    80         // Set the type of Bots for this particular Gametype.
    81         this->botclass_ = Class(OrxoBloxBat);
    82 
    83         this->scoreLimit_ = 10;
    84         this->setConfigValues();
     81       
     82
    8583    }
    8684
     
    9593    }
    9694
    97     void OrxoBlox::setConfigValues()
    98     {
    99         SetConfigValue(scoreLimit_, 10).description("The player first reaching those points wins.");
    100     }
    101 
    10295    /**
    10396    @brief
     
    112105        }
    113106
    114         // Destroy both bats, if present.
    115         for (size_t i = 0; i < 2; ++i)
    116         {
    117             if (this->bat_[0] != nullptr)
    118             {
    119                 this->bat_[0]->destroy();
    120                 this->bat_[0] = nullptr;
    121             }
    122         }
    123 
    124     }
    125 
    126     /**
    127     @brief
     107        if (this->futureWall_)
     108            {
     109                this->futureWall_->destroy();
     110                this->futureWall_ = nullptr;
     111            }
     112
     113        // Destroy 6 bWalls, if present.
     114        for (size_t i = 0; i < 6; ++i)
     115        {
     116            if (this->activeWalls_[0] != nullptr)
     117            {
     118                this->activeWalls_[0]->destroy();
     119                this->activeWalls_[0] = nullptr;
     120            }
     121           
     122        }
     123
     124    }
     125
     126    /**
     127    @brieftt   
    128128        Starts the OrxoBlox minigame.
    129129    */
     
    141141            // Attach the ball to the centerpoint and set the parameters as specified in the centerpoint, the ball is attached to.
    142142            this->center_->attach(this->ball_);
    143             this->ball_->setPosition(0,0,50); //Startposition
     143            this->ball_->setPosition(0, 0, 50);
    144144            this->ball_->setFieldDimension(this->center_->getFieldDimension());
    145145            this->ball_->setSpeed(0);
    146146            this->ball_->setAccelerationFactor(this->center_->getBallAccelerationFactor());
    147147            this->ball_->setBatLength(this->center_->getBatLength());
     148
     149
     150
     151
    148152
    149153            // If one of the bats is missing, create it. Apply the template for the bats as specified in the centerpoint.
     
    157161            }
    158162
    159             // Attach the bats to the centerpoint and set the parameters as specified in the centerpoint, the bats are attached to.
    160             this->center_->attach(this->bat_[0]);
    161             this->center_->attach(this->bat_[1]);
    162             this->bat_[0]->setPosition(-this->center_->getFieldDimension().x / 2, 0, 0);
    163             this->bat_[0]->yaw(Degree(-90));
    164             this->bat_[0]->setSpeed(this->center_->getBatSpeed());
    165             this->bat_[0]->setFieldHeight(this->center_->getFieldDimension().y);
    166             this->bat_[0]->setLength(this->center_->getBatLength());
    167 
    168             // Set the bats for the ball.
    169             this->ball_->setBats(this->bat_);
     163
     164            // Create the first Wall.
     165            this->createWall();
     166            orxout()<< "helloo"<< endl;
     167
    170168        }
    171169        else // If no centerpoint was specified, an error is thrown and the level is exited.
     
    188186        // Reset the variable.
    189187        this->bForceSpawn_ = temp;
    190 
    191188    }
    192189
     
    220217    }
    221218
     219
    222220    /**
    223221    @brief
     
    228226    void OrxoBlox::spawnPlayer(PlayerInfo* player)
    229227    {
    230         assert(player);
    231 
    232         // If the first (left) bat has no player.
    233         if (this->bat_[0]->getPlayer() == nullptr)
    234         {
    235             player->startControl(this->bat_[0]);
     228         assert(player);
     229
     230        if(this->player_ == nullptr)
     231        {
     232            this->player_ = player;
    236233            this->players_[player].state_ = PlayerState::Alive;
    237234        }
    238         else
    239             return;
    240235    }
    241236
     
    244239        Is called when the player scored.
    245240    */
    246     void OrxoBlox::playerScored(PlayerInfo* player, int score)
    247     {
    248         Deathmatch::playerScored(player, score);
    249 
    250         if (this->center_ != nullptr) // If there is a centerpoint.
    251         {
    252             // Fire an event for the player that has scored, to be able to react to it in the level, e.g. by displaying fireworks.
    253            
    254             if (player == this->getLeftPlayer())
    255                 this->center_->fireEvent(FireEventName(OrxoBloxCenterpoint, left));
    256 
    257             // Also announce, that the player has scored.
    258             if (player != nullptr)
    259                 this->gtinfo_->sendAnnounceMessage(player->getName() + " scored");
    260         }
    261 
    262         // If there is a ball present, reset its position, velocity and acceleration.
    263         if (this->ball_ != nullptr)
    264         {
    265             this->ball_->setPosition(Vector3::ZERO);
    266             this->ball_->setVelocity(Vector3::ZERO);
    267             this->ball_->setAcceleration(Vector3::ZERO);
    268             this->ball_->setSpeed(0);
    269         }
    270 
    271         // If there are bats reset them to the middle position.
    272         if (this->bat_[0] != nullptr && this->bat_[1] != nullptr)
    273         {
    274             this->bat_[0]->setPosition(-this->center_->getFieldDimension().x / 2, 0, 0);
    275            
    276         }
    277 
    278 
    279         // Restart the timer to start the ball.
    280         this->starttimer_.startTimer();
    281     }
    282 
    283     /*void OrxoBlox::createStonewall(void){
    284         this->futureWall_ = new OrxoBolxWall(this->center_->getContext());
    285     }
    286 
    287     /*void Tetris::createBrick(void)             //TODO: random rotation offset between 0 and 3 (times 90°)
    288     {
    289         // create new futureBrick_
    290         this->futureBrick_ = new TetrisBrick(this->center_->getContext());
    291 
    292 
     241   
     242    //void startWall(void);
     243   
     244
     245
     246    void OrxoBlox::createWall(void){
     247        this->futureWall_ = new OrxoBloxWall(this->center_->getContext());
    293248        // Apply the stone template to the stone.
    294         this->futureBrick_->addTemplate(this->center_->getBrickTemplate());
     249        this->futureWall_->addTemplate(this->center_->getWallTemplate());
    295250
    296251        // Attach the brick to the Centerpoint and set the position of the brick to be at the left side.
    297         this->center_->attach(this->futureBrick_);
    298         float xPos = (this->center_->getWidth()*1.6f + ((this->center_->getWidth() % 2)*2-1)/2.0f)*this->center_->getStoneSize();
    299         float yPos = (this->center_->getHeight()-5.1f)*this->center_->getStoneSize();
    300        
    301         this->futureBrick_->setPosition(xPos, yPos, 0.0f);
    302         this->futureBrick_->setGame(this);
    303     }
    304 
    305     }*/
     252        this->center_->attach(this->futureWall_);
     253       
     254       
     255        this->futureWall_->setPosition(10, 10, 0.0f);
     256        this->futureWall_->setGame(this);
     257    }
     258
     259    // void OrxoBlox::createWall(void)             //TODO: random rotation offset between 0 and 3 (times 90°)
     260    // {
     261    //     // create new futureBrick_
     262    //     this->futureWall_ = new TetrisBrick(this->center_->getContext());
     263
     264
     265    //     // Apply the stone template to the stone.
     266    //     this->futureBrick_->addTemplate(this->center_->getBrickTemplate());
     267
     268    //     // Attach the brick to the Centerpoint and set the position of the brick to be at the left side.
     269    //     this->center_->attach(this->futureBrick_);
     270    //     float xPos = (this->center_->getWidth()*1.6f + ((this->center_->getWidth() % 2)*2-1)/2.0f)*this->center_->getStoneSize();
     271    //     float yPos = (this->center_->getHeight()-5.1f)*this->center_->getStoneSize();
     272       
     273    //     this->futureBrick_->setPosition(xPos, yPos, 0.0f);
     274    //     this->futureBrick_->setGame(this);
     275    // }
    306276
    307277    /**
     
    315285    }
    316286
    317     /**
    318     @brief
    319         Get the left player.
    320     @return
    321         Returns a pointer to the player playing on the left. If there is no left player, nullptr is returned.
    322     */
    323     PlayerInfo* OrxoBlox::getLeftPlayer() const
    324     {
    325         if (this->bat_[0] != nullptr)
    326             return this->bat_[0]->getPlayer();
    327         else
    328             return nullptr;
    329     }
    330 
     287   
    331288   
    332289}
Note: See TracChangeset for help on using the changeset viewer.