Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8107


Ignore:
Timestamp:
Mar 23, 2011, 9:41:21 PM (13 years ago)
Author:
dafrick
Message:

Done documenting Pong.
Also resolved some doxygen warnings.

Location:
code/branches/tetris
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • code/branches/tetris/doc/api/groups/Triggers.dox

    r8106 r8107  
    6666    A @ref orxonox::DistanceMultiTrigger "DistanceMultiTrigger" is the MultiTrigger equivalent of the @ref orxonox::DistanceTrigger "DistanceTrigger" and works just the same way. It triggers (now separately for each object triggering it, since it's a @ref orxonox::MultiTrigger "MultiTrigger") whenever an object that is a target of the @ref orxonox::DistanceMultiTrigger "DistanceMultiTrigger" is in the specified range.
    6767
    68     Two additional parameters can be specified for the @ref orxonox::DistanceMultiTrigger "DistanceMultiTrigger" are the <em>distance</em>, which defines the maximum distance at which an object still triggers the @ref orxonox:: "DistanceMultiTrigger", and the <em>targetname</em>. Setting the <em>targename</em> puts the @ref orxonox::DistanceMultiTrigger "DistanceMultiTrigger" in <em>single-target mode</em>. In this mode the @ref orxonox::DistanceMultiTrigger "DistanceMultiTrigger"  can only be triggered by objects that have a @ref orxonox::DistanceTriggerBeacon "DistanceTriggerBeacon" with the name specified by <em>targetname</em> directly attached. For the <em>single-target mode</em> to work the target of the @ref orxonox::DistanceMultiTrigger "DistanceMultiTrigger" has to be set to <code>DistanceTriggerBeacon</code>.
     68    Two additional parameters can be specified for the @ref orxonox::DistanceMultiTrigger "DistanceMultiTrigger" are the <em>distance</em>, which defines the maximum distance at which an object still triggers the @ref orxonox::DistanceMultiTrigger "DistanceMultiTrigger", and the <em>targetname</em>. Setting the <em>targename</em> puts the @ref orxonox::DistanceMultiTrigger "DistanceMultiTrigger" in <em>single-target mode</em>. In this mode the @ref orxonox::DistanceMultiTrigger "DistanceMultiTrigger"  can only be triggered by objects that have a @ref orxonox::DistanceTriggerBeacon "DistanceTriggerBeacon" with the name specified by <em>targetname</em> directly attached. For the <em>single-target mode</em> to work the target of the @ref orxonox::DistanceMultiTrigger "DistanceMultiTrigger" has to be set to <code>DistanceTriggerBeacon</code>.
    6969
    7070    A common usage (without @ref orxonox::DistanceTriggerBeacon "DistanceTriggerBeacon") would look like this:
  • code/branches/tetris/src/libraries/core/Loader.cc

    r8079 r8107  
    144144    @param verbose
    145145        Whether the loader is verbose (prints its progress in a low output level) or not.
     146    @param bRemoveLuaTags
     147        If true lua tags are just ignored and removed. The default is false.
    146148    @return
    147149        Returns true if successful.
  • code/branches/tetris/src/libraries/network/Host.cc

    r8079 r8107  
    7575  * @param packet Packet to be added
    7676  * @param clientID ID of the client the packet should be sent to
     77  * @param channelID ID of the channel.
    7778  * @return success?
    7879  */
  • code/branches/tetris/src/libraries/network/MasterServerComm.h

    r7804 r8107  
    8989
    9090      /** \param callback The callback function to call with data received.
     91       *  \param delayms Delay in milliseconds.
    9192       * \return 0 for success, other for error
    9293       *
  • code/branches/tetris/src/modules/designtools/ScreenshotManager.cc

    r8079 r8107  
    6161    @brief
    6262        Creates a screenshot with the given camera.
    63     @param camera
    64         Pointer to the camera "looking at" the scene of interest
    65     @param fileName
    66         the filename of the screenshot file.
    6763    */
    6864    void ScreenshotManager::makeScreenshot() const
  • code/branches/tetris/src/modules/pong/PongAI.cc

    r6417 r8107  
    2727 */
    2828
     29/**
     30    @file PongAI.cc
     31    @brief Implementation of the PongAI class.
     32*/
     33
    2934#include "PongAI.h"
    3035
     
    3237#include "core/ConfigValueIncludes.h"
    3338#include "tools/Timer.h"
     39
    3440#include "worldentities/ControllableEntity.h"
     41
    3542#include "PongBall.h"
    3643
     
    4148    const static float MAX_REACTION_TIME = 0.4f;
    4249
     50    /**
     51    @brief
     52        Constructor. Registers and initializes the object.
     53    */
    4354    PongAI::PongAI(BaseObject* creator) : Controller(creator)
    4455    {
     
    5970    }
    6071
     72    /**
     73    @brief
     74        Destructor. Cleans up the list fo reaction timers.
     75    */
    6176    PongAI::~PongAI()
    6277    {
     
    6580    }
    6681
     82    /**
     83    @brief
     84        Sets config values.
     85    */
    6786    void PongAI::setConfigValues()
    6887    {
     88        // Sets the strength of the PongAi as a config value.
    6989        SetConfigValue(strength_, 0.5).description("A value from 0 to 1 where 0 is weak and 1 is strong.");
    7090    }
    7191
     92    /**
     93    @brief
     94        Is called each tick.
     95        Implements the behavior of the PongAI (i.e. its intelligence).
     96    @param dt
     97        The time that has elapsed since the last tick.
     98    */
    7299    void PongAI::tick(float dt)
    73100    {
    74         if (!this->ball_ || !this->getControllableEntity())
     101        // If either the ball, or the controllable entity (i.e. the bat) don't exist (or aren't set).
     102        if (this->ball_  == NULL || this->getControllableEntity() == NULL)
    75103            return;
    76104
     
    109137            if (this->ballDirection_.x != 1)
    110138            {
    111                 // The ball just startet to approach, initialize all values
     139                // The ball just started to approach, initialize all values
    112140                this->ballDirection_.x = 1;
    113141                this->ballDirection_.y = sgn(ballvel.z);
     
    158186            {
    159187                // We had to correct our position because we moved too far
    160                 // (and delay ist false, so we're not in the wrong place because of a new end-position prediction)
     188                // (and delay is false, so we're not in the wrong place because of a new end-position prediction)
    161189                if (fabs(mypos.z - this->ballEndPosition_) < 0.5 * this->ball_->getBatLength() * this->ball_->getFieldDimension().y)
    162190                {
     
    173201    }
    174202
     203    /**
     204    @brief
     205        Calculates the random offset, that accounts for random errors the AI makes in order to be beatable.
     206        The higher the strength of the AI, the smaller the (expected value of the) error.
     207        The result of this method is stored in this->randomOffset_.
     208    */
    175209    void PongAI::calculateRandomOffset()
    176210    {
     
    184218                                          // exp < 1 -> position is more likely a large number
    185219
    186         // The position shouln't be larger than 0.5 (50% of the bat-length from the middle is the end)
     220        // The position shouldn't be larger than 0.5 (50% of the bat-length from the middle is the end)
    187221        position *= 0.48f;
    188222
     
    194228    }
    195229
     230    /**
     231    @brief
     232        Calculate the end position the ball will be in.
     233        The result of this calculation is stored in this->ballEndPosition_.
     234    */
    196235    void PongAI::calculateBallEndPosition()
    197236    {
     
    295334    }
    296335
     336    /**
     337    @brief
     338        Determine the movement the AI will undertake. (Either -1, 0 or 1)
     339        The result of this calculation is stored in this->movement_;
     340    @param direction
     341        The current direction of movement.
     342    @param bUseDelay
     343        The time by which this move is delayed. (Again, to make the AI less efficient)
     344    */
    297345    void PongAI::move(char direction, bool bUseDelay)
    298346    {
     
    321369    }
    322370
     371    /**
     372    @brief
     373        Is called, when a delayed move takes effect.
     374    */
    323375    void PongAI::delayedMove()
    324376    {
  • code/branches/tetris/src/modules/pong/PongAI.h

    r5929 r8107  
    2727 */
    2828
     29/**
     30    @file PongAI.h
     31    @brief Declaration of the PongAI class.
     32    @ingroup Pong
     33*/
     34
    2935#ifndef _PongAI_H__
    3036#define _PongAI_H__
     
    3339
    3440#include <list>
     41
    3542#include "util/Math.h"
    3643#include "tools/interfaces/Tickable.h"
     44
    3745#include "controllers/Controller.h"
    3846
    3947namespace orxonox
    4048{
     49
     50    /**
     51    @brief
     52        The PongAI is an artificial intelligence for the @ref orxonox::Pong "Pong" gametype.
     53
     54    @author
     55        Fabian 'x3n' Landau
     56
     57    @ingroup Pong
     58    */
    4159    class _PongExport PongAI : public Controller, public Tickable
    4260    {
    4361        public:
    44             PongAI(BaseObject* creator);
     62            PongAI(BaseObject* creator); //!< Constructor. Registers and initializes the object.
    4563            virtual ~PongAI();
    4664
    4765            void setConfigValues();
    4866
    49             virtual void tick(float dt);
     67            virtual void tick(float dt); //!< Implements the behavior of the PongAI (i.e. its intelligence).
    5068
     69            /**
     70            @brief Set the ball for the AI.
     71            @param ball A pointer to the ball.
     72            */
    5173            void setPongBall(PongBall* ball)
    5274                { this->ball_ = ball; }
    5375
    5476        protected:
    55             void calculateRandomOffset();
    56             void calculateBallEndPosition();
    57             void move(char direction, bool bUseDelay);
    58             void delayedMove();
     77            void calculateRandomOffset(); //!< Calculates the random offset, that accounts for random errors the AI makes in order to be beatable.
     78            void calculateBallEndPosition(); //!< Calculate the end position the ball will be in.
     79            void move(char direction, bool bUseDelay); //!< Determine the movement the AI will undertake.
     80            void delayedMove(); //!< Is called, when a delayed move takes effect.
    5981
    60             PongBall* ball_;
    61             Vector2 ballDirection_;
    62             float ballEndPosition_;
    63             float randomOffset_;
    64             bool bChangedRandomOffset_;
    65             float relHysteresisOffset_;
    66             float strength_;
     82            PongBall* ball_; //!< A pointer to the ball.
     83            Vector2 ballDirection_; //!< Vector to store the (x,z) direction in which the ball is flying.
     84            float ballEndPosition_; //!< The calculated end position of the ball.
     85            float randomOffset_; //!< A random offset to introduce random errors (weighted by the strength of the AI) into the AI's behavior.
     86            bool bChangedRandomOffset_; //!< Helper boolean, to change the random offset more often.
     87            float relHysteresisOffset_; //!< A hysteresis offset.
     88            float strength_; //!< The strength of the AI. Ranging from 0 to 1.
    6789
    68             std::list<std::pair<Timer*, char> > reactionTimers_;
    69             char movement_;
    70             char oldMove_;
    71             bool bOscillationAvoidanceActive_;
     90            std::list<std::pair<Timer*, char> > reactionTimers_; //!< A list of reaction timers and the directions that take effect when their timer expires.
     91            char movement_; //!< The planned movement.
     92            char oldMove_; //!< The previous movement.
     93            bool bOscillationAvoidanceActive_; //!< Boolean, to avoid oscillations.
    7294    };
    7395}
  • code/branches/tetris/src/modules/pong/PongBat.cc

    r8106 r8107  
    8787                this->movement_ = clamp(this->movement_, -1.0f, 1.0f) * this->speed_;
    8888
    89                 //TODO: Why needed?
     89                // If moveRightLeft() is used the movement is dependento on wehther it is the right or the left bat, so, it is i.e. dependent on the orientation of the bat.
    9090                if (this->bMoveLocal_)
    9191                    this->setVelocity(this->getOrientation() * Vector3(this->movement_, 0, 0));
  • code/branches/tetris/src/modules/pong/PongBot.cc

    r5781 r8107  
    2727 */
    2828
     29/**
     30    @file PongBot.cc
     31    @brief Implementation of the PongBot class.
     32*/
     33
    2934#include "PongBot.h"
    3035
     
    3641    CreateFactory(PongBot);
    3742
     43    /**
     44    @brief
     45        Constructor. Registers the object and creates a PongAI controller.
     46    */
    3847    PongBot::PongBot(BaseObject* creator) : Bot(creator)
    3948    {
  • code/branches/tetris/src/modules/pong/PongBot.h

    r5781 r8107  
    2727 */
    2828
     29/**
     30    @file PongBot.h
     31    @brief Declaration of the PongBot class.
     32    @ingroup Pong
     33*/
     34
    2935#ifndef _PongBot_H__
    3036#define _PongBot_H__
     
    3541namespace orxonox
    3642{
     43
     44    /**
     45    @brief
     46        A bot especially for @ref orxonox::Pong "Pong".
     47
     48        Uses the @ref orxonox::PongAI "PongAI".
     49
     50    @author
     51        Fabian 'x3n' Landau
     52
     53    @ingroup Pong
     54    */
    3755    class _PongExport PongBot : public Bot
    3856    {
  • code/branches/tetris/src/modules/pong/PongScore.cc

    r6417 r8107  
    2727 */
    2828
     29/**
     30    @file PongScore.cc
     31    @brief Implementation of the PongScore class.
     32*/
     33
    2934#include "PongScore.h"
    3035
    31 #include "util/Convert.h"
    3236#include "core/CoreIncludes.h"
    3337#include "core/XMLPort.h"
     38#include "util/Convert.h"
     39
     40#include "infos/PlayerInfo.h"
     41
    3442#include "Pong.h"
    35 #include "infos/PlayerInfo.h"
    3643
    3744namespace orxonox
     
    3946    CreateFactory(PongScore);
    4047
     48    /**
     49    @brief
     50        Constructor. Registers and initializes the object.
     51    */
    4152    PongScore::PongScore(BaseObject* creator) : OverlayText(creator)
    4253    {
     
    5162    }
    5263
     64    /**
     65    @brief
     66        Destructor.
     67    */
    5368    PongScore::~PongScore()
    5469    {
    5570    }
    5671
     72    /**
     73    @brief
     74        Method to create a PongScore through XML.
     75    */
    5776    void PongScore::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    5877    {
     
    6584    }
    6685
     86    /**
     87    @brief
     88        Is called each tick.
     89        Creates and sets the caption to be displayed by the PongScore.
     90    @param dt
     91        The time that has elapsed since the last tick.
     92    */
    6793    void PongScore::tick(float dt)
    6894    {
    6995        SUPER(PongScore, tick, dt);
    7096
    71         if (this->owner_)
     97        // If the owner is set. The owner being a Pong game.
     98        if (this->owner_ != NULL)
    7299        {
     100            // Get the two players.
    73101            PlayerInfo* player1 = this->owner_->getLeftPlayer();
    74102            PlayerInfo* player2 = this->owner_->getRightPlayer();
     
    80108            std::string score2("0");
    81109
    82             if (player1)
     110            // Save the name and score of each player as a string.
     111            if (player1 != NULL)
    83112            {
    84113                name1 = player1->getName();
    85114                score1 = multi_cast<std::string>(this->owner_->getScore(player1));
    86115            }
    87 
    88             if (player2)
     116            if (player2 != NULL)
    89117            {
    90118                name2 = player2->getName();
     
    92120            }
    93121
     122            // Assemble the strings, depending on what should all be displayed.
    94123            std::string output1;
    95124            if (this->bShowLeftPlayer_)
    96125            {
    97                 if (this->bShowName_ && this->bShowScore_ && player1)
     126                if (this->bShowName_ && this->bShowScore_ && player1 != NULL)
    98127                    output1 = name1 + " - " + score1;
    99128                else if (this->bShowScore_)
     
    106135            if (this->bShowRightPlayer_)
    107136            {
    108                 if (this->bShowName_ && this->bShowScore_ && player2)
     137                if (this->bShowName_ && this->bShowScore_ && player2 != NULL)
    109138                    output2 = score2 + " - " + name2;
    110139                else if (this->bShowScore_)
     
    127156    }
    128157
    129 
     158    /**
     159    @brief
     160        Is called when the owner changes.
     161        Sets the owner to NULL, if it is not a pointer to a Pong game.
     162    */
    130163    void PongScore::changedOwner()
    131164    {
    132165        SUPER(PongScore, changedOwner);
    133166
    134         if (this->getOwner() && this->getOwner()->getGametype())
     167        if (this->getOwner() != NULL && this->getOwner()->getGametype())
    135168            this->owner_ = orxonox_cast<Pong*>(this->getOwner()->getGametype().get());
    136169        else
  • code/branches/tetris/src/modules/pong/PongScore.h

    r8106 r8107  
    3939
    4040#include "tools/interfaces/Tickable.h"
     41
    4142#include "overlays/OverlayText.h"
    4243
     
    4546
    4647    /**
    47    
     48    @brief
     49        The PongScore class displays the score for a game of @ref orxonox::Pong "Pong".
     50
     51    @author
     52        Fabian 'x3n' Landau
     53
     54    @ingroup Pong
    4855    */
    4956    class _PongExport PongScore : public OverlayText, public Tickable
     
    5360            virtual ~PongScore();
    5461
    55             virtual void tick(float dt);
     62            virtual void tick(float dt); //!< Creates and sets the caption to be displayed by the PongScore.
    5663            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    57             virtual void changedOwner();
     64            virtual void changedOwner(); //!< Is called when the owner changes.
    5865
     66            /**
     67            @brief Set whether the PongScore displays the players' names.
     68            @param value If true the players' names are displayed.
     69            */
    5970            inline void setShowName(bool value)
    6071                { this->bShowName_ = value; }
     72            /**
     73            @brief Get whether the PongScore displays the players' names.
     74            @return Returns true if the players' names are displayed, false otherwise.
     75            */
    6176            inline bool getShowName() const
    6277                { return this->bShowName_; }
    6378
     79            /**
     80            @brief Set whether the PongScore displays the players' scores.
     81            @param value If true the players' scores are displayed.
     82            */
    6483            inline void setShowScore(bool value)
    6584                { this->bShowScore_ = value; }
     85            /**
     86            @brief Get whether the PongScore displays the players' scores.
     87            @return Returns true if the players' scores are displayed, false otherwise.
     88            */
    6689            inline bool getShowScore() const
    6790                { return this->bShowScore_; }
    6891
     92            /**
     93            @brief Set whether the PongScore displays the left player.
     94            @param value If true the left player is displayed.
     95            */
    6996            inline void setShowLeftPlayer(bool value)
    7097                { this->bShowLeftPlayer_ = value; }
     98            /**
     99            @brief Get whether the PongScore displays the left player.
     100            @return Returns true if the left player is displayed, false otherwise.
     101            */
    71102            inline bool getShowLeftPlayer() const
    72103                { return this->bShowLeftPlayer_; }
    73104
     105            /**
     106            @brief Set whether the PongScore displays the right player.
     107            @param value If true the right player is displayed.
     108            */
    74109            inline void setShowRightPlayer(bool value)
    75110                { this->bShowRightPlayer_ = value; }
     111            /**
     112            @brief Get whether the PongScore displays the right player.
     113            @return Returns true if the right player is displayed, false otherwise.
     114            */
    76115            inline bool getShowRightPlayer() const
    77116                { return this->bShowRightPlayer_; }
    78117
    79118        private:
    80             Pong* owner_;
    81             bool bShowName_;
    82             bool bShowScore_;
    83             bool bShowLeftPlayer_;
    84             bool bShowRightPlayer_;
     119            Pong* owner_; //!< The Pong game that owns this PongScore.
     120            bool bShowName_; //!< Whether the names of the players are shown.
     121            bool bShowScore_; //!< Whether the score of the players is shown.
     122            bool bShowLeftPlayer_; //!< Whether the left player is shown.
     123            bool bShowRightPlayer_; //!< Whether the right player is shown.
    85124    };
    86125}
Note: See TracChangeset for help on using the changeset viewer.