Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

A Stone is in the game/ Templates are ajusted

Location:
code/branches/OrxoBlox_FS19
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • code/branches/OrxoBlox_FS19/data/levels/orxoblox.oxw

    r12305 r12307  
    5151</Template>
    5252
     53
     54
     55<Template name=OrxoBloxStonescameras defaults=0>
     56  <OrxoBloxStones>
     57    <camerapositions>
     58      <CameraPosition position="55,75,200" absolute=true />
     59    </camerapositions>
     60  </OrxoBloxStones>
     61</Template>
     62
     63<Template name=OrxoBloxstone>
     64  <OrxoBloxStones camerapositiontemplate=OrxoBloxStonescameras >
     65    <attached>
     66      <Model position="0,0,0" mesh="CuboidBody.mesh" scale=4.5 />
     67      <Model position="0,0,0" mesh="cube_orange.mesh" scale=4.3 />
     68    </attached>
     69  </OrxoBloxStones>
     70</Template>
     71
     72<Template name=OrxoBloxWallcameras defaults=0>
     73  <OrxoBloxWall>
     74    <camerapositions>
     75      <CameraPosition position="55,75,200" absolute=true />
     76      <!--CameraPosition position="0,50,160" drag=true mouselook=true />
     77      <CameraPosition position="0,50,0" pitch=-90 drag=true mouselook=true /-->
     78    </camerapositions>
     79  </OrxoBloxWall>
     80</Template>
     81
     82<Template name=OrxoBloxwall>
     83  <OrxoBloxWall camerapositiontemplate=OrxoBloxWallcameras>
     84  </OrxoBloxWall>
     85</Template>
     86
     87
     88
    5389<Level
    5490  plugins = "OrxoBlox"
     
    74110    <MovableEntity rotationrate=5 rotationaxis="0,0,1">
    75111      <attached>
    76         <OrxoBloxCenterpoint name=OrxoBloxcenter dimension="120,100" balltemplate=OrxoBloxball battemplate=OrxoBloxbat ballspeed=200 ballaccfactor=1.0 batspeed=130 batlength=0.25>
     112        <OrxoBloxCenterpoint name=OrxoBloxcenter dimension="120,100" balltemplate=OrxoBloxball battemplate=OrxoBloxbat ballspeed=200 ballaccfactor=1.0 batspeed=130 batlength=0.25 StoneTemplate=OrxoBloxstone WallTemplate=OrxoBloxwall>
    77113          <attached>
    78114            <!-- Balken die das Spielfeld begrenzen. -->
  • 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}
  • code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.h

    r12288 r12307  
    7474            virtual void spawnPlayer(PlayerInfo* player) override; //!< Spawns the input player.
    7575
    76             virtual void playerScored(PlayerInfo* player, int score = 1) override; //!< Is called when the player scored.
     76           
    7777
    7878            /**
     
    8282            void setCenterpoint(OrxoBloxCenterpoint* center)
    8383                { this->center_ = center; }
    84             void setConfigValues(); //!< Makes scoreLimit configurable.
    8584
    86             PlayerInfo* getLeftPlayer() const; //!< Get the left player.
     85            OrxoBloxCenterpoint* getCenterpoint(void)
     86                { return this->center_; }
    8787
    8888        protected:
    8989            virtual void spawnPlayersIfRequested() override; //!< Spawns players, and fills the rest up with bots.
    90 
     90        private:
     91            void startWall(void);
     92            void createWall(void);
    9193            void startBall(); //!< Starts the ball with some default speed.
    9294            void cleanup(); //!< Cleans up the Gametype by destroying the ball and the bats.
     
    9496            WeakPtr<OrxoBloxCenterpoint> center_; //!< The playing field.
    9597            WeakPtr<OrxoBloxBall> ball_; //!< The OrxoBlox ball.
    96             WeakPtr<OrxoBloxBat> bat_[1]; //!< The two bats.
     98            WeakPtr<OrxoBloxBat> bat_[0]; //!< The two bats.
     99            PlayerInfo* player_;
     100
    97101            Timer starttimer_; //!< A timer to delay the start of the game.
    98             int scoreLimit_; //!< If a player scored that much points, the game is ended.
     102           
    99103            WeakPtr<OrxoBloxWall> futureWall_;
     104            WeakPtr<OrxoBloxWall> activeWalls_[6]; //6 is the number of wallls in the game.
    100105    };
    101106}
  • code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxCenterpoint.cc

    r12305 r12307  
    8080        XMLPortParam(OrxoBloxCenterpoint, "ballaccfactor", setBallAccelerationFactor, getBallAccelerationFactor, xmlelement, mode);
    8181        XMLPortParam(OrxoBloxCenterpoint, "batspeed", setBatSpeed, getBatSpeed, xmlelement, mode);
     82        XMLPortParam(OrxoBloxCenterpoint, "stoneTemplate", setStoneTemplate, getStoneTemplate, xmlelement, mode);
     83        XMLPortParam(OrxoBloxCenterpoint, "WallTemplate", setWallTemplate, getWallTemplate, xmlelement, mode);
    8284        XMLPortParam(OrxoBloxCenterpoint, "batlength", setBatLength, getBatLength, xmlelement, mode);
    8385    }
  • code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxCenterpoint.h

    r12266 r12307  
    217217                { return this->batlength_; }
    218218
     219            /**
     220            @brief Set the template for the stones.
     221            @param templateName The template name to be applied to each stone.
     222            */
     223            void setStoneTemplate(const std::string& templateName)
     224                { this->stoneTemplate_ = templateName; }
     225            /**
     226            @brief Get the template for the stones.
     227            @return Returns the template name to be applied to each stone.
     228            */
     229            const std::string& getStoneTemplate(void) const
     230                { return this->stoneTemplate_; }
     231           
     232
     233            /**
     234            @brief Set the template for the bricks.
     235            @param templateName The template name to be applied to each brick.
     236            */
     237            void setWallTemplate(const std::string& templateName)
     238                { this->WallTemplate_ = templateName; }
     239
     240            /**
     241            @brief Get the template for the bricks.
     242            @return Returns the template name to be applied to each brick.
     243            */
     244            const std::string& getWallTemplate(void) const
     245                { return this->WallTemplate_; }
     246
     247
    219248        private:
    220249            void checkGametype(); //!< Checks whether the gametype is OrxoBlox and if it is, sets its centerpoint.
     
    222251            std::string balltemplate_; //!< The template for the ball.
    223252            std::string battemplate_; //!< The template for the bats.
     253            std::string WallTemplate_;
     254            std::string stoneTemplate_;
    224255
    225256            float ballspeed_; //!< The speed of then ball.
     
    230261            float width_; //!< The height of the playing field.
    231262            float height_; //!< The width of the playing field.
     263
     264           
    232265    };
    233266}
  • code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxPrereqs.h

    r12212 r12307  
    7272    class OrxoBloxBall;
    7373    class OrxoBloxBat;
    74     class OrxoBloxBot;
    7574    class OrxoBloxCenterpoint;
    76     class OrxoBloxScore;
     75    class OrxoBloxWall;
     76    class OrxobloxStones;
    7777}
    7878
  • code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxStones.cc

    r12251 r12307  
    11#include "OrxoBloxStones.h"
     2
    23#include "core/CoreIncludes.h"
    34#include "core/XMLPort.h"
  • code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxStones.h

    r12251 r12307  
    4646                }
    4747
    48 
     48            void setGame(OrxoBlox* orxoblox)
     49                { assert(orxoblox); orxoblox_ = orxoblox; }
     50               
    4951        private:
    5052            float size_; //!< The dimensions a stone has in the game world.
     
    5254            bool delay_;
    5355           
     56            OrxoBlox* orxoblox_;
    5457           
    5558
  • code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxWall.cc

    r12278 r12307  
    1616        RegisterObject(OrxoBloxWall);
    1717
    18         this->health_ = 10;
     18        this->health_ = 1 + static_cast<unsigned int>(rnd(6.0f)); //<! random number between 0 and 7;
    1919        this->delay_ = false;
     20        this->orxoblox_ = this->getOrxoBlox();
     21
     22
     23        OrxoBloxStones* stone = new OrxoBloxStones(this->getContext());
     24        if(this->orxoblox_ != nullptr)
     25            {
     26                stone->setGame(this->orxoblox_);
     27                if(this->orxoblox_->getCenterpoint() != nullptr)
     28                    stone->addTemplate(this->orxoblox_->getCenterpoint()->getStoneTemplate());
     29                else
     30                    orxout()<< "tetris_->getCenterpoint == nullptr in TetrisBrick.cc"<< endl;
     31            }
     32            else
     33                orxout()<< "tetris_ == nullptr in TetrisBrick.cc"<< endl;
     34    }
     35
     36
     37    OrxoBlox* OrxoBloxWall::getOrxoBlox()
     38    {
     39        if (this->getGametype() != nullptr && this->getGametype()->isA(Class(OrxoBlox)))
     40        {
     41            OrxoBlox* orxobloxGametype = orxonox_cast<OrxoBlox*>(this->getGametype());
     42            return orxobloxGametype;
     43        }
     44        else orxout()<<"There is no Gametype! ask Anna"<< endl;
     45        return nullptr;
    2046    }
    2147}
  • code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxWall.h

    r12278 r12307  
    4545                //  else ~OrxoBloxStones();
    4646                }
    47 
    48 
     47            void setGame(OrxoBlox* orxoblox)
     48                { assert(orxoblox); orxoblox_ = orxoblox; }
    4949        private:
     50            OrxoBlox* getOrxoBlox();
    5051            unsigned int health_;
    5152            bool delay_;
    52            
     53            OrxoBlox* orxoblox_;
    5354           
    5455
Note: See TracChangeset for help on using the changeset viewer.