Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 31, 2015, 5:31:23 PM (9 years ago)
Author:
landauf
Message:

replaced tabs with spaces. no changes in code.

File:
1 edited

Legend:

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

    r10078 r10215  
    4545        RegisterObject(JumpFigure);
    4646
    47                 // initialize variables
     47        // initialize variables
    4848        leftHand_ = NULL;
    4949        rightHand_ = NULL;
     
    9898    void JumpFigure::tick(float dt)
    9999    {
    100         SUPER(JumpFigure, tick, dt);
     100        SUPER(JumpFigure, tick, dt);
    101101
    102102        if (hasLocalController())
    103103        {
    104                 timeSinceLastFire_ += dt;
    105 
    106                 // Move up/down
    107                 Vector3 velocity = getVelocity();
    108                 if (rocketActive_ == true)
    109                 {
    110                         velocity.z = rocketSpeed_;
    111                 }
    112                 else if (propellerActive_ == true)
    113                 {
    114                         velocity.z = propellerSpeed_;
    115                 }
    116                 else
    117                 {
    118                         velocity.z -= gravityAcceleration_;
    119                 }
    120 
    121                 // Animate Hands
    122                 if (animateHands_ == true)
    123                 {
    124                         if (turnUp_ == true)
    125                         {
    126                                 handAngle_ += handSpeed_ * dt;
    127                         }
    128                         else
    129                                 {
    130                                         handAngle_ -= handSpeed_ * dt;
    131                                 }
    132                 if (handAngle_ > handMaxAngle_)
    133                 {
    134                         turnUp_ = false;
    135                 }
    136                 if (handAngle_ <= handMinAngle_)
    137                 {
    138                         animateHands_ = false;
    139                 }
    140 
    141                                 if (leftHand_ != NULL)
    142                                 {
    143                                         leftHand_->setOrientation(Vector3(0.0, 1.0, 0.0), Degree(-handAngle_));
    144                                 }
    145                                 if (rightHand_ != NULL)
    146                                 {
    147                                         rightHand_->setOrientation(Vector3(0.0, 1.0, 0.0), Degree(handAngle_));
    148                                 }
    149                 }
    150 
    151                 // Move left/right
    152                 if (dead_ == false)
    153                 {
    154                         velocity.x = -mouseFactor_*horizontalSpeed_;
    155                 }
    156                 else
    157                 {
    158                         velocity.x = 0.0;
    159                 }
    160 
    161                 // Cheats
    162                 /*if (moveUpPressed_ == true)
    163                 {
    164                         velocity.z = 400.0f;
    165                         moveUpPressed_ = false;
    166                         dead_ = false;
    167                 }
    168                 if (moveDownPressed_ == true)
    169                 {
    170                         moveDownPressed_ = false;
    171                 }*/
    172 
    173                 setVelocity(velocity);
    174 
    175 
    176                 if (firePressed_ && timeSinceLastFire_ >= maxFireRate_)
    177                 {
    178                                 firePressed_ = false;
    179                                 timeSinceLastFire_ = 0.0;
    180                                 fireSignal_ = true;
    181                 }
     104            timeSinceLastFire_ += dt;
     105
     106            // Move up/down
     107            Vector3 velocity = getVelocity();
     108            if (rocketActive_ == true)
     109            {
     110                velocity.z = rocketSpeed_;
     111            }
     112            else if (propellerActive_ == true)
     113            {
     114                velocity.z = propellerSpeed_;
     115            }
     116            else
     117            {
     118                velocity.z -= gravityAcceleration_;
     119            }
     120
     121            // Animate Hands
     122            if (animateHands_ == true)
     123            {
     124                if (turnUp_ == true)
     125                {
     126                    handAngle_ += handSpeed_ * dt;
     127                }
     128                else
     129                {
     130                    handAngle_ -= handSpeed_ * dt;
     131                }
     132                if (handAngle_ > handMaxAngle_)
     133                {
     134                    turnUp_ = false;
     135                }
     136                if (handAngle_ <= handMinAngle_)
     137                {
     138                    animateHands_ = false;
     139                }
     140
     141                if (leftHand_ != NULL)
     142                {
     143                    leftHand_->setOrientation(Vector3(0.0, 1.0, 0.0), Degree(-handAngle_));
     144                }
     145                if (rightHand_ != NULL)
     146                {
     147                    rightHand_->setOrientation(Vector3(0.0, 1.0, 0.0), Degree(handAngle_));
     148                }
     149            }
     150
     151            // Move left/right
     152            if (dead_ == false)
     153            {
     154                velocity.x = -mouseFactor_*horizontalSpeed_;
     155            }
     156            else
     157            {
     158                velocity.x = 0.0;
     159            }
     160
     161            // Cheats
     162            /*if (moveUpPressed_ == true)
     163            {
     164                velocity.z = 400.0f;
     165                moveUpPressed_ = false;
     166                dead_ = false;
     167            }
     168            if (moveDownPressed_ == true)
     169            {
     170                moveDownPressed_ = false;
     171            }*/
     172
     173            setVelocity(velocity);
     174
     175
     176            if (firePressed_ && timeSinceLastFire_ >= maxFireRate_)
     177            {
     178                firePressed_ = false;
     179                timeSinceLastFire_ = 0.0;
     180                fireSignal_ = true;
     181            }
    182182        }
    183183
     
    186186        if (position.x < -fieldWidth_*1.1)
    187187        {
    188                 position.x = fieldWidth_*1.1;
     188            position.x = fieldWidth_*1.1;
    189189        }
    190190        else if (position.x > fieldWidth_*1.1)
    191191        {
    192                 position.x = -fieldWidth_*1.1;
     192            position.x = -fieldWidth_*1.1;
    193193        }
    194194        setPosition(position);
     
    204204    void JumpFigure::JumpFromPlatform(JumpPlatform* platform)
    205205    {
    206         if (dead_ == false)
    207         {
    208                 Vector3 velocity = getVelocity();
    209                 velocity.z = (bootsActive_ ? 1.2*jumpSpeed_ : jumpSpeed_);
    210                 setVelocity(velocity);
    211 
    212                 animateHands_ = true;
    213                 handAngle_ = 0.0;
    214                 turnUp_ = true;
    215         }
     206        if (dead_ == false)
     207        {
     208            Vector3 velocity = getVelocity();
     209            velocity.z = (bootsActive_ ? 1.2*jumpSpeed_ : jumpSpeed_);
     210            setVelocity(velocity);
     211
     212            animateHands_ = true;
     213            handAngle_ = 0.0;
     214            turnUp_ = true;
     215        }
    216216    }
    217217
    218218    void JumpFigure::JumpFromSpring(JumpSpring* spring)
    219219    {
    220         if (dead_ == false)
    221         {
    222                 Vector3 velocity = getVelocity();
    223                 velocity.z = 1.2*jumpSpeed_;
    224                 setVelocity(velocity);
    225         }
     220        if (dead_ == false)
     221        {
     222            Vector3 velocity = getVelocity();
     223            velocity.z = 1.2*jumpSpeed_;
     224            setVelocity(velocity);
     225        }
    226226    }
    227227
    228228    void JumpFigure::CollisionWithEnemy(JumpEnemy* enemy)
    229         {
    230         if (rocketActive_ == false && propellerActive_ == false && shieldActive_ == false)
    231                 {
    232                         dead_ = true;
    233                 }
    234         }
     229    {
     230        if (rocketActive_ == false && propellerActive_ == false && shieldActive_ == false)
     231        {
     232            dead_ = true;
     233        }
     234    }
    235235
    236236    bool JumpFigure::StartRocket(JumpRocket* rocket)
    237237    {
    238         if (rocketActive_ == false && propellerActive_ == false && bootsActive_ == false)
    239         {
    240                 attach(rocket);
    241                 rocket->setPosition(0.0, rocketPos_, 0.0);
    242                 rocket->setVelocity(0.0, 0.0, 0.0);
    243                 rocketActive_ = true;
    244 
    245                 return true;
    246         }
    247 
    248         return false;
     238        if (rocketActive_ == false && propellerActive_ == false && bootsActive_ == false)
     239        {
     240            attach(rocket);
     241            rocket->setPosition(0.0, rocketPos_, 0.0);
     242            rocket->setVelocity(0.0, 0.0, 0.0);
     243            rocketActive_ = true;
     244
     245            return true;
     246        }
     247
     248        return false;
    249249    }
    250250
    251251    void JumpFigure::StopRocket(JumpRocket* rocket)
    252252    {
    253                 rocket->setPosition(0.0, 0.0, -1000.0);
    254         rocket->setVelocity(0.0, 0.0, 0.0);
    255         detach(rocket);
    256                 rocket->destroy();
    257                 rocketActive_ = false;
     253        rocket->setPosition(0.0, 0.0, -1000.0);
     254        rocket->setVelocity(0.0, 0.0, 0.0);
     255        detach(rocket);
     256        rocket->destroy();
     257        rocketActive_ = false;
    258258    }
    259259
    260260    bool JumpFigure::StartPropeller(JumpPropeller* propeller)
    261261    {
    262         if (rocketActive_ == false && propellerActive_ == false && bootsActive_ == false)
    263         {
    264                 attach(propeller);
    265                 propeller->setPosition(0.0, 0.0, propellerPos_);
    266                 propeller->setVelocity(0.0, 0.0, 0.0);
    267                 propellerActive_ = true;
    268 
    269                 return true;
    270         }
    271 
    272         return false;
     262        if (rocketActive_ == false && propellerActive_ == false && bootsActive_ == false)
     263        {
     264            attach(propeller);
     265            propeller->setPosition(0.0, 0.0, propellerPos_);
     266            propeller->setVelocity(0.0, 0.0, 0.0);
     267            propellerActive_ = true;
     268
     269            return true;
     270        }
     271
     272        return false;
    273273    }
    274274
    275275    void JumpFigure::StopPropeller(JumpPropeller* propeller)
    276276    {
    277         propeller->setPosition(0.0, 0.0, -1000.0);
    278         propeller->setVelocity(0.0, 0.0, 0.0);
    279         detach(propeller);
    280         propeller->destroy();
    281         propellerActive_ = false;
     277        propeller->setPosition(0.0, 0.0, -1000.0);
     278        propeller->setVelocity(0.0, 0.0, 0.0);
     279        detach(propeller);
     280        propeller->destroy();
     281        propellerActive_ = false;
    282282    }
    283283
    284284    bool JumpFigure::StartBoots(JumpBoots* boots)
    285285    {
    286         if (rocketActive_ == false && propellerActive_ == false && bootsActive_ == false)
    287         {
    288                 attach(boots);
    289                 boots->setPosition(0.0, 0.0, bootsPos_);
    290                 boots->setVelocity(0.0, 0.0, 0.0);
    291                 bootsActive_ = true;
    292 
    293                 return true;
    294         }
    295 
    296         return false;
     286        if (rocketActive_ == false && propellerActive_ == false && bootsActive_ == false)
     287        {
     288            attach(boots);
     289            boots->setPosition(0.0, 0.0, bootsPos_);
     290            boots->setVelocity(0.0, 0.0, 0.0);
     291            bootsActive_ = true;
     292
     293            return true;
     294        }
     295
     296        return false;
    297297    }
    298298
    299299    void JumpFigure::StopBoots(JumpBoots* boots)
    300300    {
    301         boots->setPosition(0.0, 0.0, -1000.0);
    302         boots->setVelocity(0.0, 0.0, 0.0);
    303         detach(boots);
    304         boots->destroy();
    305         bootsActive_ = false;
     301        boots->setPosition(0.0, 0.0, -1000.0);
     302        boots->setVelocity(0.0, 0.0, 0.0);
     303        detach(boots);
     304        boots->destroy();
     305        bootsActive_ = false;
    306306    }
    307307
    308308    bool JumpFigure::StartShield(JumpShield* shield)
    309309    {
    310         if (shieldActive_ == false)
    311         {
    312                 attach(shield);
    313                 shield->setPosition(0.0, 0.0, propellerPos_);
    314                 shield->setVelocity(0.0, 0.0, 0.0);
    315                 shieldActive_ = true;
    316 
    317                 return true;
    318         }
    319 
    320         return false;
     310        if (shieldActive_ == false)
     311        {
     312            attach(shield);
     313            shield->setPosition(0.0, 0.0, propellerPos_);
     314            shield->setVelocity(0.0, 0.0, 0.0);
     315            shieldActive_ = true;
     316
     317            return true;
     318        }
     319
     320        return false;
    321321    }
    322322
    323323    void JumpFigure::StopShield(JumpShield* shield)
    324324    {
    325         shield->setPosition(0.0, 0.0, -1000.0);
    326         shield->setVelocity(0.0, 0.0, 0.0);
    327         detach(shield);
    328         shield->destroy();
    329         shieldActive_ = false;
     325        shield->setPosition(0.0, 0.0, -1000.0);
     326        shield->setVelocity(0.0, 0.0, 0.0);
     327        detach(shield);
     328        shield->destroy();
     329        shieldActive_ = false;
    330330    }
    331331
    332332    void JumpFigure::InitializeAnimation(Context* context)
    333333    {
    334         leftHand_ = new Model(context);
    335         rightHand_ = new Model(context);
    336 
    337         leftHand_->addTemplate(modelLeftHand_);
    338         rightHand_->addTemplate(modelRightHand_);
    339 
    340                 attach(leftHand_);
    341                 attach(rightHand_);
     334        leftHand_ = new Model(context);
     335        rightHand_ = new Model(context);
     336
     337        leftHand_->addTemplate(modelLeftHand_);
     338        rightHand_->addTemplate(modelRightHand_);
     339
     340        attach(leftHand_);
     341        attach(rightHand_);
    342342    }
    343343
    344344    void JumpFigure::moveFrontBack(const Vector2& value)
    345345    {
    346         if (value.x > 0)
    347         {
    348                 moveUpPressed_ = true;
    349                 moveDownPressed_ = false;
    350         }
    351         else
    352         {
    353                 moveUpPressed_ = false;
    354                 moveDownPressed_ = true;
    355         }
     346        if (value.x > 0)
     347        {
     348            moveUpPressed_ = true;
     349            moveDownPressed_ = false;
     350        }
     351        else
     352        {
     353            moveUpPressed_ = false;
     354            moveDownPressed_ = true;
     355        }
    356356    }
    357357
    358358    void JumpFigure::moveRightLeft(const Vector2& value)
    359359    {
    360         if (value.x > 0)
    361         {
    362                 moveLeftPressed_ = false;
    363                 moveRightPressed_ = true;
    364         }
    365         else
    366         {
    367                 moveLeftPressed_ = true;
    368                 moveRightPressed_ = false;
    369         }
     360        if (value.x > 0)
     361        {
     362            moveLeftPressed_ = false;
     363            moveRightPressed_ = true;
     364        }
     365        else
     366        {
     367            moveLeftPressed_ = true;
     368            moveRightPressed_ = false;
     369        }
    370370    }
    371371
    372372    void JumpFigure::rotateYaw(const Vector2& value)
    373373    {
    374         horizontalSpeed_ = value.x;
     374        horizontalSpeed_ = value.x;
    375375    }
    376376
     
    394394    void JumpFigure::fired(unsigned int firemode)
    395395    {
    396         firePressed_ = true;
     396        firePressed_ = true;
    397397    }
    398398}
Note: See TracChangeset for help on using the changeset viewer.