Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 23, 2011, 12:13:34 PM (13 years ago)
Author:
dafrick
Message:

More documentation for Pong.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/tetris/src/modules/pong/PongCenterpoint.h

    r5929 r8105  
    2727 */
    2828
     29/**
     30    @file PongCenterpoint.h
     31    @brief Declaration of the PongCenterpoint class.
     32    @ingroup Pong
     33*/
     34
    2935#ifndef _PongCenterpoint_H__
    3036#define _PongCenterpoint_H__
     
    3339
    3440#include <string>
     41
    3542#include <util/Math.h>
     43
    3644#include "worldentities/StaticEntity.h"
    3745
    3846namespace orxonox
    3947{
     48   
     49    /**
     50    @brief
     51        The PongCenterpoint implements the playing field @ref orxonox::Pong "Pong" takes place in and allows for many parameters of the minigame to be set.
     52        The playing field resides in the x,z-plane, with the x-axis being the horizontal axis and the z-axis being the vertical axis.
     53       
     54        Various parameters can be set:
     55        - The <b>dimension</b> is a vector, that defines the width and height of the playing field. The default is <em>(200, 120)</em>.
     56        - The <b>balltemplate</b> is a template that is applied to the @ref orxonox::PongBall "PongBall", it can be used to attach different things to it, e.g. its @ref orxonox::Model "Model". See below for a usage example.
     57        - The <b>battemplate</b> is a template that is applied to the @ref orxonox::PongBall "PongBat", it can be used to attach different things to it, e.g. its @ref orxonox::Model "Model". See below for a usage example.
     58        - The <b>ballspeed</b> is the speed with wich the @ref orxonox::PongBall "PongBall" moves. The default is <em>100</em>.
     59        - The <b>ballaccfactor</b> is the acceleration factor for the @ref orxonox::PongBall "PongBall". The default is <em>1.0</em>.
     60        - The <b>batspeed</b> is the speed with which the @ref orxonox::PongBat "PongBats" move. The default is <em>60</em>.
     61        - The <b>batlength</b> is the length of the @ref orxonox::PongBat "PongBats" as the percentage of the height of the playing field. The default is <em>0.25</em>.
     62       
     63        An example in XML of the PongCenterpoint would be:
     64       
     65        First the needed templates:
     66        The template for the @ref orxonox::PongBall "PongBall".
     67        @code
     68        <Template name="pongball">
     69          <PongBall>
     70            <attached>
     71              <Model mesh="sphere.mesh" scale="2" />
     72              <ParticleSpawner name="hiteffect" position="0,0,0" source="Orxonox/sparks2" lifetime="0.01" autostart="0" mainstate="spawn" />
     73            </attached>
     74            <eventlisteners>
     75              <EventTarget target="hiteffect" />
     76            </eventlisteners>
     77          </PongBall>
     78        </Template>
     79        @endcode
     80        As can be seen, a sphere is attached as the @ref orxonox::Model "Model" for the @ref orxonox::PongBall "PongBall", and also an @ref orxonox::EventListener "EventListener" that triggers a @ref orxonox::ParticleSpawner "ParticleSpawner", whenever the ball hits the boundaries is attached.
     81       
     82        Additionally the template for the @ref orxonox::PongBat "PongBat".
     83        @code
     84        <Template name="pongbatcameras" defaults="0">
     85          <PongBat>
     86            <camerapositions>
     87              <CameraPosition position="0,200,0" pitch="-90" absolute="true" />
     88            </camerapositions>
     89          </PongBat>
     90        </Template>
     91
     92        <Template name="pongbat">
     93          <PongBat camerapositiontemplate=pongbatcameras>
     94            <attached>
     95              <Model position="0,0,3" mesh="cube.mesh" scale3D="14,2,2" />
     96            </attached>
     97          </PongBat>
     98        </Template>
     99        @endcode
     100        As can be seen, there are actually two templates. The first template is needed to set the camera for the @ref orxonox::PongBat "PongBat". The second template ist the actual template for the @ref orxonox::PongBat "PongBat", the template for the camera position is added and a @ref orxonox::Model "Model" for the @ref orxonox::PongBat "PongBat" is attached.
     101       
     102        Finally the PongCenterpoint is created.
     103        @code
     104        <PongCenterpoint name="pongcenter" dimension="200,120" balltemplate="pongball" battemplate="pongbat" ballspeed="200" ballaccfactor="1.0" batspeed="130" batlength="0.25">
     105          <attached>
     106            <Model position="0,0,60" mesh="cube.mesh" scale3D="105,1,1" />
     107            <Model position="0,0,-60" mesh="cube.mesh" scale3D="105,1,1" />
     108          </attached>
     109        </PongCenterpoint>
     110        @endcode
     111        All parameters are specified. And also two @ref orxonox::Model "Models" (for the upper and lower boundary) are attached.
     112       
     113        For a more elaborate example, have a look at the <code>pong.oxw</code> level file.
     114   
     115    @author
     116        Fabian 'x3n' Landau
     117       
     118    @ingroup Pong
     119    */
    40120    class _PongExport PongCenterpoint : public StaticEntity
    41121    {
    42122        public:
    43             PongCenterpoint(BaseObject* creator);
     123            PongCenterpoint(BaseObject* creator); //!< Constructor. Registers and initializes the object and checks whether the gametype is actually Pong.
    44124            virtual ~PongCenterpoint() {}
    45125
    46             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    47 
    48             virtual void changedGametype();
    49 
     126            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method to create a PongCenterpoint through XML.
     127
     128            virtual void changedGametype(); //!< Is called when the gametype has changed.
     129
     130            /**
     131            @brief Set the template for the ball. (e.g. to attach the model of the ball, but also to attach an EventListener to it to detect, when it hits the boundaries, and e.g. display some ParticleEffets, when it does.)
     132            @param balltemplate The name of the template to be set.
     133            */
    50134            void setBalltemplate(const std::string& balltemplate)
    51135                { this->balltemplate_ = balltemplate; }
     136            /**
     137            @brief Get the template of the ball.
     138            @return Returns the name of the template of the ball.
     139            */
    52140            const std::string& getBalltemplate() const
    53141                { return this->balltemplate_; }
    54142
     143            /**
     144            @brief Set the template for the bats. (e.g. to attach the model of the bat, but also to attach CameraPositions to it, to be able to view the game from the bats perspective)
     145            @param battemplate The name of the template to be set.
     146            */
    55147            void setBattemplate(const std::string& battemplate)
    56148                { this->battemplate_ = battemplate; }
     149            /**
     150            @brief Get the template of the bats.
     151            @return Returns the name of the template of the bats.
     152            */
    57153            const std::string& getBattemplate() const
    58154                { return this->battemplate_; }
    59155
     156            /**
     157            @brief Set the dimensions of the playing field.
     158            @param dimension A vector with the width of the playing field as first component and the height as second.
     159            */
    60160            void setFieldDimension(const Vector2& dimension)
    61161                { this->width_ = dimension.x; this->height_ = dimension.y; }
     162            /**
     163            @brief Get the dimensions of the playing field.
     164            @return Returns a vector with the width of the playing field as first component and the height as second.
     165            */
    62166            Vector2 getFieldDimension() const
    63167                { return Vector2(this->width_, this->height_); }
    64168
     169            /**
     170            @brief Set the speed of the ball.
     171            @param ballspeed The speed of the ball.
     172            */
    65173            void setBallSpeed(float ballspeed)
    66174                { this->ballspeed_ = ballspeed; }
     175            /**
     176            @brief Get the speed of the ball.
     177            @return Returns the speed of the ball.
     178            */
    67179            float getBallSpeed() const
    68180                { return this->ballspeed_; }
    69181
     182            /**
     183            @brief Set the ball's acceleration factor.
     184            @param ballaccfactor The ball's acceleration factor.
     185            */
    70186            void setBallAccelerationFactor(float ballaccfactor)
    71187                { this->ballaccfactor_ = ballaccfactor; }
     188            /**
     189            @brief Get the ball's acceleration factor
     190            @return Returns the ball's acceleration factor.
     191            */
    72192            float getBallAccelerationFactor() const
    73193                { return this->ballaccfactor_; }
    74194
     195            /**
     196            @brief Set the speed of the bats.
     197            @param batspeed The speed of the bats.
     198            */
    75199            void setBatSpeed(float batspeed)
    76200                { this->batspeed_ = batspeed; }
     201            /**
     202            @brief Get the speed of the bats.
     203            @return Returns the speed of the bats.
     204            */
    77205            float getBatSpeed() const
    78206                { return this->batspeed_; }
    79207
     208            /**
     209            @brief Set the length of the bats.
     210            @param batlength The length of the bats (in z-direction) as a percentage of the height of the playing field.
     211            */
    80212            void setBatLength(float batlength)
    81213                { this->batlength_ = batlength; }
     214            /**
     215            @brief Get the length of the bats.
     216            @return Returns the length of the bats (in z-direction) as a percentage of the height of the playing field.
     217            */
    82218            float getBatLength() const
    83219                { return this->batlength_; }
    84220
    85221        private:
    86             void checkGametype();
    87 
    88             std::string balltemplate_;
    89             std::string battemplate_;
    90 
    91             float ballspeed_;
    92             float ballaccfactor_;
    93             float batspeed_;
    94             float batlength_;
    95 
    96             float width_;
    97             float height_;
     222            void checkGametype(); //!< Checks whether the gametype is Pong and if it is, sets its centerpoint.
     223
     224            std::string balltemplate_; //!< The template for the ball.
     225            std::string battemplate_; //!< The template for the batts.
     226
     227            float ballspeed_; //!< The speed of then ball.
     228            float ballaccfactor_; //!< The acceleration factor of the ball.
     229            float batspeed_; //!< The speed of the bat.
     230            float batlength_; //!< The length of the bat (in z-direction) as a percentage of the height of the playing field.
     231
     232            float width_; //!< The height of the playing field.
     233            float height_; //!< The width of the playing field.
    98234    };
    99235}
Note: See TracChangeset for help on using the changeset viewer.