Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 21, 2019, 2:19:16 PM (6 years ago)
Author:
ahuwyler
Message:

A new Game is born

Location:
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox
Files:
6 edited

Legend:

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

    r12210 r12212  
    1 SET_SOURCE_FILES(PONG_SRC_FILES
    2 BUILD_UNIT PongBuildUnit.cc
    3   Pong.cc
    4   PongAI.cc
    5   PongBall.cc
    6   PongBat.cc
    7   PongBot.cc
    8   PongCenterpoint.cc
    9   PongScore.cc
     1SET_SOURCE_FILES(OrxoBlox_FS19_SRC_FILES
     2BUILD_UNIT OrxoBloxBuildUnit.cc
     3  OrxoBlox.cc
     4  OrxoBloxAI.cc
     5  OrxoBloxBall.cc
     6  OrxoBloxBat.cc
     7  OrxoBloxBot.cc
     8  OrxoBloxCenterpoint.cc
     9  OrxoBloxScore.cc
    1010END_BUILD_UNIT
    1111)
    1212
    13 ORXONOX_ADD_LIBRARY(pong
     13ORXONOX_ADD_LIBRARY(OrxoBlox_FS19
    1414  PLUGIN
    1515  FIND_HEADER_FILES
     
    1717    orxonox
    1818    overlays
    19   SOURCE_FILES ${PONG_SRC_FILES}
     19  SOURCE_FILES ${OrxoBlox_FS19_SRC_FILES}
    2020)
  • code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.cc

    r12210 r12212  
    2828
    2929/**
    30     @file Pong.cc
    31     @brief Implementation of the Pong class.
     30    @file OrxoBlox.cc
     31    @brief Implementation of the OrxoBlox class.
    3232*/
    3333
    34 #include "Pong.h"
     34#include "OrxoBlox.h"
    3535
    3636#include "core/CoreIncludes.h"
     
    4242#include "chat/ChatManager.h"
    4343
    44 #include "PongCenterpoint.h"
    45 #include "PongBall.h"
    46 #include "PongBat.h"
    47 #include "PongBot.h"
    48 #include "PongAI.h"
    49 
     44#include "OrxoBloxCenterpoint.h"
     45#include "OrxoBloxBall.h"
     46#include "OrxoBloxBat.h"
     47#include "OrxoBloxBot.h"
     48#include "OrxoBloxAI.h"
    5049namespace orxonox
    5150{
    5251    // Events to allow to react to scoring of a player, in the level-file.
    53     CreateEventName(PongCenterpoint, right);
    54     CreateEventName(PongCenterpoint, left);
    55 
    56     RegisterUnloadableClass(Pong);
     52    CreateEventName(OrxoBloxCenterpoint, right);
     53    CreateEventName(OrxoBloxCenterpoint, left);
     54
     55    RegisterUnloadableClass(OrxoBlox);
    5756
    5857    /**
     
    6059        Constructor. Registers and initializes the object.
    6160    */
    62     Pong::Pong(Context* context) : Deathmatch(context)
    63     {
    64         RegisterObject(Pong);
     61    OrxoBlox::OrxoBlox(Context* context) : Deathmatch(context)
     62    {
     63        RegisterObject(OrxoBlox);
    6564
    6665        this->center_ = nullptr;
     
    6968        this->bat_[1] = nullptr;
    7069
    71         this->setHUDTemplate("PongHUD");
     70        this->setHUDTemplate("OrxoBloxHUD");
    7271
    7372        // Pre-set the timer, but don't start it yet.
    74         this->starttimer_.setTimer(1.0, false, createExecutor(createFunctor(&Pong::startBall, this)));
     73        this->starttimer_.setTimer(1.0, false, createExecutor(createFunctor(&OrxoBlox::startBall, this)));
    7574        this->starttimer_.stopTimer();
    7675
    7776        // Set the type of Bots for this particular Gametype.
    78         this->botclass_ = Class(PongBot);
     77        this->botclass_ = Class(OrxoBloxBot);
    7978
    8079        this->scoreLimit_ = 10;
     
    8685        Destructor. Cleans up, if initialized.
    8786    */
    88     Pong::~Pong()
     87    OrxoBlox::~OrxoBlox()
    8988    {
    9089        if (this->isInitialized())
     
    9291    }
    9392
    94     void Pong::setConfigValues()
     93    void OrxoBlox::setConfigValues()
    9594    {
    9695        SetConfigValue(scoreLimit_, 10).description("The player first reaching those points wins.");
     
    101100        Cleans up the Gametype by destroying the ball and the bats.
    102101    */
    103     void Pong::cleanup()
     102    void OrxoBlox::cleanup()
    104103    {
    105104        if (this->ball_ != nullptr) // Destroy the ball, if present.
     
    123122    /**
    124123    @brief
    125         Starts the Pong minigame.
    126     */
    127     void Pong::start()
    128     {
    129         if (this->center_ != nullptr) // There needs to be a PongCenterpoint, i.e. the area the game takes place.
     124        Starts the OrxoBlox minigame.
     125    */
     126    void OrxoBlox::start()
     127    {
     128        if (this->center_ != nullptr) // There needs to be a OrxoBloxCenterpoint, i.e. the area the game takes place.
    130129        {
    131130            if (this->ball_ == nullptr) // If there is no ball, create a new ball.
    132131            {
    133                 this->ball_ = new PongBall(this->center_->getContext());
     132                this->ball_ = new OrxoBloxBall(this->center_->getContext());
    134133                // Apply the template for the ball specified by the centerpoint.
    135134                this->ball_->addTemplate(this->center_->getBalltemplate());
     
    145144
    146145            // If one of the bats is missing, create it. Apply the template for the bats as specified in the centerpoint.
    147             for (WeakPtr<orxonox::PongBat>& bat : this->bat_)
     146            for (WeakPtr<orxonox::OrxoBloxBat>& bat : this->bat_)
    148147            {
    149148                if (bat == nullptr)
    150149                {
    151                     bat = new PongBat(this->center_->getContext());
     150                    bat = new OrxoBloxBat(this->center_->getContext());
    152151                    bat->addTemplate(this->center_->getBattemplate());
    153152                }
     
    173172        else // If no centerpoint was specified, an error is thrown and the level is exited.
    174173        {
    175             orxout(internal_error) << "Pong: No Centerpoint specified." << endl;
     174            orxout(internal_error) << "OrxoBlox: No Centerpoint specified." << endl;
    176175            GSLevel::startMainMenu();
    177176            return;
     
    194193    /**
    195194    @brief
    196         Ends the Pong minigame.
    197     */
    198     void Pong::end()
     195        Ends the OrxoBlox minigame.
     196    */
     197    void OrxoBlox::end()
    199198    {
    200199        this->cleanup();
     
    208207        Spawns players, and fills the rest up with bots.
    209208    */
    210     void Pong::spawnPlayersIfRequested()
     209    void OrxoBlox::spawnPlayersIfRequested()
    211210    {
    212211        // first spawn human players to assign always the left bat to the player in singleplayer
     
    226225        The player to be spawned.
    227226    */
    228     void Pong::spawnPlayer(PlayerInfo* player)
     227    void OrxoBlox::spawnPlayer(PlayerInfo* player)
    229228    {
    230229        assert(player);
     
    247246
    248247        // If the player is an AI, it receives a pointer to the ball.
    249         if (player->getController() != nullptr && player->getController()->isA(Class(PongAI)))
    250         {
    251             PongAI* ai = orxonox_cast<PongAI*>(player->getController());
    252             ai->setPongBall(this->ball_);
     248        if (player->getController() != nullptr && player->getController()->isA(Class(OrxoBloxAI)))
     249        {
     250            OrxoBloxAI* ai = orxonox_cast<OrxoBloxAI*>(player->getController());
     251            ai->setOrxoBloxBall(this->ball_);
    253252        }
    254253    }
     
    258257        Is called when the player scored.
    259258    */
    260     void Pong::playerScored(PlayerInfo* player, int score)
     259    void OrxoBlox::playerScored(PlayerInfo* player, int score)
    261260    {
    262261        Deathmatch::playerScored(player, score);
     
    266265            // Fire an event for the player that has scored, to be able to react to it in the level, e.g. by displaying fireworks.
    267266            if (player == this->getRightPlayer())
    268                 this->center_->fireEvent(FireEventName(PongCenterpoint, right));
     267                this->center_->fireEvent(FireEventName(OrxoBloxCenterpoint, right));
    269268            else if (player == this->getLeftPlayer())
    270                 this->center_->fireEvent(FireEventName(PongCenterpoint, left));
     269                this->center_->fireEvent(FireEventName(OrxoBloxCenterpoint, left));
    271270
    272271            // Also announce, that the player has scored.
     
    312311        Starts the ball with some default speed.
    313312    */
    314     void Pong::startBall()
     313    void OrxoBlox::startBall()
    315314    {
    316315        if (this->ball_ != nullptr && this->center_ != nullptr)
     
    324323        Returns a pointer to the player playing on the left. If there is no left player, nullptr is returned.
    325324    */
    326     PlayerInfo* Pong::getLeftPlayer() const
     325    PlayerInfo* OrxoBlox::getLeftPlayer() const
    327326    {
    328327        if (this->bat_[0] != nullptr)
     
    338337        Returns a pointer to the player playing on the right. If there is no right player, nullptr is returned.
    339338    */
    340     PlayerInfo* Pong::getRightPlayer() const
     339    PlayerInfo* OrxoBlox::getRightPlayer() const
    341340    {
    342341        if (this->bat_[1] != nullptr)
  • code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.h

    r12210 r12212  
    4141
    4242#include "gametypes/Deathmatch.h"
    43 #include "PongCenterpoint.h"
     43#include "OrxoBloxCenterpoint.h"
    4444
    4545namespace orxonox
     
    4848    /**
    4949    @brief
    50         Implements a Pong minigame (<a href="http://en.wikipedia.org/wiki/Pong">Wikipedia::Pong</a>).
    51         It connects the different entities present in a game of Pong.
     50        Implements a OrxoBlox minigame (<a href="http://en.wikipedia.org/wiki/OrxoBlox">Wikipedia::OrxoBlox</a>).
     51        It connects the different entities present in a game of OrxoBlox.
    5252
    53         - The @ref orxonox::PongCenterpoint "PongCenterpoint" is the playing field for the Pong minigame, it allows for configuration of the minigame, e.g. by setting the size of the playing field, or the length of the @ref orxonox::PongBat "PongBats". The playing field is always in the x,y-plane, the x-axis being the horizontal and the z-axis being the vertical axis.<br />
    54         The Pong class redistributes the important parameters defined in @ref orxonox::PongCenterpoint "PongCenterpoint" to the other entities, that need to know them, e.g. the @ref orxonox::PongBall "PongBall" and the @ref orxonox::PongBat "PongBats".<br />
    55         The @ref orxonox::PongCenterpoint "PongCenterpoint" needs to exist in a level with the @ref orxonox::Gametype "Gametype" <em>Pong</em>.
    56         - The @ref orxonox::PongBall "PongBall" is the ball both players play with. The @ref orxonox::PongBall "PongBall" both implements the movement of the ball, as well as the influence of the boundaries and consequently, also the bouncing (off the upper and lower delimiters, and as off the @ref orxonox::PongBat "PongBats") of the ball and the effects of the failure of a player to catch the ball (i.e. the scoring of the other player).
    57         - The two @ref orxonox::PongBat "PongBats" are the entities through which the players can actively participate in the game, by controlling them. The @ref orxonox::PongBat "PongBat" class manages the movement (and restrictions thereof) and the influence of the players on the bats.
     53        - The @ref orxonox::OrxoBloxCenterpoint "OrxoBloxCenterpoint" is the playing field for the OrxoBlox minigame, it allows for configuration of the minigame, e.g. by setting the size of the playing field, or the length of the @ref orxonox::OrxoBloxBat "OrxoBloxBats". The playing field is always in the x,y-plane, the x-axis being the horizontal and the z-axis being the vertical axis.<br />
     54        The OrxoBlox class redistributes the important parameters defined in @ref orxonox::OrxoBloxCenterpoint "OrxoBloxCenterpoint" to the other entities, that need to know them, e.g. the @ref orxonox::OrxoBloxBall "OrxoBloxBall" and the @ref orxonox::OrxoBloxBat "OrxoBloxBats".<br />
     55        The @ref orxonox::OrxoBloxCenterpoint "OrxoBloxCenterpoint" needs to exist in a level with the @ref orxonox::Gametype "Gametype" <em>OrxoBlox</em>.
     56        - The @ref orxonox::OrxoBloxBall "OrxoBloxBall" is the ball both players play with. The @ref orxonox::OrxoBloxBall "OrxoBloxBall" both implements the movement of the ball, as well as the influence of the boundaries and consequently, also the bouncing (off the upper and lower delimiters, and as off the @ref orxonox::OrxoBloxBat "OrxoBloxBats") of the ball and the effects of the failure of a player to catch the ball (i.e. the scoring of the other player).
     57        - The two @ref orxonox::OrxoBloxBat "OrxoBloxBats" are the entities through which the players can actively participate in the game, by controlling them. The @ref orxonox::OrxoBloxBat "OrxoBloxBat" class manages the movement (and restrictions thereof) and the influence of the players on the bats.
    5858
    5959    @author
    6060        Fabian 'x3n' Landau
    6161
    62     @ingroup Pong
     62    @ingroup OrxoBlox
    6363    */
    64     class _PongExport Pong : public Deathmatch
     64    class _OrxoBloxExport OrxoBlox : public Deathmatch
    6565    {
    6666        public:
    67             Pong(Context* context); //!< Constructor. Registers and initializes the object.
    68             virtual ~Pong(); //!< Destructor. Cleans up, if initialized.
     67            OrxoBlox(Context* context); //!< Constructor. Registers and initializes the object.
     68            virtual ~OrxoBlox(); //!< Destructor. Cleans up, if initialized.
    6969
    70             virtual void start() override; //!< Starts the Pong minigame.
    71             virtual void end() override; ///!< Ends the Pong minigame.
     70            virtual void start() override; //!< Starts the OrxoBlox minigame.
     71            virtual void end() override; ///!< Ends the OrxoBlox minigame.
    7272
    7373            virtual void spawnPlayer(PlayerInfo* player) override; //!< Spawns the input player.
     
    7676
    7777            /**
    78             @brief Set the PongCenterpoint (the playing field).
    79             @param center A pointer to the PongCenterpoint to be set.
     78            @brief Set the OrxoBloxCenterpoint (the playing field).
     79            @param center A pointer to the OrxoBloxCenterpoint to be set.
    8080            */
    81             void setCenterpoint(PongCenterpoint* center)
     81            void setCenterpoint(OrxoBloxCenterpoint* center)
    8282                { this->center_ = center; }
    8383            void setConfigValues(); //!< Makes scoreLimit configurable.
     
    9292            void cleanup(); //!< Cleans up the Gametype by destroying the ball and the bats.
    9393
    94             WeakPtr<PongCenterpoint> center_; //!< The playing field.
    95             WeakPtr<PongBall> ball_; //!< The Pong ball.
    96             WeakPtr<PongBat> bat_[2]; //!< The two bats.
     94            WeakPtr<OrxoBloxCenterpoint> center_; //!< The playing field.
     95            WeakPtr<OrxoBloxBall> ball_; //!< The OrxoBlox ball.
     96            WeakPtr<OrxoBloxBat> bat_[2]; //!< The two bats.
    9797            Timer starttimer_; //!< A timer to delay the start of the game.
    9898            int scoreLimit_; //!< If a player scored that much points, the game is ended.
     
    100100}
    101101
    102 #endif /* _Pong_H__ */
     102#endif /* _OrxoBlox_H__ */
  • code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.cc

    r12210 r12212  
    1 
    2 //TODO: Sounds (all the sounds are still from the pong module...)
    3 //TODO: Blocks (the Ball-Block comunication is based on how the blocks are implemented)
    4 //TODO: The bottom boundary/ the Ball collecter
    5 //TODO: Ability to shoot the ball (the ball is still constructed like the pong ball)
    6 
    71/*
    82 *   ORXONOX - the hottest 3D action shooter ever to exist
     
    4539#include "gametypes/Gametype.h"
    4640
    47 #include "OrxoBloxBlocks.h"
     41#include "OrxoBloxBat.h"
    4842
    4943#include "sound/WorldSound.h"
     
    6761        this->speed_ = 0;
    6862        this->accelerationFactor_ = 1.0f;
    69         this->block_ = nullptr;
    70         this->bDeleteBlock_ = false;
    71         this->blockID_ = new unsigned int[100];
    72         for (int i = 0; i < 100; i++) {
    73                 this->blockID_[i] = OBJECTID_UNKNOWN;
    74         }
     63        this->bat_ = nullptr;
     64        this->bDeleteBats_ = false;
     65        this->batID_ = new unsigned int[2];
     66        this->batID_[0] = OBJECTID_UNKNOWN;
     67        this->batID_[1] = OBJECTID_UNKNOWN;
     68        this->relMercyOffset_ = 0.05f;
    7569
    7670        this->registerVariables();
     
    10296        if (this->isInitialized())
    10397        {
    104             if (this->bDeleteBlock_)
    105                 delete[] this->block_;
    106 
    107             delete[] this->blockID_;
     98            if (this->bDeleteBats_)
     99                delete[] this->bat_;
     100
     101            delete[] this->batID_;
    108102        }
    109103    }
     
    126120        registerVariable( this->fieldWidth_ );
    127121        registerVariable( this->fieldHeight_ );
    128         registerVariable( this->blocklength_ );
     122        registerVariable( this->batlength_ );
    129123        registerVariable( this->speed_ );
    130         registerVariable( this->blockID_[0] );
    131         registerVariable( this->blockID_[1], VariableDirection::ToClient, new NetworkCallback<OrxoBloxBall>( this, &OrxoBloxBall::applyBlock) );
     124        registerVariable( this->relMercyOffset_ );
     125        registerVariable( this->batID_[0] );
     126        registerVariable( this->batID_[1], VariableDirection::ToClient, new NetworkCallback<OrxoBloxBall>( this, &OrxoBloxBall::applyBats) );
    132127    }
    133128
     
    135130    @brief
    136131        Is called every tick.
    137         Handles the movement of the ball and its interaction with the boundaries and blocks.
     132        Handles the movement of the ball and its interaction with the boundaries and bats.
    138133    @param dt
    139134        The time since the last tick.
     
    148143        Vector3 acceleration = this->getAcceleration();
    149144
    150         // If the ball has hit the boundaries on either the right side or the left
    151         if (position.x > this->fieldWidth_ / 2 || position.x < -this->fieldWidth_ / 2)
    152         {
    153             defBoundarySound_->play(); //play boundary sound
    154             // Its velocity in x-direction is inverted (i.e. it bounces off).
    155             velocity.x = -velocity.x;
    156             // And its position is set as to not overstep the boundary it has just crossed.
    157             if (position.x > this->fieldWidth_ / 2)
    158                 position.x = this->fieldWidth_ / 2;
    159             if (position.x < -this->fieldWidth_ / 2)
    160                 position.x = -this->fieldWidth_ / 2;
    161 
    162             this->fireEvent();
    163         }
    164 
    165         // If the ball has hit the boundary on the top
    166         if (position.z > this->fieldHeight_ / 2)
     145        // If the ball has gone over the top or bottom boundary of the playing field (i.e. the ball has hit the top or bottom delimiters).
     146        if (position.z > this->fieldHeight_ / 2 || position.z < -this->fieldHeight_ / 2)
    167147        {
    168148            defBoundarySound_->play(); //play boundary sound
     
    170150            velocity.z = -velocity.z;
    171151            // And its position is set as to not overstep the boundary it has just crossed.
    172             position.z = this->fieldHeight_ / 2;
     152            if (position.z > this->fieldHeight_ / 2)
     153                position.z = this->fieldHeight_ / 2;
     154            if (position.z < -this->fieldHeight_ / 2)
     155                position.z = -this->fieldHeight_ / 2;
    173156
    174157            this->fireEvent();
    175158        }
    176159
    177         // If the ball has crossed the bottom boundary
    178         if (position.z < -this->fieldHeight_ / 2)
    179         {
    180         //TODO: Ball Collector
     160        // If the ball has crossed the left or right boundary of the playing field (i.e. a player has just scored, if the bat isn't there to parry).
     161        if (position.x > this->fieldWidth_ / 2 || position.x < -this->fieldWidth_ / 2)
     162        {
     163            float distance = 0;
     164
     165            if (this->bat_ != nullptr) // If there are bats.
     166            {
     167                // If the right boundary has been crossed.
     168                if (position.x > this->fieldWidth_ / 2 && this->bat_[1] != nullptr)
     169                {
     170                    // Calculate the distance (in z-direction) between the ball and the center of the bat, weighted by half of the effective length of the bat (with additional 10%)
     171                    distance = (position.z - this->bat_[1]->getPosition().z) / (this->fieldHeight_ * (this->batlength_ * 1.10f) / 2);
     172                    if (fabs(distance) <= 1) // If the bat is there to parry.
     173                    {
     174                        defBatSound_->play(); //play bat sound
     175                        // Set the ball to be exactly at the boundary.
     176                        position.x = this->fieldWidth_ / 2;
     177                        // Invert its velocity in x-direction (i.e. it bounces off).
     178                        velocity.x = -velocity.x;
     179                        // Adjust the velocity in the z-direction, depending on where the ball hit the bat.
     180                        velocity.z = distance * distance * sgn(distance) * OrxoBloxBall::MAX_REL_Z_VELOCITY * this->speed_;
     181                        acceleration = this->bat_[1]->getVelocity() * this->accelerationFactor_ * -1;
     182
     183                        this->fireEvent();
     184                    }
     185                    // If the left player scores.
     186                    else if (GameMode::isMaster() && position.x > this->fieldWidth_ / 2 * (1 + this->relMercyOffset_))
     187                    {
     188                        defScoreSound_->play();//play score sound
     189                        if (this->getGametype() && this->bat_[0])
     190                        {
     191                            this->getGametype()->playerScored(this->bat_[0]->getPlayer());
     192                            return;
     193                        }
     194                    }
     195                }
     196                // If the left boundary has been crossed.
     197                else if (position.x < -this->fieldWidth_ / 2 && this->bat_[0] != nullptr)
     198                {
     199                    // Calculate the distance (in z-direction) between the ball and the center of the bat, weighted by half of the effective length of the bat (with additional 10%)
     200                    distance = (position.z - this->bat_[0]->getPosition().z) / (this->fieldHeight_ * (this->batlength_ * 1.10f) / 2);
     201                    if (fabs(distance) <= 1) // If the bat is there to parry.
     202                    {
     203                        defBatSound_->play(); //play bat sound
     204                        // Set the ball to be exactly at the boundary.
     205                        position.x = -this->fieldWidth_ / 2;
     206                        // Invert its velocity in x-direction (i.e. it bounces off).
     207                        velocity.x = -velocity.x;
     208                        // Adjust the velocity in the z-direction, depending on where the ball hit the bat.
     209                        velocity.z = distance * distance * sgn(distance) * OrxoBloxBall::MAX_REL_Z_VELOCITY * this->speed_;
     210                        acceleration = this->bat_[0]->getVelocity() * this->accelerationFactor_ * -1;
     211
     212                        this->fireEvent();
     213                    }
     214                    // If the right player scores.
     215                    else if (GameMode::isMaster() && position.x < -this->fieldWidth_ / 2 * (1 + this->relMercyOffset_))
     216                    {
     217                        defScoreSound_->play();//play score sound
     218                        if (this->getGametype() && this->bat_[1])
     219                        {
     220                            this->getGametype()->playerScored(this->bat_[1]->getPlayer());
     221                            return;
     222                        }
     223                    }
     224                }
     225            }
    181226        }
    182227
     
    215260    /**
    216261    @brief
    217         Set the blocks for the ball.
     262        Set the bats for the ball.
    218263    @param bats
    219         An array (of size n (n=#Blocks) of weak pointers, to be set as the new blocks.
    220     */
    221     void OrxoBloxBall::setBlock(WeakPtr<OrxoBloxBlock>* block, int n)
    222     {
    223         if (this->bDeleteBlock_) // If there are already some blocks, delete them.
    224         {
    225             delete[] this->block_;
    226             this->bDeleteBlock_ = false;
    227         }
    228 
    229         this->block_ = block;
     264        An array (of size 2) of weak pointers, to be set as the new bats.
     265    */
     266    void OrxoBloxBall::setBats(WeakPtr<OrxoBloxBat>* bats)
     267    {
     268        if (this->bDeleteBats_) // If there are already some bats, delete them.
     269        {
     270            delete[] this->bat_;
     271            this->bDeleteBats_ = false;
     272        }
     273
     274        this->bat_ = bats;
    230275        // Also store their object IDs, for synchronization.
    231         for (int i = 0; i < n; i++) {
    232                 this->blockID_[i] = this->block_[i]->getObjectID();
    233         }
    234     }
    235 
    236     /**
    237     @brief
    238         Get the blocks over the network.
    239     */
    240     void OrxoBloxBall::applyBlock(int n)
    241     {
    242         // Make space for the blocks, if they don't exist, yet.
    243         if (this->block_ == nullptr)
    244         {
    245             this->block_ = new WeakPtr<OrxoBloxBlock>[n];
    246             this->bDeleteBlock_ = true;
    247         }
    248        
    249         for (int i = 0; i < n; i++) {
    250                 if (this->blockID_[i] != OBJECTID_UNKNOWN)
    251                 this->bat_[i] = orxonox_cast<OrxoBloxBlock*>(Synchronisable::getSynchronisable(this->blockID_[i]));
    252         }
    253     }
    254 
    255     void OrxoBloxBall::setDefScoreSound(const std::string &pongSound)
     276        this->batID_[0] = this->bat_[0]->getObjectID();
     277        this->batID_[1] = this->bat_[1]->getObjectID();
     278    }
     279
     280    /**
     281    @brief
     282        Get the bats over the network.
     283    */
     284    void OrxoBloxBall::applyBats()
     285    {
     286        // Make space for the bats, if they don't exist, yet.
     287        if (this->bat_ == nullptr)
     288        {
     289            this->bat_ = new WeakPtr<OrxoBloxBat>[2];
     290            this->bDeleteBats_ = true;
     291        }
     292
     293        if (this->batID_[0] != OBJECTID_UNKNOWN)
     294            this->bat_[0] = orxonox_cast<OrxoBloxBat*>(Synchronisable::getSynchronisable(this->batID_[0]));
     295        if (this->batID_[1] != OBJECTID_UNKNOWN)
     296            this->bat_[1] = orxonox_cast<OrxoBloxBat*>(Synchronisable::getSynchronisable(this->batID_[1]));
     297    }
     298
     299    void OrxoBloxBall::setDefScoreSound(const std::string &OrxoBloxSound)
    256300    {
    257301        if( defScoreSound_ )
    258             defScoreSound_->setSource(pongSound);
     302            defScoreSound_->setSource(OrxoBloxSound);
    259303        else
    260304            assert(0); // This should never happen, because soundpointer is only available on master
     
    270314    }
    271315
    272     void OrxoBloxBall::setDefBatSound(const std::string &pongSound)
     316    void OrxoBloxBall::setDefBatSound(const std::string &OrxoBloxSound)
    273317    {
    274318        if( defBatSound_ )
    275             defBatSound_->setSource(pongSound);
     319            defBatSound_->setSource(OrxoBloxSound);
    276320        else
    277321            assert(0); // This should never happen, because soundpointer is only available on master
     
    287331    }
    288332
    289     void OrxoBloxBall::setDefBoundarySound(const std::string &pongSound)
     333    void OrxoBloxBall::setDefBoundarySound(const std::string &OrxoBloxSound)
    290334    {
    291335        if( defBoundarySound_ )
    292             defBoundarySound_->setSource(pongSound);
     336            defBoundarySound_->setSource(OrxoBloxSound);
    293337        else
    294338            assert(0); // This should never happen, because soundpointer is only available on master
  • code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.h

    r12210 r12212  
    5050        This class manages the ball for @ref orxonox::OrxoBlox "OrxoBlox".
    5151
    52         It is responsible for both the movement of the ball in the x,y-plane as well as its interaction with the boundaries of the playing field (defined by the @ref orxonox::OrxoBloxCenterpoint "OrxoBloxCenterpoint") and the @ref orxonox::OrxoBloxBlocks "OrxoBloxBlocks". Or more precisely, it makes the ball bounce off then left and right delimiters of the playing field, it makes the ball bounce off the blocks, damages them and also detects when it reaches the lower bound and takes appropriate measures.
     52        It is responsible for both the movement of the ball in the x,z-plane as well as its interaction with the boundaries of the playing field (defined by the @ref orxonox::OrxoBloxCenterpoint "OrxoBloxCenterpoint") and the @ref orxonox::OrxoBloxBat "OrxoBloxBats". Or more precisely, it makes the ball bounce off then upper and lower delimiters of the playing field, it makes the ball bounce off the bats and also detects when a player scores and takes appropriate measures.
    5353
    5454    @author
     
    7676            /**
    7777            @brief Get the dimensions of the playing field.
    78             @param dimension A vector with the width as the first and height as the second                  component.
     78            @param dimension A vector with the width as the first and height as the second component.
    7979            */
    8080            void setFieldDimension(const Vector2& dimension)
     
    8282            /**
    8383            @brief Get the dimensions of the playing field.
    84             @return Returns a vector with the width as the first and height as the second                     component.
     84            @return Returns a vector with the width as the first and height as the second component.
    8585            */
    8686            Vector2 getFieldDimension() const
     
    109109
    110110            /**
    111             @brief Set the length of the blocks.
    112             @param batlength The length of the blocks (in x-direction) as percentage of the height                  of the playing field.
     111            @brief Set the length of the bats.
     112            @param batlength The length of the bats (in z-direction) as percentage of the height of the playing field.
    113113            */
    114             void setBlockLength(float blocklength)
    115                 { this->blocklength_ = blocklength; }
     114            void setBatLength(float batlength)
     115                { this->batlength_ = batlength; }
    116116            /**
    117             @brief Get the length of the blocks.
    118             @return Returns the length of the blocks as percentage of the height of the playing            field.
     117            @brief Get the length of the bats.
     118            @return Returns the length of the bats (in z-direction) as percentage of the height of the playing field.
    119119            */
    120             float getBlockLength() const
    121                 { return this->blocklength_; }
     120            float getBatLength() const
     121                { return this->batlength_; }
    122122
    123             void setBlock(WeakPtr<OrxoBloxBlock>* block); //!< Set the blocks for the ball.
    124             void applyBlock(); //!< Get the block over the network.
     123            void setBats(WeakPtr<OrxoBloxBat>* bats); //!< Set the bats for the ball.
     124            void applyBats(); //!< Get the bats over the network.
    125125
    126126            static const float MAX_REL_Z_VELOCITY;
     
    138138            float fieldWidth_; //!< The width of the playing field.
    139139            float fieldHeight_; //!< The height of the playing field.
    140             float speedX_; //!< The speed (in x-direction) of the ball.
    141             float speedY_; //!< The speed (in y-direction) of the ball.
     140            float speed_; //!< The speed (in x-direction) of the ball.
    142141            float accelerationFactor_; //!< The acceleration factor of the ball.
    143             float blocklength_; //!< The length of the bats (in z-direction) as percentage of the           height of the playing field.
    144             WeakPtr<OrxoBloxBlock>* block_; //!< An array with the blocks.
    145             bool bDeleteBlock_; //!< Bool, to keep track, of whether this->block_ exists or not.
    146             unsigned int* blockID_; //!< The object IDs of the blocks, to be able to synchronize                    them over the network.
     142            float batlength_; //!< The length of the bats (in z-direction) as percentage of the height of the playing field.
     143            WeakPtr<OrxoBloxBat>* bat_; //!< An array with the two bats.
     144            bool bDeleteBats_; //!< Bool, to keep track, of whether this->bat_ exists or not.
     145            unsigned int* batID_; //!< The object IDs of the bats, to be able to synchronize them over the network.
     146            float relMercyOffset_; //!< Offset, that makes the player not loose, when, in all fairness, he would have.
    147147            WorldSound* defScoreSound_;
    148148            WorldSound* defBatSound_;
  • code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxPrereqs.h

    r12210 r12212  
    4343//-----------------------------------------------------------------------
    4444
    45 #if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(PONG_STATIC_BUILD)
    46 #  ifdef PONG_SHARED_BUILD
    47 #    define _PongExport __declspec(dllexport)
     45#if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(OrxoBlox_STATIC_BUILD)
     46#  ifdef OrxoBlox_SHARED_BUILD
     47#    define _OrxoBloxExport __declspec(dllexport)
    4848#  else
    4949#    if defined( __MINGW32__ )
    50 #      define _PongExport
     50#      define _OrxoBloxExport
    5151#    else
    52 #      define _PongExport __declspec(dllimport)
     52#      define _OrxoBloxExport __declspec(dllimport)
    5353#    endif
    5454#  endif
    55 #  define _PongPrivate
     55#  define _OrxoBloxPrivate
    5656#elif defined (ORXONOX_GCC_VISIBILITY)
    57 #  define _PongExport  __attribute__ ((visibility("default")))
    58 #  define _PongPrivate __attribute__ ((visibility("hidden")))
     57#  define _OrxoBloxExport  __attribute__ ((visibility("default")))
     58#  define _OrxoBloxPrivate __attribute__ ((visibility("hidden")))
    5959#else
    60 #  define _PongExport
    61 #  define _PongPrivate
     60#  define _OrxoBloxExport
     61#  define _OrxoBloxPrivate
    6262#endif
    6363
     
    6868namespace orxonox
    6969{
    70     class Pong;
    71     class PongAI;
    72     class PongBall;
    73     class PongBat;
    74     class PongBot;
    75     class PongCenterpoint;
    76     class PongScore;
     70    class OrxoBlox;
     71    class OrxoBloxAI;
     72    class OrxoBloxBall;
     73    class OrxoBloxBat;
     74    class OrxoBloxBot;
     75    class OrxoBloxCenterpoint;
     76    class OrxoBloxScore;
    7777}
    7878
    79 #endif /* _PongPrereqs_H__ */
     79#endif /* _OrxoBloxPrereqs_H__ */
Note: See TracChangeset for help on using the changeset viewer.