Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Merging changes from tetris branch into trunk, since they are also useful, there.

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/modules/pong/PongBat.cc

    r5781 r8108  
    2727 */
    2828
     29/**
     30    @file PongBat.cc
     31    @brief Implementation of the PongBat class.
     32*/
     33
    2934#include "PongBat.h"
    3035
     
    3641    CreateFactory(PongBat);
    3742
     43    /**
     44    @brief
     45        Constructor. Registers and initializes the object.
     46    */
    3847    PongBat::PongBat(BaseObject* creator) : ControllableEntity(creator)
    3948    {
     
    5059    }
    5160
     61    /**
     62    @brief
     63        Registers variables to be synchronized over the network.
     64    */
    5265    void PongBat::registerVariables()
    5366    {
     
    5770    }
    5871
     72    /**
     73    @brief
     74        Is called each tick.
     75        Moves the bat.
     76    @param dt
     77        The time since last tick.
     78    */
    5979    void PongBat::tick(float dt)
    6080    {
     81        // If the bat is controlled (but not over the network).
    6182        if (this->hasLocalController())
    6283        {
    6384            if (this->movement_ != 0)
    6485            {
     86                // The absolute value of the movement is restricted to be lesser or equal than the speed of the bat.
    6587                this->movement_ = clamp(this->movement_, -1.0f, 1.0f) * this->speed_;
    6688
     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.
    6790                if (this->bMoveLocal_)
    6891                    this->setVelocity(this->getOrientation() * Vector3(this->movement_, 0, 0));
     
    7396                this->bSteadiedPosition_ = false;
    7497            }
     98            // If there is no movement but the position has not been steadied, the velocity is set to zero and the position is reaffirmed.
    7599            else if (!this->bSteadiedPosition_)
    76100            {
     
    84108        SUPER(PongBat, tick, dt);
    85109
     110        // Restrict the position of the bats, for them to always be between the upper and lower delimiters. i.e. the bats stall if they reach the upper or lower boundary.
    86111        Vector3 position = this->getPosition();
    87112        if (position.z > this->fieldHeight_ / 2 - this->fieldHeight_ * this->length_ / 2)
     
    96121    }
    97122
     123    /**
     124    @brief
     125        Overloaded the function to steer the bat up and down.
     126    @param value
     127        A vector whose first component is the inverse direction in which we want to steer the bat.
     128    */
    98129    void PongBat::moveFrontBack(const Vector2& value)
    99130    {
     
    102133    }
    103134
     135    /**
     136    @brief
     137        Overloaded the function to steer the bat up and down.
     138    @param value
     139        A vector whose first component is the direction in which we wnat to steer the bat.
     140    */
    104141    void PongBat::moveRightLeft(const Vector2& value)
    105142    {
     
    108145    }
    109146
     147    /**
     148    @brief
     149        Is called when the player changed.
     150    */
    110151    void PongBat::changedPlayer()
    111152    {
Note: See TracChangeset for help on using the changeset viewer.