Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 5, 2014, 4:06:09 PM (9 years ago)
Author:
fvultier
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/pickupsFS14/src/modules/jump/JumpFigure.cc

    r10074 r10111  
    2121 *
    2222 *   Author:
    23  *      Fabian 'x3n' Landau
     23 *      Fabien Vultier
    2424 *   Co-authors:
    2525 *      ...
     
    2929/**
    3030    @file JumpFigure.cc
    31     @brief Implementation of the JumpFigure class.
     31    @brief This class represents your figure when you play the minigame. Here the movement of the figure, activating items, ... are handled.
    3232*/
    3333
     
    4141    RegisterClass(JumpFigure);
    4242
    43     /**
    44     @brief
    45         Constructor. Registers and initializes the object.
    46     */
    4743    JumpFigure::JumpFigure(Context* context) : ControllableEntity(context)
    4844    {
    4945        RegisterObject(JumpFigure);
    5046
     47                // initialize variables
    5148        leftHand_ = NULL;
    5249        rightHand_ = NULL;
    53 
    5450        fieldHeight_ = 0;
    5551        fieldWidth_ = 0;
    56 
    5752        jumpSpeed_ = 0.0;
    5853        handSpeed_ = 0.0;
     
    6257        propellerPos_ = 0.0;
    6358        bootsPos_ = 0.0;
    64 
    65         moveUpPressed = false;
    66         moveDownPressed = false;
    67         moveLeftPressed = false;
    68         moveDownPressed = false;
    69         firePressed = false;
    70         fireSignal = false;
    71         timeSinceLastFire = 0.0;
    72 
    73         gravityAcceleration = 8.0;
     59        moveUpPressed_ = false;
     60        moveDownPressed_ = false;
     61        moveLeftPressed_ = false;
     62        moveDownPressed_ = false;
     63        firePressed_ = false;
     64        fireSignal_ = false;
     65        timeSinceLastFire_ = 0.0;
     66        gravityAcceleration_ = 8.0;
    7467        mouseFactor_ = 75.0;
    75         maxFireRate = 0.3;
    76 
     68        maxFireRate_ = 0.3;
    7769        handAngle_ = 0.0;
    7870        animateHands_ = false;
    7971        turnUp_ = false;
    80 
    8172        rocketActive_ = false;
    8273        propellerActive_ = false;
     
    8576        rocketSpeed_ = 0.0;
    8677        propellerSpeed_ = 0.0;
    87 
    8878        dead_ = false;
    8979    }
    9080
    91     /**
    92     @brief
    93         Method to create a JumpCenterpoint through XML.
    94     */
    9581    void JumpFigure::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    9682    {
     
    11096    }
    11197
    112     /**
    113     @brief
    114         Is called each tick.
    115         Moves the bat.
    116     @param dt
    117         The time since last tick.
    118     */
    11998    void JumpFigure::tick(float dt)
    12099    {
    121100        SUPER(JumpFigure, tick, dt);
    122101
    123         // If the bat is controlled (but not over the network).
    124102        if (hasLocalController())
    125103        {
    126                 timeSinceLastFire += dt;
     104                timeSinceLastFire_ += dt;
    127105
    128106                // Move up/down
     
    138116                else
    139117                {
    140                         velocity.z -= gravityAcceleration;
     118                        velocity.z -= gravityAcceleration_;
    141119                }
    142120
     
    174152                if (dead_ == false)
    175153                {
    176                         velocity.x = -mouseFactor_*horizontalSpeed;
     154                        velocity.x = -mouseFactor_*horizontalSpeed_;
    177155                }
    178156                else
     
    182160
    183161                // Cheats
    184                 if (moveUpPressed == true)
    185                 {
    186                         velocity.z = 200.0f;
    187                         moveUpPressed = false;
     162                /*if (moveUpPressed_ == true)
     163                {
     164                        velocity.z = 400.0f;
     165                        moveUpPressed_ = false;
    188166                        dead_ = false;
    189167                }
    190                 if (moveDownPressed == true)
    191                 {
    192                         moveDownPressed = false;
    193                 }
     168                if (moveDownPressed_ == true)
     169                {
     170                        moveDownPressed_ = false;
     171                }*/
    194172
    195173                setVelocity(velocity);
    196174
    197175
    198                 if (firePressed && timeSinceLastFire >= maxFireRate)
    199                 {
    200                                 firePressed = false;
    201                                 timeSinceLastFire = 0.0;
    202                                 fireSignal = true;
    203                                 //orxout() << "fired signal set" << endl;
     176                if (firePressed_ && timeSinceLastFire_ >= maxFireRate_)
     177                {
     178                                firePressed_ = false;
     179                                timeSinceLastFire_ = 0.0;
     180                                fireSignal_ = true;
    204181                }
    205182        }
     
    218195
    219196        // Reset key variables
    220         moveUpPressed = false;
    221         moveDownPressed = false;
    222         moveLeftPressed = false;
    223         moveDownPressed = false;
    224         firePressed = false;
     197        moveUpPressed_ = false;
     198        moveDownPressed_ = false;
     199        moveLeftPressed_ = false;
     200        moveDownPressed_ = false;
     201        firePressed_ = false;
    225202    }
    226203
     
    365342    }
    366343
    367     /**
    368     @briefhandPosition_
    369         Overloaded the function to steer the bat up and down.
    370     @param value
    371         A vector whose first component is the inverse direction in which we want to steer the bat.
    372     */
    373344    void JumpFigure::moveFrontBack(const Vector2& value)
    374345    {
    375346        if (value.x > 0)
    376347        {
    377                 //orxout() << "up pressed" << endl;
    378                 moveUpPressed = true;
    379                 moveDownPressed = false;
     348                moveUpPressed_ = true;
     349                moveDownPressed_ = false;
    380350        }
    381351        else
    382352        {
    383                 //orxout() << "down pressed" << endl;
    384                 moveUpPressed = false;
    385                 moveDownPressed = true;
    386         }
    387     }
    388 
    389     /**
    390     @brief
    391         Overloaded the function to steer the bat up and down.
    392     @param value
    393         A vector whose first component is the direction in which we wnat to steer the bat.
    394     */
     353                moveUpPressed_ = false;
     354                moveDownPressed_ = true;
     355        }
     356    }
     357
    395358    void JumpFigure::moveRightLeft(const Vector2& value)
    396359    {
    397360        if (value.x > 0)
    398361        {
    399                 moveLeftPressed = false;
    400                 moveRightPressed = true;
     362                moveLeftPressed_ = false;
     363                moveRightPressed_ = true;
    401364        }
    402365        else
    403366        {
    404                 moveLeftPressed = true;
    405                 moveRightPressed = false;
     367                moveLeftPressed_ = true;
     368                moveRightPressed_ = false;
    406369        }
    407370    }
     
    409372    void JumpFigure::rotateYaw(const Vector2& value)
    410373    {
    411         horizontalSpeed = value.x;
     374        horizontalSpeed_ = value.x;
    412375    }
    413376
     
    426389    void JumpFigure::fire(unsigned int firemode)
    427390    {
    428         //SUPER(JumpFigure, fire, firemode);
     391
    429392    }
    430393
    431394    void JumpFigure::fired(unsigned int firemode)
    432395    {
    433         //SUPER(JumpFigure, fired, firemode);
    434         firePressed = true;
     396        firePressed_ = true;
    435397    }
    436398}
Note: See TracChangeset for help on using the changeset viewer.