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.

Location:
code/branches/presentationFS14/src/modules/jump
Files:
24 edited

Legend:

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

    r10078 r10215  
    8484    void Jump::tick(float dt)
    8585    {
    86         SUPER(Jump, tick, dt);
    87 
    88         if (figure_ != NULL)
    89         {
    90                 Vector3 figurePosition = figure_->getPosition();
    91                 Vector3 figureVelocity = figure_->getVelocity();
    92 
    93                 float boundary = totalScreenShift_+center_->getCameraOffset();
    94 
    95                 if (figurePosition.z > boundary)
    96                 {
    97                         screenShiftSinceLastUpdate_ += figurePosition.z - boundary;
    98                         totalScreenShift_ = figurePosition.z - center_->getCameraOffset();
     86        SUPER(Jump, tick, dt);
     87
     88        if (figure_ != NULL)
     89        {
     90            Vector3 figurePosition = figure_->getPosition();
     91            Vector3 figureVelocity = figure_->getVelocity();
     92
     93            float boundary = totalScreenShift_+center_->getCameraOffset();
     94
     95            if (figurePosition.z > boundary)
     96            {
     97                screenShiftSinceLastUpdate_ += figurePosition.z - boundary;
     98                totalScreenShift_ = figurePosition.z - center_->getCameraOffset();
    9999
    100100                // Create new platforms if needed
    101101                if (screenShiftSinceLastUpdate_ > center_->getSectionLength())
    102102                {
    103                         if (sectionNumber_ > 2 && sectionNumber_%4 == 0 && rand()%2 == 0 && figure_->propellerActive_ == false && figure_->rocketActive_ == false && addAdventure(adventureNumber_) == true)
    104                         {
    105                                 screenShiftSinceLastUpdate_ -= 2*center_->getSectionLength();
    106                                                 ++ adventureNumber_;
    107                         }
    108                         else
    109                         {
    110                                 screenShiftSinceLastUpdate_ -= center_->getSectionLength();
    111                                 addSection();
    112                         }
     103                    if (sectionNumber_ > 2 && sectionNumber_%4 == 0 && rand()%2 == 0 && figure_->propellerActive_ == false && figure_->rocketActive_ == false && addAdventure(adventureNumber_) == true)
     104                    {
     105                        screenShiftSinceLastUpdate_ -= 2*center_->getSectionLength();
     106                        ++ adventureNumber_;
     107                    }
     108                    else
     109                    {
     110                        screenShiftSinceLastUpdate_ -= center_->getSectionLength();
     111                        addSection();
     112                    }
    113113                }
    114                 }
    115 
    116                 if (figurePosition.z < totalScreenShift_ - center_->getFieldDimension().y + platformHeight_ && figureVelocity.z < 0)
    117                 {
    118                         figure_->dead_ = true;
    119                 }
    120 
    121                 if (figure_->fireSignal_ == true)
    122                 {
    123                         if (figure_->dead_ == true)
    124                         {
    125                                 end();
    126                         }
    127                         else
    128                         {
    129                                 figure_->fireSignal_ = false;
    130                                 addProjectile(figurePosition.x, figurePosition.z + figure_->getPropellerPos());
    131                         }
    132                 }
    133 
    134 
    135                 if (camera != NULL)
    136                         {
    137                                 Vector3 cameraPosition = Vector3(0, totalScreenShift_, 0);
    138                                 camera->setPosition(cameraPosition);
    139                         }
    140                         else
    141                         {
    142                                 orxout() << "No camera found." << endl;
    143                         }
    144         }
    145 
    146                 ObjectList<JumpPlatform>::iterator beginPlatform = ObjectList<JumpPlatform>::begin();
    147                 ObjectList<JumpPlatform>::iterator endPlatform = ObjectList<JumpPlatform>::end();
    148                 ObjectList<JumpPlatform>::iterator itPlatform = beginPlatform;
    149                 Vector3 platformPosition;
    150 
    151                 while (itPlatform != endPlatform)
    152                 {
    153                         platformPosition = itPlatform->getPosition();
    154                         if (platformPosition.z < totalScreenShift_ - center_->getFieldDimension().y)
    155                         {
    156                                 ObjectList<JumpPlatform>::iterator temp = itPlatform;
    157                                 ++ itPlatform;
    158                                 center_->detach(*temp);
    159                                 temp->destroy();
    160                         }
    161                         else
    162                         {
    163                                 ++ itPlatform;
    164                         }
    165                 }
    166 
    167                 // Deleted deactivated platforms
    168                 ObjectList<JumpPlatformDisappear>::iterator beginDisappear = ObjectList<JumpPlatformDisappear>::begin();
    169                 ObjectList<JumpPlatformDisappear>::iterator endDisappear = ObjectList<JumpPlatformDisappear>::end();
    170                 ObjectList<JumpPlatformDisappear>::iterator itDisappear = beginDisappear;
    171 
    172                 while (itDisappear != endDisappear)
    173                 {
    174                         if (!itDisappear->isActive())
    175                         {
    176                                 ObjectList<JumpPlatformDisappear>::iterator temp = itDisappear;
    177                                 ++ itDisappear;
    178                                 center_->detach(*temp);
    179                                 temp->destroy();
    180                         }
    181                         else
    182                         {
    183                                 ++ itDisappear;
    184                         }
    185                 }
    186 
    187                 ObjectList<JumpPlatformTimer>::iterator beginTimer = ObjectList<JumpPlatformTimer>::begin();
    188                 ObjectList<JumpPlatformTimer>::iterator endTimer = ObjectList<JumpPlatformTimer>::end();
    189                 ObjectList<JumpPlatformTimer>::iterator itTimer = beginTimer;
    190 
    191                 while (itTimer != endTimer)
    192                 {
    193                         if (!itTimer->isActive())
    194                         {
    195                                 ObjectList<JumpPlatformTimer>::iterator temp = itTimer;
    196                                 ++ itTimer;
    197                                 center_->detach(*temp);
    198                                 temp->destroy();
    199                         }
    200                         else
    201                         {
    202                                 ++ itTimer;
    203                         }
    204                 }
    205 
    206                 ObjectList<JumpProjectile>::iterator beginProjectile = ObjectList<JumpProjectile>::begin();
    207                 ObjectList<JumpProjectile>::iterator endProjectile = ObjectList<JumpProjectile>::end();
    208                 ObjectList<JumpProjectile>::iterator itProjectile = beginProjectile;
    209                 Vector3 projectilePosition;
    210 
    211                 while (itProjectile != endProjectile)
    212                 {
    213                         projectilePosition = itProjectile->getPosition();
    214                         if (projectilePosition.z > totalScreenShift_ + 5*center_->getFieldDimension().y)
    215                         {
    216                                 ObjectList<JumpProjectile>::iterator temp = itProjectile;
    217                                 ++ itProjectile;
    218                                 center_->detach(*temp);
    219                                 temp->destroy();
    220                         }
    221                         else
    222                         {
    223                                 ++ itProjectile;
    224                         }
    225                 }
    226 
    227                 ObjectList<JumpEnemy>::iterator beginEnemy = ObjectList<JumpEnemy>::begin();
    228                 ObjectList<JumpEnemy>::iterator endEnemy = ObjectList<JumpEnemy>::end();
    229                 ObjectList<JumpEnemy>::iterator itEnemy = beginEnemy;
    230                 Vector3 enemyPosition;
    231 
    232                 while (itEnemy != endEnemy)
    233                 {
    234                         enemyPosition = itEnemy->getPosition();
    235                         if (enemyPosition.z < totalScreenShift_ - center_->getFieldDimension().y || itEnemy->dead_ == true)
    236                         {
    237                                 ObjectList<JumpEnemy>::iterator temp = itEnemy;
    238                                 ++ itEnemy;
    239                                 center_->detach(*temp);
    240                                 temp->destroy();
    241                         }
    242                         else
    243                         {
    244                                 ++ itEnemy;
    245                         }
    246                 }
    247 
    248                 ObjectList<JumpItem>::iterator beginItem = ObjectList<JumpItem>::begin();
    249                 ObjectList<JumpItem>::iterator endItem = ObjectList<JumpItem>::end();
    250                 ObjectList<JumpItem>::iterator itItem = beginItem;
    251                 Vector3 itemPosition;
    252 
    253                 while (itItem != endItem)
    254                 {
    255                         itemPosition = itItem->getPosition();
    256 
    257                         WorldEntity* parent = itItem->getParent();
    258 
    259                         if (itItem->attachedToFigure_ == false && itemPosition.z < totalScreenShift_ - center_->getFieldDimension().y && parent == center_)
    260                         {
    261                                 ObjectList<JumpItem>::iterator temp = itItem;
    262                                 ++ itItem;
    263                                 center_->detach(*temp);
    264                                 temp->destroy();
    265                         }
    266                         else
    267                         {
    268                                 ++ itItem;
    269                         }
    270                 }
     114            }
     115
     116            if (figurePosition.z < totalScreenShift_ - center_->getFieldDimension().y + platformHeight_ && figureVelocity.z < 0)
     117            {
     118                figure_->dead_ = true;
     119            }
     120
     121            if (figure_->fireSignal_ == true)
     122            {
     123                if (figure_->dead_ == true)
     124                {
     125                    end();
     126                }
     127                else
     128                {
     129                    figure_->fireSignal_ = false;
     130                    addProjectile(figurePosition.x, figurePosition.z + figure_->getPropellerPos());
     131                }
     132            }
     133
     134
     135            if (camera != NULL)
     136            {
     137                Vector3 cameraPosition = Vector3(0, totalScreenShift_, 0);
     138                camera->setPosition(cameraPosition);
     139            }
     140            else
     141            {
     142                orxout() << "No camera found." << endl;
     143            }
     144        }
     145
     146        ObjectList<JumpPlatform>::iterator beginPlatform = ObjectList<JumpPlatform>::begin();
     147        ObjectList<JumpPlatform>::iterator endPlatform = ObjectList<JumpPlatform>::end();
     148        ObjectList<JumpPlatform>::iterator itPlatform = beginPlatform;
     149        Vector3 platformPosition;
     150
     151        while (itPlatform != endPlatform)
     152        {
     153            platformPosition = itPlatform->getPosition();
     154            if (platformPosition.z < totalScreenShift_ - center_->getFieldDimension().y)
     155            {
     156                ObjectList<JumpPlatform>::iterator temp = itPlatform;
     157                ++ itPlatform;
     158                center_->detach(*temp);
     159                temp->destroy();
     160            }
     161            else
     162            {
     163                ++ itPlatform;
     164            }
     165        }
     166
     167        // Deleted deactivated platforms
     168        ObjectList<JumpPlatformDisappear>::iterator beginDisappear = ObjectList<JumpPlatformDisappear>::begin();
     169        ObjectList<JumpPlatformDisappear>::iterator endDisappear = ObjectList<JumpPlatformDisappear>::end();
     170        ObjectList<JumpPlatformDisappear>::iterator itDisappear = beginDisappear;
     171
     172        while (itDisappear != endDisappear)
     173        {
     174            if (!itDisappear->isActive())
     175            {
     176                ObjectList<JumpPlatformDisappear>::iterator temp = itDisappear;
     177                ++ itDisappear;
     178                center_->detach(*temp);
     179                temp->destroy();
     180            }
     181            else
     182            {
     183                ++ itDisappear;
     184            }
     185        }
     186
     187        ObjectList<JumpPlatformTimer>::iterator beginTimer = ObjectList<JumpPlatformTimer>::begin();
     188        ObjectList<JumpPlatformTimer>::iterator endTimer = ObjectList<JumpPlatformTimer>::end();
     189        ObjectList<JumpPlatformTimer>::iterator itTimer = beginTimer;
     190
     191        while (itTimer != endTimer)
     192        {
     193            if (!itTimer->isActive())
     194            {
     195                ObjectList<JumpPlatformTimer>::iterator temp = itTimer;
     196                ++ itTimer;
     197                center_->detach(*temp);
     198                temp->destroy();
     199            }
     200            else
     201            {
     202                ++ itTimer;
     203            }
     204        }
     205
     206        ObjectList<JumpProjectile>::iterator beginProjectile = ObjectList<JumpProjectile>::begin();
     207        ObjectList<JumpProjectile>::iterator endProjectile = ObjectList<JumpProjectile>::end();
     208        ObjectList<JumpProjectile>::iterator itProjectile = beginProjectile;
     209        Vector3 projectilePosition;
     210
     211        while (itProjectile != endProjectile)
     212        {
     213            projectilePosition = itProjectile->getPosition();
     214            if (projectilePosition.z > totalScreenShift_ + 5*center_->getFieldDimension().y)
     215            {
     216                ObjectList<JumpProjectile>::iterator temp = itProjectile;
     217                ++ itProjectile;
     218                center_->detach(*temp);
     219                temp->destroy();
     220            }
     221            else
     222            {
     223                ++ itProjectile;
     224            }
     225        }
     226
     227        ObjectList<JumpEnemy>::iterator beginEnemy = ObjectList<JumpEnemy>::begin();
     228        ObjectList<JumpEnemy>::iterator endEnemy = ObjectList<JumpEnemy>::end();
     229        ObjectList<JumpEnemy>::iterator itEnemy = beginEnemy;
     230        Vector3 enemyPosition;
     231
     232        while (itEnemy != endEnemy)
     233        {
     234            enemyPosition = itEnemy->getPosition();
     235            if (enemyPosition.z < totalScreenShift_ - center_->getFieldDimension().y || itEnemy->dead_ == true)
     236            {
     237                ObjectList<JumpEnemy>::iterator temp = itEnemy;
     238                ++ itEnemy;
     239                center_->detach(*temp);
     240                temp->destroy();
     241            }
     242            else
     243            {
     244                ++ itEnemy;
     245            }
     246        }
     247
     248        ObjectList<JumpItem>::iterator beginItem = ObjectList<JumpItem>::begin();
     249        ObjectList<JumpItem>::iterator endItem = ObjectList<JumpItem>::end();
     250        ObjectList<JumpItem>::iterator itItem = beginItem;
     251        Vector3 itemPosition;
     252
     253        while (itItem != endItem)
     254        {
     255            itemPosition = itItem->getPosition();
     256
     257            WorldEntity* parent = itItem->getParent();
     258
     259            if (itItem->attachedToFigure_ == false && itemPosition.z < totalScreenShift_ - center_->getFieldDimension().y && parent == center_)
     260            {
     261                ObjectList<JumpItem>::iterator temp = itItem;
     262                ++ itItem;
     263                center_->detach(*temp);
     264                temp->destroy();
     265            }
     266            else
     267            {
     268                ++ itItem;
     269            }
     270        }
    271271    }
    272272
    273273    void Jump::cleanup()
    274274    {
    275                 camera = 0;
     275        camera = 0;
    276276    }
    277277
     
    280280        if (center_ != NULL) // There needs to be a JumpCenterpoint, i.e. the area the game takes place.
    281281        {
    282                         if (figure_ == NULL)
    283                         {
    284                                 figure_ = new JumpFigure(center_->getContext());
    285                                 figure_->addTemplate(center_->getFigureTemplate());
    286                                 figure_->InitializeAnimation(center_->getContext());
    287                         }
     282            if (figure_ == NULL)
     283            {
     284                figure_ = new JumpFigure(center_->getContext());
     285                figure_->addTemplate(center_->getFigureTemplate());
     286                figure_->InitializeAnimation(center_->getContext());
     287            }
    288288
    289289            center_->attach(figure_);
     
    303303        if (figure_ != NULL)
    304304        {
    305                 camera = figure_->getCamera();
     305            camera = figure_->getCamera();
    306306        }
    307307
     
    318318    void Jump::end()
    319319    {
    320         cleanup();
    321         GSLevel::startMainMenu();
     320        cleanup();
     321        GSLevel::startMainMenu();
    322322
    323323        Deathmatch::end();
     
    349349    void Jump::addPlatform(JumpPlatform* newPlatform, std::string platformTemplate, float xPosition, float zPosition)
    350350    {
    351         if (newPlatform != NULL && center_ != NULL)
    352                 {
    353                 newPlatform->addTemplate(platformTemplate);
    354                 newPlatform->setPosition(Vector3(xPosition, 0.0, zPosition));
    355                 newPlatform->setFigure(this->figure_);
    356                 center_->attach(newPlatform);
    357                 }
     351        if (newPlatform != NULL && center_ != NULL)
     352        {
     353            newPlatform->addTemplate(platformTemplate);
     354            newPlatform->setPosition(Vector3(xPosition, 0.0, zPosition));
     355            newPlatform->setFigure(this->figure_);
     356            center_->attach(newPlatform);
     357        }
    358358    }
    359359
    360360    JumpPlatformStatic* Jump::addPlatformStatic(float xPosition, float zPosition)
    361361    {
    362                 JumpPlatformStatic* newPlatform = new JumpPlatformStatic(center_->getContext());
    363                 addPlatform(newPlatform, center_->getPlatformStaticTemplate(), xPosition, zPosition);
    364 
    365                 return newPlatform;
     362        JumpPlatformStatic* newPlatform = new JumpPlatformStatic(center_->getContext());
     363        addPlatform(newPlatform, center_->getPlatformStaticTemplate(), xPosition, zPosition);
     364
     365        return newPlatform;
    366366    }
    367367
    368368    JumpPlatformHMove* Jump::addPlatformHMove(float xPosition, float zPosition, float leftBoundary, float rightBoundary, float speed)
    369369    {
    370         JumpPlatformHMove* newPlatform = new JumpPlatformHMove(center_->getContext());
    371                 newPlatform->setProperties(leftBoundary, rightBoundary, speed);
    372                 addPlatform(newPlatform, center_->getPlatformHMoveTemplate(), xPosition, zPosition);
    373 
    374                 return newPlatform;
     370        JumpPlatformHMove* newPlatform = new JumpPlatformHMove(center_->getContext());
     371        newPlatform->setProperties(leftBoundary, rightBoundary, speed);
     372        addPlatform(newPlatform, center_->getPlatformHMoveTemplate(), xPosition, zPosition);
     373
     374        return newPlatform;
    375375    }
    376376
    377377    JumpPlatformVMove* Jump::addPlatformVMove(float xPosition, float zPosition, float lowerBoundary, float upperBoundary, float speed)
    378378    {
    379         JumpPlatformVMove* newPlatform = new JumpPlatformVMove(center_->getContext());
    380                 newPlatform->setProperties(lowerBoundary, upperBoundary, speed);
    381                 addPlatform(newPlatform, center_->getPlatformVMoveTemplate(), xPosition, zPosition);
    382 
    383                 return newPlatform;
     379        JumpPlatformVMove* newPlatform = new JumpPlatformVMove(center_->getContext());
     380        newPlatform->setProperties(lowerBoundary, upperBoundary, speed);
     381        addPlatform(newPlatform, center_->getPlatformVMoveTemplate(), xPosition, zPosition);
     382
     383        return newPlatform;
    384384    }
    385385
    386386    JumpPlatformDisappear* Jump::addPlatformDisappear(float xPosition, float zPosition)
    387387    {
    388                 JumpPlatformDisappear* newPlatform = new JumpPlatformDisappear(center_->getContext());
    389                 newPlatform->setProperties(true);
    390                 addPlatform(newPlatform, center_->getPlatformDisappearTemplate(), xPosition, zPosition);
    391 
    392                 return newPlatform;
     388        JumpPlatformDisappear* newPlatform = new JumpPlatformDisappear(center_->getContext());
     389        newPlatform->setProperties(true);
     390        addPlatform(newPlatform, center_->getPlatformDisappearTemplate(), xPosition, zPosition);
     391
     392        return newPlatform;
    393393    }
    394394
    395395    JumpPlatformTimer* Jump::addPlatformTimer(float xPosition, float zPosition, float time, float variance)
    396396    {
    397                 float additionalTime = (float)(rand()%100)/(100*variance) - variance/2;
    398 
    399         JumpPlatformTimer* newPlatform = new JumpPlatformTimer(center_->getContext());
    400                 newPlatform->setProperties(time + additionalTime);
    401                 addPlatform(newPlatform, center_->getPlatformTimerTemplate(), xPosition, zPosition);
    402 
    403                 return newPlatform;
     397        float additionalTime = (float)(rand()%100)/(100*variance) - variance/2;
     398
     399        JumpPlatformTimer* newPlatform = new JumpPlatformTimer(center_->getContext());
     400        newPlatform->setProperties(time + additionalTime);
     401        addPlatform(newPlatform, center_->getPlatformTimerTemplate(), xPosition, zPosition);
     402
     403        return newPlatform;
    404404    }
    405405
    406406    JumpPlatformFake* Jump::addPlatformFake(float xPosition, float zPosition)
    407407    {
    408                 JumpPlatformFake* newPlatform = new JumpPlatformFake(center_->getContext());
    409                 addPlatform(newPlatform, center_->getPlatformFakeTemplate(), xPosition, zPosition);
    410                 newPlatform->setAngularVelocity(Vector3(0, 0, 2.0));
    411 
    412                 return newPlatform;
     408        JumpPlatformFake* newPlatform = new JumpPlatformFake(center_->getContext());
     409        addPlatform(newPlatform, center_->getPlatformFakeTemplate(), xPosition, zPosition);
     410        newPlatform->setAngularVelocity(Vector3(0, 0, 2.0));
     411
     412        return newPlatform;
    413413    }
    414414
     
    416416    void Jump::addProjectile(float xPosition, float zPosition)
    417417    {
    418         JumpProjectile* newProjectile = new JumpProjectile(center_->getContext());
    419         if (newProjectile != NULL && center_ != NULL)
    420                 {
    421                 newProjectile->addTemplate(center_->getProjectileTemplate());
    422                 newProjectile->setPosition(Vector3(xPosition, 0.0, zPosition));
    423                 newProjectile->setFieldDimension(center_->getFieldDimension());
    424                 newProjectile->setFigure(this->figure_);
    425                 center_->attach(newProjectile);
    426                 }
     418        JumpProjectile* newProjectile = new JumpProjectile(center_->getContext());
     419        if (newProjectile != NULL && center_ != NULL)
     420        {
     421            newProjectile->addTemplate(center_->getProjectileTemplate());
     422            newProjectile->setPosition(Vector3(xPosition, 0.0, zPosition));
     423            newProjectile->setFieldDimension(center_->getFieldDimension());
     424            newProjectile->setFigure(this->figure_);
     425            center_->attach(newProjectile);
     426        }
    427427    }
    428428
    429429    void Jump::addSpring(float xPosition, float zPosition, float leftBoundary, float rightBoundary, float lowerBoundary, float upperBoundary, float xVelocity, float zVelocity)
    430430    {
    431         JumpSpring* newSpring = new JumpSpring(center_->getContext());
    432         if (newSpring != NULL && center_ != NULL)
    433                 {
    434                 newSpring->addTemplate(center_->getSpringTemplate());
    435                 newSpring->setPosition(Vector3(xPosition, 0.0, zPosition));
    436                 newSpring->setProperties(leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity);
    437                 newSpring->setFigure(figure_);
    438                 center_->attach(newSpring);
    439                 }
     431        JumpSpring* newSpring = new JumpSpring(center_->getContext());
     432        if (newSpring != NULL && center_ != NULL)
     433        {
     434            newSpring->addTemplate(center_->getSpringTemplate());
     435            newSpring->setPosition(Vector3(xPosition, 0.0, zPosition));
     436            newSpring->setProperties(leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity);
     437            newSpring->setFigure(figure_);
     438            center_->attach(newSpring);
     439        }
    440440    }
    441441
    442442    void Jump::addSpring(JumpPlatform* platform)
    443443    {
    444         JumpSpring* newSpring = new JumpSpring(center_->getContext());
    445         if (newSpring != NULL && center_ != NULL)
    446                 {
    447                 newSpring->addTemplate(center_->getSpringTemplate());
    448                 newSpring->setPosition(Vector3(0.0, 0.0, 0.0));
    449                 newSpring->setProperties(-10.0, 10.0, -10.0, 10.0, 0.0, 0.0);
    450                 newSpring->setFigure(figure_);
    451                 platform->attach(newSpring);
    452                 }
     444        JumpSpring* newSpring = new JumpSpring(center_->getContext());
     445        if (newSpring != NULL && center_ != NULL)
     446        {
     447            newSpring->addTemplate(center_->getSpringTemplate());
     448            newSpring->setPosition(Vector3(0.0, 0.0, 0.0));
     449            newSpring->setProperties(-10.0, 10.0, -10.0, 10.0, 0.0, 0.0);
     450            newSpring->setFigure(figure_);
     451            platform->attach(newSpring);
     452        }
    453453    }
    454454
    455455    void Jump::addRocket(float xPosition, float zPosition, float leftBoundary, float rightBoundary, float lowerBoundary, float upperBoundary, float xVelocity, float zVelocity)
    456456    {
    457         JumpRocket* newRocket = new JumpRocket(center_->getContext());
    458         if (newRocket != NULL && center_ != NULL)
    459                 {
    460                 newRocket->addTemplate(center_->getRocketTemplate());
    461                 newRocket->setPosition(Vector3(xPosition, 0.0, zPosition));
    462                 newRocket->setProperties(leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity);
    463                 newRocket->setFigure(figure_);
    464                 center_->attach(newRocket);
    465                 }
     457        JumpRocket* newRocket = new JumpRocket(center_->getContext());
     458        if (newRocket != NULL && center_ != NULL)
     459        {
     460            newRocket->addTemplate(center_->getRocketTemplate());
     461            newRocket->setPosition(Vector3(xPosition, 0.0, zPosition));
     462            newRocket->setProperties(leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity);
     463            newRocket->setFigure(figure_);
     464            center_->attach(newRocket);
     465        }
    466466    }
    467467
    468468    void Jump::addRocket(JumpPlatform* platform)
    469469    {
    470         JumpRocket* newRocket = new JumpRocket(center_->getContext());
    471         if (newRocket != NULL && center_ != NULL)
    472                 {
    473                 newRocket->addTemplate(center_->getRocketTemplate());
    474                 newRocket->setPosition(Vector3(0.0, 0.0, 0.0));
    475                 newRocket->setProperties(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
    476                 newRocket->setFigure(figure_);
    477                 platform->attach(newRocket);
    478                 }
     470        JumpRocket* newRocket = new JumpRocket(center_->getContext());
     471        if (newRocket != NULL && center_ != NULL)
     472        {
     473            newRocket->addTemplate(center_->getRocketTemplate());
     474            newRocket->setPosition(Vector3(0.0, 0.0, 0.0));
     475            newRocket->setProperties(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
     476            newRocket->setFigure(figure_);
     477            platform->attach(newRocket);
     478        }
    479479    }
    480480
    481481    void Jump::addPropeller(float xPosition, float zPosition, float leftBoundary, float rightBoundary, float lowerBoundary, float upperBoundary, float xVelocity, float zVelocity)
    482482    {
    483         JumpPropeller* newPropeller = new JumpPropeller(center_->getContext());
    484         if (newPropeller != NULL && center_ != NULL)
    485                 {
    486                 newPropeller->addTemplate(center_->getPropellerTemplate());
    487                 newPropeller->setPosition(Vector3(xPosition, 0.0, zPosition));
    488                 newPropeller->setProperties(leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity);
    489                 newPropeller->setFigure(figure_);
    490                 center_->attach(newPropeller);
    491                 }
     483        JumpPropeller* newPropeller = new JumpPropeller(center_->getContext());
     484        if (newPropeller != NULL && center_ != NULL)
     485        {
     486            newPropeller->addTemplate(center_->getPropellerTemplate());
     487            newPropeller->setPosition(Vector3(xPosition, 0.0, zPosition));
     488            newPropeller->setProperties(leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity);
     489            newPropeller->setFigure(figure_);
     490            center_->attach(newPropeller);
     491        }
    492492    }
    493493
    494494    void Jump::addPropeller(JumpPlatform* platform)
    495495    {
    496         JumpPropeller* newPropeller = new JumpPropeller(center_->getContext());
    497         if (newPropeller != NULL && center_ != NULL)
    498                 {
    499                 newPropeller->addTemplate(center_->getPropellerTemplate());
    500                 newPropeller->setPosition(Vector3(0.0, 0.0, 0.0));
    501                 newPropeller->setProperties(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
    502                 newPropeller->setFigure(figure_);
    503                 platform->attach(newPropeller);
    504                 }
     496        JumpPropeller* newPropeller = new JumpPropeller(center_->getContext());
     497        if (newPropeller != NULL && center_ != NULL)
     498        {
     499            newPropeller->addTemplate(center_->getPropellerTemplate());
     500            newPropeller->setPosition(Vector3(0.0, 0.0, 0.0));
     501            newPropeller->setProperties(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
     502            newPropeller->setFigure(figure_);
     503            platform->attach(newPropeller);
     504        }
    505505    }
    506506
    507507    void Jump::addBoots(float xPosition, float zPosition, float leftBoundary, float rightBoundary, float lowerBoundary, float upperBoundary, float xVelocity, float zVelocity)
    508508    {
    509         JumpBoots* newBoots = new JumpBoots(center_->getContext());
    510         if (newBoots != NULL && center_ != NULL)
    511                 {
    512                 newBoots->addTemplate(center_->getBootsTemplate());
    513                 newBoots->setPosition(Vector3(xPosition, 0.0, zPosition));
    514                 newBoots->setProperties(leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity);
    515                 newBoots->setFigure(figure_);
    516                 center_->attach(newBoots);
    517                 }
     509        JumpBoots* newBoots = new JumpBoots(center_->getContext());
     510        if (newBoots != NULL && center_ != NULL)
     511        {
     512            newBoots->addTemplate(center_->getBootsTemplate());
     513            newBoots->setPosition(Vector3(xPosition, 0.0, zPosition));
     514            newBoots->setProperties(leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity);
     515            newBoots->setFigure(figure_);
     516            center_->attach(newBoots);
     517        }
    518518    }
    519519
    520520    void Jump::addBoots(JumpPlatform* platform)
    521521    {
    522         JumpBoots* newBoots = new JumpBoots(center_->getContext());
    523         if (newBoots != NULL && center_ != NULL)
    524                 {
    525                 newBoots->addTemplate(center_->getBootsTemplate());
    526                 newBoots->setPosition(Vector3(0.0, 0.0, 0.0));
    527                 newBoots->setProperties(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
    528                 newBoots->setFigure(figure_);
    529                 platform->attach(newBoots);
    530                 }
     522        JumpBoots* newBoots = new JumpBoots(center_->getContext());
     523        if (newBoots != NULL && center_ != NULL)
     524        {
     525            newBoots->addTemplate(center_->getBootsTemplate());
     526            newBoots->setPosition(Vector3(0.0, 0.0, 0.0));
     527            newBoots->setProperties(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
     528            newBoots->setFigure(figure_);
     529            platform->attach(newBoots);
     530        }
    531531    }
    532532
    533533    void Jump::addShield(float xPosition, float zPosition, float leftBoundary, float rightBoundary, float lowerBoundary, float upperBoundary, float xVelocity, float zVelocity)
    534534    {
    535         JumpShield* newShield = new JumpShield(center_->getContext());
    536         if (newShield != NULL && center_ != NULL)
    537                 {
    538                 newShield->addTemplate(center_->getShieldTemplate());
    539                 newShield->setPosition(Vector3(xPosition, 0.0, zPosition));
    540                 newShield->setProperties(leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity);
    541                 newShield->setFigure(figure_);
    542                 center_->attach(newShield);
    543                 }
     535        JumpShield* newShield = new JumpShield(center_->getContext());
     536        if (newShield != NULL && center_ != NULL)
     537        {
     538            newShield->addTemplate(center_->getShieldTemplate());
     539            newShield->setPosition(Vector3(xPosition, 0.0, zPosition));
     540            newShield->setProperties(leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity);
     541            newShield->setFigure(figure_);
     542            center_->attach(newShield);
     543        }
    544544    }
    545545
    546546    void Jump::addShield(JumpPlatform* platform)
    547547    {
    548         JumpShield* newShield = new JumpShield(center_->getContext());
    549         if (newShield != NULL && center_ != NULL)
    550                 {
    551                 newShield->addTemplate(center_->getShieldTemplate());
    552                 newShield->setPosition(Vector3(0.0, 0.0, 0.0));
    553                 newShield->setProperties(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
    554                 newShield->setFigure(figure_);
    555                 platform->attach(newShield);
    556                 }
     548        JumpShield* newShield = new JumpShield(center_->getContext());
     549        if (newShield != NULL && center_ != NULL)
     550        {
     551            newShield->addTemplate(center_->getShieldTemplate());
     552            newShield->setPosition(Vector3(0.0, 0.0, 0.0));
     553            newShield->setProperties(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
     554            newShield->setFigure(figure_);
     555            platform->attach(newShield);
     556        }
    557557    }
    558558
    559559    void Jump::addEnemy(int type, float xPosition, float zPosition, float leftBoundary, float rightBoundary, float lowerBoundary, float upperBoundary, float xVelocity, float zVelocity)
    560560    {
    561         JumpEnemy* newEnemy = new JumpEnemy(center_->getContext());
    562         if (newEnemy != NULL && center_ != NULL)
    563                 {
    564                 switch (type)
    565                 {
    566                 case 1:
    567                         newEnemy->addTemplate(center_->getEnemy1Template());
    568                         break;
    569                 case 2:
    570                         newEnemy->addTemplate(center_->getEnemy2Template());
    571                         break;
    572                 case 3:
    573                         newEnemy->addTemplate(center_->getEnemy3Template());
    574                         break;
    575                 case 4:
    576                         newEnemy->addTemplate(center_->getEnemy4Template());
    577                         break;
    578                 default:
    579                         return;
    580                 }
    581 
    582                 newEnemy->setPosition(Vector3(xPosition, 0.0, zPosition));
    583                 newEnemy->setProperties(leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity);
    584                 newEnemy->setFieldDimension(center_->getFieldDimension());
    585                 newEnemy->setFigure(this->figure_);
    586                 center_->attach(newEnemy);
    587                 }
     561        JumpEnemy* newEnemy = new JumpEnemy(center_->getContext());
     562        if (newEnemy != NULL && center_ != NULL)
     563        {
     564            switch (type)
     565            {
     566            case 1:
     567                newEnemy->addTemplate(center_->getEnemy1Template());
     568                break;
     569            case 2:
     570                newEnemy->addTemplate(center_->getEnemy2Template());
     571                break;
     572            case 3:
     573                newEnemy->addTemplate(center_->getEnemy3Template());
     574                break;
     575            case 4:
     576                newEnemy->addTemplate(center_->getEnemy4Template());
     577                break;
     578            default:
     579                return;
     580            }
     581
     582            newEnemy->setPosition(Vector3(xPosition, 0.0, zPosition));
     583            newEnemy->setProperties(leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity);
     584            newEnemy->setFieldDimension(center_->getFieldDimension());
     585            newEnemy->setFigure(this->figure_);
     586            center_->attach(newEnemy);
     587        }
    588588    }
    589589
    590590    void Jump::addStartSection()
    591591    {
    592                 JumpPlatform* newPlatform;
    593 
    594                 float sectionLength = center_->getSectionLength();
    595 
    596                 newPlatform = new JumpPlatformStatic(center_->getContext());
    597                 addPlatform(newPlatform, center_->getPlatformStaticTemplate(), 0.0, -0.05*sectionLength);
    598 
    599                 platformWidth_ = newPlatform->getWidth();
    600                 platformHeight_ = newPlatform->getHeight();
    601 
    602                 for (float xPosition = platformWidth_; xPosition <= center_->getFieldDimension().x; xPosition += platformWidth_)
    603                 {
    604                         newPlatform = new JumpPlatformStatic(center_->getContext());
    605                         addPlatform(newPlatform, center_->getPlatformStaticTemplate(), xPosition, -0.05*sectionLength);
    606                         newPlatform = new JumpPlatformStatic(center_->getContext());
    607                         addPlatform(newPlatform, center_->getPlatformStaticTemplate(), -xPosition, -0.05*sectionLength);
    608                 }
     592        JumpPlatform* newPlatform;
     593
     594        float sectionLength = center_->getSectionLength();
     595
     596        newPlatform = new JumpPlatformStatic(center_->getContext());
     597        addPlatform(newPlatform, center_->getPlatformStaticTemplate(), 0.0, -0.05*sectionLength);
     598
     599        platformWidth_ = newPlatform->getWidth();
     600        platformHeight_ = newPlatform->getHeight();
     601
     602        for (float xPosition = platformWidth_; xPosition <= center_->getFieldDimension().x; xPosition += platformWidth_)
     603        {
     604            newPlatform = new JumpPlatformStatic(center_->getContext());
     605            addPlatform(newPlatform, center_->getPlatformStaticTemplate(), xPosition, -0.05*sectionLength);
     606            newPlatform = new JumpPlatformStatic(center_->getContext());
     607            addPlatform(newPlatform, center_->getPlatformStaticTemplate(), -xPosition, -0.05*sectionLength);
     608        }
    609609    }
    610610
     
    619619        int numJ = 4;
    620620
    621         enum PlatformType
    622         {
    623                 PLATFORM_EMPTY, PLATFORM_STATIC, PLATFORM_HMOVE, PLATFORM_VMOVE, PLATFORM_DISAPPEAR, PLATFORM_TIMER, PLATFORM_FAKE
    624         };
    625 
    626         enum ItemType
    627         {
    628                 ITEM_NOTHING, ITEM_SPRING, ITEM_PROPELLER, ITEM_ROCKET, ITEM_BOOTS, ITEM_SHIELD
    629         };
     621        enum PlatformType
     622        {
     623            PLATFORM_EMPTY, PLATFORM_STATIC, PLATFORM_HMOVE, PLATFORM_VMOVE, PLATFORM_DISAPPEAR, PLATFORM_TIMER, PLATFORM_FAKE
     624        };
     625
     626        enum ItemType
     627        {
     628            ITEM_NOTHING, ITEM_SPRING, ITEM_PROPELLER, ITEM_ROCKET, ITEM_BOOTS, ITEM_SHIELD
     629        };
    630630
    631631        struct PlatformMatrix
    632632        {
    633                 PlatformType type;
     633            PlatformType type;
    634634            bool done;
    635635        } matrix[numI][numJ];
    636636
    637637
    638                 for (int i = 0; i < numI; ++i)
    639                 {
    640                         for (int j = 0; j < numJ; ++j)
    641                         {
    642                                 matrix[i][j].type = PLATFORM_EMPTY;
    643                                 matrix[i][j].done = false;
    644                         }
    645                 }
    646                 PlatformType platformtype1;
    647                 PlatformType platformtype2;
    648                 ItemType itemType = ITEM_NOTHING;
    649 
    650             if (rand()%2 == 0)
    651             {
    652                 itemType = ITEM_SPRING;
    653             }
    654             else if (rand()%2 == 0 && sectionNumber_ > 3)
    655             {
    656                         switch(rand()%4)
    657                         {
    658                         case 0:
    659                                 itemType = ITEM_PROPELLER;
    660                                 break;
    661                         case 1:
    662                                 itemType = ITEM_ROCKET;
    663                                 break;
    664                         case 2:
    665                                 itemType = ITEM_BOOTS;
    666                                 break;
    667                         case 3:
    668                                 itemType = ITEM_SHIELD;
    669                                 break;
    670                         default:
    671                                 break;
    672                         }
    673             }
    674 
    675                 switch((sectionNumber_ > 28) ? rand()%29 : rand()%(sectionNumber_+1))
    676             {
    677             case 0:
    678                 platformtype1 = PLATFORM_STATIC;
    679                 platformtype2 = PLATFORM_STATIC;
    680                 break;
    681             case 1:
    682                 platformtype1 = PLATFORM_STATIC;
    683                 platformtype2 = PLATFORM_STATIC;
    684                 break;
    685             case 2:
    686               platformtype1 = PLATFORM_STATIC;
    687               platformtype2 = PLATFORM_HMOVE;
    688               break;
    689             case 3:
    690               platformtype1 = PLATFORM_STATIC;
    691               platformtype2 = PLATFORM_DISAPPEAR;
    692               break;
    693             case 4:
    694               platformtype1 = PLATFORM_STATIC;
    695               platformtype2 = PLATFORM_VMOVE;
    696               break;
    697             case 5:
    698               platformtype1 = PLATFORM_STATIC;
    699               platformtype2 = PLATFORM_TIMER;
    700               break;
    701             case 6:
    702               platformtype1 = PLATFORM_HMOVE;
    703               platformtype2 = PLATFORM_STATIC;
    704               break;
    705             case 7:
    706               platformtype1 = PLATFORM_HMOVE;
    707               platformtype2 = PLATFORM_HMOVE;
    708               break;
    709             case 8:
    710               platformtype1 = PLATFORM_HMOVE;
    711               platformtype2 = PLATFORM_HMOVE;
    712               break;
    713             case 9:
    714               platformtype1 = PLATFORM_HMOVE;
    715               platformtype2 = PLATFORM_DISAPPEAR;
    716               break;
    717             case 10:
    718               platformtype1 = PLATFORM_HMOVE;
    719               platformtype2 = PLATFORM_VMOVE;
    720               break;
    721             case 11:
    722               platformtype1 = PLATFORM_HMOVE;
    723               platformtype2 = PLATFORM_TIMER;
    724               break;
    725             case 12:
    726               platformtype1 = PLATFORM_DISAPPEAR;
    727               platformtype2 = PLATFORM_STATIC;
    728               break;
    729             case 13:
    730               platformtype1 = PLATFORM_DISAPPEAR;
    731               platformtype2 = PLATFORM_HMOVE;
    732               break;
    733             case 14:
    734               platformtype1 = PLATFORM_DISAPPEAR;
    735               platformtype2 = PLATFORM_DISAPPEAR;
    736               break;
    737             case 15:
    738               platformtype1 = PLATFORM_DISAPPEAR;
    739               platformtype2 = PLATFORM_DISAPPEAR;
    740               break;
    741             case 16:
    742               platformtype1 = PLATFORM_DISAPPEAR;
    743               platformtype2 = PLATFORM_VMOVE;
    744               break;
    745             case 17:
    746               platformtype1 = PLATFORM_DISAPPEAR;
    747               platformtype2 = PLATFORM_TIMER;
    748               break;
    749             case 18:
    750               platformtype1 = PLATFORM_VMOVE;
    751               platformtype2 = PLATFORM_STATIC;
    752               break;
    753             case 19:
    754               platformtype1 = PLATFORM_VMOVE;
    755               platformtype2 = PLATFORM_HMOVE;
    756               break;
    757             case 20:
    758               platformtype1 = PLATFORM_VMOVE;
    759               platformtype2 = PLATFORM_DISAPPEAR;
    760               break;
    761             case 21:
    762               platformtype1 = PLATFORM_VMOVE;
    763               platformtype2 = PLATFORM_VMOVE;
    764               break;
    765             case 22:
    766               platformtype1 = PLATFORM_VMOVE;
    767               platformtype2 = PLATFORM_VMOVE;
    768               break;
    769             case 23:
    770               platformtype1 = PLATFORM_VMOVE;
    771               platformtype2 = PLATFORM_TIMER;
    772               break;
    773             case 24:
    774               platformtype1 = PLATFORM_TIMER;
    775               platformtype2 = PLATFORM_STATIC;
    776               break;
    777             case 25:
    778               platformtype1 = PLATFORM_TIMER;
    779               platformtype2 = PLATFORM_HMOVE;
    780               break;
    781             case 26:
    782               platformtype1 = PLATFORM_TIMER;
    783               platformtype2 = PLATFORM_DISAPPEAR;
    784               break;
    785             case 27:
    786                 platformtype1 = PLATFORM_TIMER;
    787                 platformtype2 = PLATFORM_VMOVE;
    788                 break;
    789             case 28:
    790                 platformtype1 = PLATFORM_TIMER;
    791                 platformtype2 = PLATFORM_TIMER;
    792                 break;
    793             default:
    794                 platformtype1 = PLATFORM_TIMER;
    795                 platformtype2 = PLATFORM_TIMER;
    796                 break;
    797             }
    798 
    799             // Fill matrix with selected platform types
    800             for (int i = 0; i < numI; ++ i)
    801             {
    802                           for (int j = 0; j < numJ; ++ j)
    803                           {
    804                                         if (rand()%3 == 0)
    805                                         {
    806                                             matrix[i][j].type = platformtype1;
    807                                         }
    808                                         else
    809                                         {
    810                                                 matrix[i][j].type = platformtype2;
    811                                         }
    812                                         matrix[i][j].done = false;
    813                           }
    814             }
    815 
    816             if (platformtype1 == platformtype2 && sectionNumber_ > 10 && rand()%2 == 0)
    817             {
    818                 matrix[rand()%numI][rand()%numJ].type = PLATFORM_EMPTY;
    819                     matrix[rand()%numI][rand()%numJ].type = PLATFORM_EMPTY;
    820             }
    821 
    822             // Delete some planned platforms or replace them with fake platforms
    823             if (sectionNumber_ > 5)
    824             {
    825                 if (rand()%2 == 0)
    826                 {
    827                         matrix[rand()%numI][rand()%numJ].type = PLATFORM_EMPTY;
    828                 }
    829                 else
    830                 {
    831                         matrix[rand()%numI][rand()%numJ].type = PLATFORM_FAKE;
    832                 }
    833             }
    834             else if (sectionNumber_ > 10)
    835             {
    836                 if (rand()%2 == 0)
    837                 {
    838                         matrix[rand()%numI][rand()%numJ].type = PLATFORM_EMPTY;
    839                 }
    840                 else
    841                 {
    842                         matrix[rand()%numI][rand()%numJ].type = PLATFORM_FAKE;
    843                 }
    844                 if (rand()%2 == 0)
    845                 {
    846                         matrix[rand()%numI][rand()%numJ].type = PLATFORM_EMPTY;
    847                 }
    848                 else
    849                 {
    850                         matrix[rand()%numI][rand()%numJ].type = PLATFORM_FAKE;
    851                 }
    852             }
    853             else if (sectionNumber_ > 15)
    854             {
    855                 if (rand()%2 == 0)
    856                 {
    857                         matrix[rand()%numI][rand()%numJ].type = PLATFORM_EMPTY;
    858                 }
    859                 else
    860                 {
    861                         matrix[rand()%numI][rand()%numJ].type = PLATFORM_FAKE;
    862                 }
    863                 if (rand()%2 == 0)
    864                 {
    865                         matrix[rand()%numI][rand()%numJ].type = PLATFORM_EMPTY;
    866                 }
    867                 else
    868                 {
    869                         matrix[rand()%numI][rand()%numJ].type = PLATFORM_FAKE;
    870                 }
    871                 if (rand()%2 == 0)
    872                 {
    873                         matrix[rand()%numI][rand()%numJ].type = PLATFORM_EMPTY;
    874                 }
    875                 else
    876                 {
    877                         matrix[rand()%numI][rand()%numJ].type = PLATFORM_FAKE;
    878                 }
    879             }
    880 
    881             std::vector<JumpPlatform*> platformList;
    882 
    883             for (int i = 0; i < numI; ++ i)
    884             {
    885                 for (int j = 0; j < numJ; ++ j)
    886                 {
    887                     if (matrix[i][j].done == false)
    888                     {
    889                         float xPosition = 0.0;
    890                         float zPosition = 0.0;
    891                                 float leftBoundary = 0.0;
    892                                 float rightBoundary = 0.0;
    893                                 float lowerBoundary = 0.0;
    894                                 float upperBoundary = 0.0;
    895                                 float xVelocity = 0.0;
    896                                 float zVelocity = 0.0;
    897 
    898                         switch(matrix[i][j].type)
    899                                     {
    900                                     case PLATFORM_EMPTY:
    901                                             matrix[i][j].done = true;
    902                                             break;
    903                                     case PLATFORM_STATIC:
    904                                                 xPosition = randomXPosition(numJ, j);
    905                                                 zPosition = sectionBegin + i*sectionLength/numI;
    906                                                 platformList.push_back(addPlatformStatic(xPosition, zPosition));
    907                                                 matrix[i][j].done = true;
    908                                         break;
    909                                     case PLATFORM_FAKE:
    910                                                 xPosition = randomXPosition(numJ, j);
    911                                                 zPosition = sectionBegin + i*sectionLength/numI;
    912                                                 platformList.push_back(addPlatformFake(xPosition, zPosition));
    913                                             matrix[i][j].done = true;
    914                                         break;
    915                                     case PLATFORM_TIMER:
    916                                                 xPosition = randomXPosition(numJ, j);
    917                                                 zPosition = sectionBegin + i*sectionLength/numI;
    918                                                 platformList.push_back(addPlatformTimer(xPosition, zPosition, 12.0, 1.5));
    919                                             matrix[i][j].done = true;
    920                                         break;
    921                                     case PLATFORM_DISAPPEAR:
    922                                                 xPosition = randomXPosition(numJ, j);
    923                                                 zPosition = sectionBegin + i*sectionLength/numI;
    924                                                 platformList.push_back(addPlatformDisappear(xPosition, zPosition));
    925                                             matrix[i][j].done = true;
    926                                         break;
    927                                     case PLATFORM_HMOVE:
    928                                         xVelocity = randomSpeed();
    929                                             if (j <= numJ-3 && matrix[i][j+1].type == PLATFORM_HMOVE && matrix[i][j+2].type == PLATFORM_HMOVE && rand()%2 == 0)
    930                                             {
    931                                                 leftBoundary = randomXPositionLeft(numJ, j);
    932                                                 rightBoundary = randomXPositionRight(numJ, j+2);
    933                                                 xPosition = randomPosition(leftBoundary, rightBoundary);
    934                                                         zPosition = sectionBegin + i*sectionLength/numI;
    935                                                         platformList.push_back(addPlatformHMove(xPosition, zPosition, leftBoundary, rightBoundary, xVelocity));
    936                                                 matrix[i][j].done = true;
    937                                                 matrix[i][j+1].done = true;
    938                                                 matrix[i][j+2].done = true;
    939                                             }
    940                                             else if (j <= numJ-2 && matrix[i][j+1].type == PLATFORM_HMOVE && rand()%2 == 0)
    941                                             {
    942                                                 leftBoundary = randomXPositionLeft(numJ, j);
    943                                                 rightBoundary = randomXPositionRight(numJ, j+1);
    944                                                 xPosition = randomPosition(leftBoundary, rightBoundary);
    945                                                         zPosition = sectionBegin + i*sectionLength/numI;
    946                                                         platformList.push_back(addPlatformHMove(xPosition, zPosition, leftBoundary, rightBoundary, xVelocity));
    947                                                 matrix[i][j].done = true;
    948                                                 matrix[i][j+1].done = true;
    949                                             }
    950                                             else
    951                                             {
    952                                                 leftBoundary = randomXPositionLeft(numJ, j);
    953                                                 rightBoundary = randomXPositionRight(numJ, j);
    954                                                 xPosition = randomPosition(leftBoundary, rightBoundary);
    955                                                         zPosition = sectionBegin + i*sectionLength/numI;
    956                                                         platformList.push_back(addPlatformHMove(xPosition, zPosition, leftBoundary, rightBoundary, xVelocity));
    957                                                 matrix[i][j].done = true;
    958                                             }
    959                                             break;
    960                                     case PLATFORM_VMOVE:
    961                                         zVelocity = randomSpeed();
    962                                             if (i <= numI-3 && matrix[i+1][j].type == PLATFORM_VMOVE && matrix[i+2][j].type == PLATFORM_VMOVE && rand()%2 == 0)
    963                                             {
    964                                                 lowerBoundary = randomZPositionLower(numI, i, sectionBegin, sectionEnd);
    965                                                 upperBoundary = randomZPositionUpper(numI, i+2, sectionBegin, sectionEnd);
    966                                                 zPosition = randomPosition(lowerBoundary, upperBoundary);
    967                                                 xPosition = randomXPosition(numJ, j);
    968                                                 platformList.push_back(addPlatformVMove(xPosition, zPosition, lowerBoundary, upperBoundary, zVelocity));
    969                                                 matrix[i][j].done = true;
    970                                                 matrix[i+1][j].done = true;
    971                                                 matrix[i+2][j].done = true;
    972                                             }
    973                                             else if (i <= numI-2 && matrix[i+1][j].type == PLATFORM_VMOVE && rand()%2 == 0)
    974                                             {
    975                                                 lowerBoundary = randomZPositionLower(numI, i, sectionBegin, sectionEnd);
    976                                                 upperBoundary = randomZPositionUpper(numI, i+1, sectionBegin, sectionEnd);
    977                                                 zPosition = randomPosition(lowerBoundary, upperBoundary);
    978                                                 xPosition = randomXPosition(numJ, j);
    979                                                 platformList.push_back(addPlatformVMove(xPosition, zPosition, lowerBoundary, upperBoundary, zVelocity));
    980                                                 matrix[i][j].done = true;
    981                                                 matrix[i+1][j].done = true;
    982                                             }
    983                                             else
    984                                             {
    985                                                 lowerBoundary = randomZPositionLower(numI, i, sectionBegin, sectionEnd);
    986                                                 upperBoundary = randomZPositionUpper(numI, i, sectionBegin, sectionEnd);
    987                                                 zPosition = randomPosition(lowerBoundary, upperBoundary);
    988                                                 xPosition = randomXPosition(numJ, j);
    989                                                 platformList.push_back(addPlatformVMove(xPosition, zPosition, lowerBoundary, upperBoundary, zVelocity));
    990                                                 matrix[i][j].done = true;
    991                                             }
    992                                             break;
    993                                     default:
    994                                         //ERROR
    995                                         break;
    996 
    997                         }
    998                     }
    999                 }
    1000             }
    1001 
    1002             //Add items
    1003         int numNewPlatforms = platformList.size();
    1004 
    1005         if (rand()%4 == 0)
    1006         {
    1007                         if (rand()%2 == 0)
    1008                         {
    1009                         switch (itemType)
    1010                                 {
    1011                                 case ITEM_ROCKET:
    1012                                         addRocket(0.0, randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/2, fieldWidth/2, 0.0, 0.0, randomSpeed(), 0.0);
    1013                                         break;
    1014                                 case ITEM_PROPELLER:
    1015                                         addPropeller(0.0, randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/2, fieldWidth/2, 0.0, 0.0, randomSpeed(), 0.0);
    1016                                         break;
    1017                                 case ITEM_BOOTS:
    1018                                         addBoots(0.0, randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/2, fieldWidth/2, 0.0, 0.0, randomSpeed(), 0.0);
    1019                                         break;
    1020                                 case ITEM_SHIELD:
    1021                                         addShield(0.0, randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/2, fieldWidth/2, 0.0, 0.0, randomSpeed(), 0.0);
    1022                                         break;
    1023                                 default:
    1024                                         break;
    1025                                 }
    1026                         }
    1027                         else
    1028                         {
    1029                         switch (itemType)
    1030                                 {
    1031                                 case ITEM_ROCKET:
    1032                                         addRocket(randomPosition(-fieldWidth/2, fieldWidth/2), sectionBegin + sectionLength/2, 0.0, 0.0, sectionBegin, sectionEnd, 0.0, randomSpeed());
    1033                                         break;
    1034                                 case ITEM_PROPELLER:
    1035                                         addPropeller(randomPosition(-fieldWidth/2, fieldWidth/2), sectionBegin + sectionLength/2, 0.0, 0.0, sectionBegin, sectionEnd, 0.0, randomSpeed());
    1036                                         break;
    1037                                 case ITEM_BOOTS:
    1038                                         addBoots(randomPosition(-fieldWidth/2, fieldWidth/2), sectionBegin + sectionLength/2, 0.0, 0.0, sectionBegin, sectionEnd, 0.0, randomSpeed());
    1039                                         break;
    1040                                 case ITEM_SHIELD:
    1041                                         addShield(randomPosition(-fieldWidth/2, fieldWidth/2), sectionBegin + sectionLength/2, 0.0, 0.0, sectionBegin, sectionEnd, 0.0, randomSpeed());
    1042                                         break;
    1043                                 default:
    1044                                         break;
    1045                                 }
    1046                         }
    1047         }
    1048         else
    1049         {
    1050                 if (numNewPlatforms > 0)
    1051                 {
    1052                         JumpPlatform* itemPlatform = platformList[rand()%numNewPlatforms];
    1053 
    1054                         switch (itemType)
    1055                         {
    1056                         case ITEM_SPRING:
    1057                                 addSpring(itemPlatform);
    1058                                 break;
    1059                         case ITEM_ROCKET:
    1060                                 addRocket(itemPlatform);
    1061                                 break;
    1062                         case ITEM_PROPELLER:
    1063                                 addPropeller(itemPlatform);
    1064                                 break;
    1065                         case ITEM_BOOTS:
    1066                                 addBoots(itemPlatform);
    1067                                 break;
    1068                         case ITEM_SHIELD:
    1069                                 addShield(itemPlatform);
    1070                                 break;
    1071                         default:
    1072                                 break;
    1073                         }
    1074                 }
    1075         }
     638        for (int i = 0; i < numI; ++i)
     639        {
     640            for (int j = 0; j < numJ; ++j)
     641            {
     642                matrix[i][j].type = PLATFORM_EMPTY;
     643                matrix[i][j].done = false;
     644            }
     645        }
     646        PlatformType platformtype1;
     647        PlatformType platformtype2;
     648        ItemType itemType = ITEM_NOTHING;
     649
     650        if (rand()%2 == 0)
     651        {
     652            itemType = ITEM_SPRING;
     653        }
     654        else if (rand()%2 == 0 && sectionNumber_ > 3)
     655        {
     656            switch(rand()%4)
     657            {
     658            case 0:
     659                itemType = ITEM_PROPELLER;
     660                break;
     661            case 1:
     662                itemType = ITEM_ROCKET;
     663                break;
     664            case 2:
     665                itemType = ITEM_BOOTS;
     666                break;
     667            case 3:
     668                itemType = ITEM_SHIELD;
     669                break;
     670            default:
     671                break;
     672            }
     673        }
     674
     675        switch((sectionNumber_ > 28) ? rand()%29 : rand()%(sectionNumber_+1))
     676        {
     677        case 0:
     678            platformtype1 = PLATFORM_STATIC;
     679            platformtype2 = PLATFORM_STATIC;
     680            break;
     681        case 1:
     682            platformtype1 = PLATFORM_STATIC;
     683            platformtype2 = PLATFORM_STATIC;
     684            break;
     685        case 2:
     686            platformtype1 = PLATFORM_STATIC;
     687            platformtype2 = PLATFORM_HMOVE;
     688            break;
     689        case 3:
     690            platformtype1 = PLATFORM_STATIC;
     691            platformtype2 = PLATFORM_DISAPPEAR;
     692            break;
     693        case 4:
     694            platformtype1 = PLATFORM_STATIC;
     695            platformtype2 = PLATFORM_VMOVE;
     696            break;
     697        case 5:
     698            platformtype1 = PLATFORM_STATIC;
     699            platformtype2 = PLATFORM_TIMER;
     700            break;
     701        case 6:
     702            platformtype1 = PLATFORM_HMOVE;
     703            platformtype2 = PLATFORM_STATIC;
     704            break;
     705        case 7:
     706            platformtype1 = PLATFORM_HMOVE;
     707            platformtype2 = PLATFORM_HMOVE;
     708            break;
     709        case 8:
     710            platformtype1 = PLATFORM_HMOVE;
     711            platformtype2 = PLATFORM_HMOVE;
     712            break;
     713        case 9:
     714            platformtype1 = PLATFORM_HMOVE;
     715            platformtype2 = PLATFORM_DISAPPEAR;
     716            break;
     717        case 10:
     718            platformtype1 = PLATFORM_HMOVE;
     719            platformtype2 = PLATFORM_VMOVE;
     720            break;
     721        case 11:
     722            platformtype1 = PLATFORM_HMOVE;
     723            platformtype2 = PLATFORM_TIMER;
     724            break;
     725        case 12:
     726            platformtype1 = PLATFORM_DISAPPEAR;
     727            platformtype2 = PLATFORM_STATIC;
     728            break;
     729        case 13:
     730            platformtype1 = PLATFORM_DISAPPEAR;
     731            platformtype2 = PLATFORM_HMOVE;
     732            break;
     733        case 14:
     734            platformtype1 = PLATFORM_DISAPPEAR;
     735            platformtype2 = PLATFORM_DISAPPEAR;
     736            break;
     737        case 15:
     738            platformtype1 = PLATFORM_DISAPPEAR;
     739            platformtype2 = PLATFORM_DISAPPEAR;
     740            break;
     741        case 16:
     742            platformtype1 = PLATFORM_DISAPPEAR;
     743            platformtype2 = PLATFORM_VMOVE;
     744            break;
     745        case 17:
     746            platformtype1 = PLATFORM_DISAPPEAR;
     747            platformtype2 = PLATFORM_TIMER;
     748            break;
     749        case 18:
     750            platformtype1 = PLATFORM_VMOVE;
     751            platformtype2 = PLATFORM_STATIC;
     752            break;
     753        case 19:
     754            platformtype1 = PLATFORM_VMOVE;
     755            platformtype2 = PLATFORM_HMOVE;
     756            break;
     757        case 20:
     758            platformtype1 = PLATFORM_VMOVE;
     759            platformtype2 = PLATFORM_DISAPPEAR;
     760            break;
     761        case 21:
     762            platformtype1 = PLATFORM_VMOVE;
     763            platformtype2 = PLATFORM_VMOVE;
     764            break;
     765        case 22:
     766            platformtype1 = PLATFORM_VMOVE;
     767            platformtype2 = PLATFORM_VMOVE;
     768            break;
     769        case 23:
     770            platformtype1 = PLATFORM_VMOVE;
     771            platformtype2 = PLATFORM_TIMER;
     772            break;
     773        case 24:
     774            platformtype1 = PLATFORM_TIMER;
     775            platformtype2 = PLATFORM_STATIC;
     776            break;
     777        case 25:
     778            platformtype1 = PLATFORM_TIMER;
     779            platformtype2 = PLATFORM_HMOVE;
     780            break;
     781        case 26:
     782            platformtype1 = PLATFORM_TIMER;
     783            platformtype2 = PLATFORM_DISAPPEAR;
     784            break;
     785        case 27:
     786            platformtype1 = PLATFORM_TIMER;
     787            platformtype2 = PLATFORM_VMOVE;
     788            break;
     789        case 28:
     790            platformtype1 = PLATFORM_TIMER;
     791            platformtype2 = PLATFORM_TIMER;
     792            break;
     793        default:
     794            platformtype1 = PLATFORM_TIMER;
     795            platformtype2 = PLATFORM_TIMER;
     796            break;
     797        }
     798
     799        // Fill matrix with selected platform types
     800        for (int i = 0; i < numI; ++ i)
     801        {
     802            for (int j = 0; j < numJ; ++ j)
     803            {
     804                if (rand()%3 == 0)
     805                {
     806                    matrix[i][j].type = platformtype1;
     807                }
     808                else
     809                {
     810                    matrix[i][j].type = platformtype2;
     811                }
     812                matrix[i][j].done = false;
     813            }
     814        }
     815
     816        if (platformtype1 == platformtype2 && sectionNumber_ > 10 && rand()%2 == 0)
     817        {
     818            matrix[rand()%numI][rand()%numJ].type = PLATFORM_EMPTY;
     819            matrix[rand()%numI][rand()%numJ].type = PLATFORM_EMPTY;
     820        }
     821
     822        // Delete some planned platforms or replace them with fake platforms
     823        if (sectionNumber_ > 5)
     824        {
     825            if (rand()%2 == 0)
     826            {
     827                matrix[rand()%numI][rand()%numJ].type = PLATFORM_EMPTY;
     828            }
     829            else
     830            {
     831                matrix[rand()%numI][rand()%numJ].type = PLATFORM_FAKE;
     832            }
     833        }
     834        else if (sectionNumber_ > 10)
     835        {
     836            if (rand()%2 == 0)
     837            {
     838                matrix[rand()%numI][rand()%numJ].type = PLATFORM_EMPTY;
     839            }
     840            else
     841            {
     842                matrix[rand()%numI][rand()%numJ].type = PLATFORM_FAKE;
     843            }
     844            if (rand()%2 == 0)
     845            {
     846                matrix[rand()%numI][rand()%numJ].type = PLATFORM_EMPTY;
     847            }
     848            else
     849            {
     850                matrix[rand()%numI][rand()%numJ].type = PLATFORM_FAKE;
     851            }
     852        }
     853        else if (sectionNumber_ > 15)
     854        {
     855            if (rand()%2 == 0)
     856            {
     857                matrix[rand()%numI][rand()%numJ].type = PLATFORM_EMPTY;
     858            }
     859            else
     860            {
     861                matrix[rand()%numI][rand()%numJ].type = PLATFORM_FAKE;
     862            }
     863            if (rand()%2 == 0)
     864            {
     865                matrix[rand()%numI][rand()%numJ].type = PLATFORM_EMPTY;
     866            }
     867            else
     868            {
     869                matrix[rand()%numI][rand()%numJ].type = PLATFORM_FAKE;
     870            }
     871            if (rand()%2 == 0)
     872            {
     873                matrix[rand()%numI][rand()%numJ].type = PLATFORM_EMPTY;
     874            }
     875            else
     876            {
     877                matrix[rand()%numI][rand()%numJ].type = PLATFORM_FAKE;
     878            }
     879        }
     880
     881        std::vector<JumpPlatform*> platformList;
     882
     883        for (int i = 0; i < numI; ++ i)
     884        {
     885            for (int j = 0; j < numJ; ++ j)
     886            {
     887                if (matrix[i][j].done == false)
     888                {
     889                    float xPosition = 0.0;
     890                    float zPosition = 0.0;
     891                    float leftBoundary = 0.0;
     892                    float rightBoundary = 0.0;
     893                    float lowerBoundary = 0.0;
     894                    float upperBoundary = 0.0;
     895                    float xVelocity = 0.0;
     896                    float zVelocity = 0.0;
     897
     898                    switch(matrix[i][j].type)
     899                    {
     900                    case PLATFORM_EMPTY:
     901                        matrix[i][j].done = true;
     902                        break;
     903                    case PLATFORM_STATIC:
     904                        xPosition = randomXPosition(numJ, j);
     905                        zPosition = sectionBegin + i*sectionLength/numI;
     906                        platformList.push_back(addPlatformStatic(xPosition, zPosition));
     907                        matrix[i][j].done = true;
     908                        break;
     909                    case PLATFORM_FAKE:
     910                        xPosition = randomXPosition(numJ, j);
     911                        zPosition = sectionBegin + i*sectionLength/numI;
     912                        platformList.push_back(addPlatformFake(xPosition, zPosition));
     913                        matrix[i][j].done = true;
     914                        break;
     915                    case PLATFORM_TIMER:
     916                        xPosition = randomXPosition(numJ, j);
     917                        zPosition = sectionBegin + i*sectionLength/numI;
     918                        platformList.push_back(addPlatformTimer(xPosition, zPosition, 12.0, 1.5));
     919                        matrix[i][j].done = true;
     920                        break;
     921                    case PLATFORM_DISAPPEAR:
     922                        xPosition = randomXPosition(numJ, j);
     923                        zPosition = sectionBegin + i*sectionLength/numI;
     924                        platformList.push_back(addPlatformDisappear(xPosition, zPosition));
     925                        matrix[i][j].done = true;
     926                        break;
     927                    case PLATFORM_HMOVE:
     928                        xVelocity = randomSpeed();
     929                        if (j <= numJ-3 && matrix[i][j+1].type == PLATFORM_HMOVE && matrix[i][j+2].type == PLATFORM_HMOVE && rand()%2 == 0)
     930                        {
     931                            leftBoundary = randomXPositionLeft(numJ, j);
     932                            rightBoundary = randomXPositionRight(numJ, j+2);
     933                            xPosition = randomPosition(leftBoundary, rightBoundary);
     934                            zPosition = sectionBegin + i*sectionLength/numI;
     935                            platformList.push_back(addPlatformHMove(xPosition, zPosition, leftBoundary, rightBoundary, xVelocity));
     936                            matrix[i][j].done = true;
     937                            matrix[i][j+1].done = true;
     938                            matrix[i][j+2].done = true;
     939                        }
     940                        else if (j <= numJ-2 && matrix[i][j+1].type == PLATFORM_HMOVE && rand()%2 == 0)
     941                        {
     942                            leftBoundary = randomXPositionLeft(numJ, j);
     943                            rightBoundary = randomXPositionRight(numJ, j+1);
     944                            xPosition = randomPosition(leftBoundary, rightBoundary);
     945                            zPosition = sectionBegin + i*sectionLength/numI;
     946                            platformList.push_back(addPlatformHMove(xPosition, zPosition, leftBoundary, rightBoundary, xVelocity));
     947                            matrix[i][j].done = true;
     948                            matrix[i][j+1].done = true;
     949                        }
     950                        else
     951                        {
     952                            leftBoundary = randomXPositionLeft(numJ, j);
     953                            rightBoundary = randomXPositionRight(numJ, j);
     954                            xPosition = randomPosition(leftBoundary, rightBoundary);
     955                            zPosition = sectionBegin + i*sectionLength/numI;
     956                            platformList.push_back(addPlatformHMove(xPosition, zPosition, leftBoundary, rightBoundary, xVelocity));
     957                            matrix[i][j].done = true;
     958                        }
     959                        break;
     960                    case PLATFORM_VMOVE:
     961                        zVelocity = randomSpeed();
     962                        if (i <= numI-3 && matrix[i+1][j].type == PLATFORM_VMOVE && matrix[i+2][j].type == PLATFORM_VMOVE && rand()%2 == 0)
     963                        {
     964                            lowerBoundary = randomZPositionLower(numI, i, sectionBegin, sectionEnd);
     965                            upperBoundary = randomZPositionUpper(numI, i+2, sectionBegin, sectionEnd);
     966                            zPosition = randomPosition(lowerBoundary, upperBoundary);
     967                            xPosition = randomXPosition(numJ, j);
     968                            platformList.push_back(addPlatformVMove(xPosition, zPosition, lowerBoundary, upperBoundary, zVelocity));
     969                            matrix[i][j].done = true;
     970                            matrix[i+1][j].done = true;
     971                            matrix[i+2][j].done = true;
     972                        }
     973                        else if (i <= numI-2 && matrix[i+1][j].type == PLATFORM_VMOVE && rand()%2 == 0)
     974                        {
     975                            lowerBoundary = randomZPositionLower(numI, i, sectionBegin, sectionEnd);
     976                            upperBoundary = randomZPositionUpper(numI, i+1, sectionBegin, sectionEnd);
     977                            zPosition = randomPosition(lowerBoundary, upperBoundary);
     978                            xPosition = randomXPosition(numJ, j);
     979                            platformList.push_back(addPlatformVMove(xPosition, zPosition, lowerBoundary, upperBoundary, zVelocity));
     980                            matrix[i][j].done = true;
     981                            matrix[i+1][j].done = true;
     982                        }
     983                        else
     984                        {
     985                            lowerBoundary = randomZPositionLower(numI, i, sectionBegin, sectionEnd);
     986                            upperBoundary = randomZPositionUpper(numI, i, sectionBegin, sectionEnd);
     987                            zPosition = randomPosition(lowerBoundary, upperBoundary);
     988                            xPosition = randomXPosition(numJ, j);
     989                            platformList.push_back(addPlatformVMove(xPosition, zPosition, lowerBoundary, upperBoundary, zVelocity));
     990                            matrix[i][j].done = true;
     991                        }
     992                        break;
     993                    default:
     994                        //ERROR
     995                        break;
     996
     997                    }
     998                }
     999            }
     1000        }
     1001
     1002        //Add items
     1003        int numNewPlatforms = platformList.size();
     1004
     1005        if (rand()%4 == 0)
     1006        {
     1007            if (rand()%2 == 0)
     1008            {
     1009                switch (itemType)
     1010                {
     1011                case ITEM_ROCKET:
     1012                    addRocket(0.0, randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/2, fieldWidth/2, 0.0, 0.0, randomSpeed(), 0.0);
     1013                    break;
     1014                case ITEM_PROPELLER:
     1015                    addPropeller(0.0, randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/2, fieldWidth/2, 0.0, 0.0, randomSpeed(), 0.0);
     1016                    break;
     1017                case ITEM_BOOTS:
     1018                    addBoots(0.0, randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/2, fieldWidth/2, 0.0, 0.0, randomSpeed(), 0.0);
     1019                    break;
     1020                case ITEM_SHIELD:
     1021                    addShield(0.0, randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/2, fieldWidth/2, 0.0, 0.0, randomSpeed(), 0.0);
     1022                    break;
     1023                default:
     1024                    break;
     1025                }
     1026            }
     1027            else
     1028            {
     1029                switch (itemType)
     1030                {
     1031                case ITEM_ROCKET:
     1032                    addRocket(randomPosition(-fieldWidth/2, fieldWidth/2), sectionBegin + sectionLength/2, 0.0, 0.0, sectionBegin, sectionEnd, 0.0, randomSpeed());
     1033                    break;
     1034                case ITEM_PROPELLER:
     1035                    addPropeller(randomPosition(-fieldWidth/2, fieldWidth/2), sectionBegin + sectionLength/2, 0.0, 0.0, sectionBegin, sectionEnd, 0.0, randomSpeed());
     1036                    break;
     1037                case ITEM_BOOTS:
     1038                    addBoots(randomPosition(-fieldWidth/2, fieldWidth/2), sectionBegin + sectionLength/2, 0.0, 0.0, sectionBegin, sectionEnd, 0.0, randomSpeed());
     1039                    break;
     1040                case ITEM_SHIELD:
     1041                    addShield(randomPosition(-fieldWidth/2, fieldWidth/2), sectionBegin + sectionLength/2, 0.0, 0.0, sectionBegin, sectionEnd, 0.0, randomSpeed());
     1042                    break;
     1043                default:
     1044                    break;
     1045                }
     1046            }
     1047        }
     1048        else
     1049        {
     1050            if (numNewPlatforms > 0)
     1051            {
     1052                JumpPlatform* itemPlatform = platformList[rand()%numNewPlatforms];
     1053
     1054                switch (itemType)
     1055                {
     1056                case ITEM_SPRING:
     1057                    addSpring(itemPlatform);
     1058                    break;
     1059                case ITEM_ROCKET:
     1060                    addRocket(itemPlatform);
     1061                    break;
     1062                case ITEM_PROPELLER:
     1063                    addPropeller(itemPlatform);
     1064                    break;
     1065                case ITEM_BOOTS:
     1066                    addBoots(itemPlatform);
     1067                    break;
     1068                case ITEM_SHIELD:
     1069                    addShield(itemPlatform);
     1070                    break;
     1071                default:
     1072                    break;
     1073                }
     1074            }
     1075        }
    10761076
    10771077        if (sectionNumber_ >= 5 && rand()%3 == 0)
    10781078        {
    1079             switch(rand()%4)
    1080                 {
     1079            switch(rand()%4)
     1080            {
    10811081            case 0:
    1082                 addEnemy(1, randomXPosition(), randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/3*2, fieldWidth/3*2, sectionBegin, sectionBegin + sectionLength, randomSpeed(), 0.0);
    1083                 break;
     1082                addEnemy(1, randomXPosition(), randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/3*2, fieldWidth/3*2, sectionBegin, sectionBegin + sectionLength, randomSpeed(), 0.0);
     1083                break;
    10841084            case 1:
    1085                 addEnemy(2, randomXPosition(), randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/3*2, fieldWidth/3*2, sectionBegin, sectionBegin + sectionLength, randomSpeed(), 0.0);
    1086                 break;
     1085                addEnemy(2, randomXPosition(), randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/3*2, fieldWidth/3*2, sectionBegin, sectionBegin + sectionLength, randomSpeed(), 0.0);
     1086                break;
    10871087            case 2:
    1088                 addEnemy(3, randomXPosition(), randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/3*2, fieldWidth/3*2, sectionBegin, sectionBegin + sectionLength, randomSpeed(), 0.0);
    1089                 break;
     1088                addEnemy(3, randomXPosition(), randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/3*2, fieldWidth/3*2, sectionBegin, sectionBegin + sectionLength, randomSpeed(), 0.0);
     1089                break;
    10901090            case 3:
    1091                 addEnemy(4, randomXPosition(), randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/3*2, fieldWidth/3*2, sectionBegin, sectionBegin + sectionLength, randomSpeed(), 0.0);
    1092                 break;
    1093                 }
    1094         }
    1095                 ++ sectionNumber_;
     1091                addEnemy(4, randomXPosition(), randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/3*2, fieldWidth/3*2, sectionBegin, sectionBegin + sectionLength, randomSpeed(), 0.0);
     1092                break;
     1093            }
     1094        }
     1095        ++ sectionNumber_;
    10961096    }
    10971097
     
    11061106        {
    11071107        case 0:
    1108                         {
    1109                                 int numI = 10;
    1110                                 if (rand()%2 == 0)
    1111                                 {
    1112                                         for (int i = 0; i < numI; ++ i)
    1113                                         {
    1114                                                 addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth+platformWidth_/2, sectionBegin+i*sectionLength/numI);
    1115                                         }
    1116                                 }
    1117                                 else
    1118                                 {
    1119                                         for (int i = 0; i < numI; ++ i)
    1120                                         {
    1121                                                 addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth+platformWidth_/2, sectionBegin+(numI-i)*sectionLength/numI);
    1122                                         }
    1123                                 }
    1124                                 break;
    1125                         }
     1108        {
     1109            int numI = 10;
     1110            if (rand()%2 == 0)
     1111            {
     1112                for (int i = 0; i < numI; ++ i)
     1113                {
     1114                    addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth+platformWidth_/2, sectionBegin+i*sectionLength/numI);
     1115                }
     1116            }
     1117            else
     1118            {
     1119                for (int i = 0; i < numI; ++ i)
     1120                {
     1121                    addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth+platformWidth_/2, sectionBegin+(numI-i)*sectionLength/numI);
     1122                }
     1123            }
     1124            break;
     1125        }
    11261126        case 1:
    1127                 {
    1128                         int numI = 7;
    1129 
    1130                         addPlatformStatic(0.0, sectionBegin);
    1131                         if (rand()%2 == 0)
    1132                         {
    1133                                 for (int i = 1; i < numI; ++ i)
    1134                                 {
    1135                                         addPlatformStatic((fieldWidth-platformWidth_/2)*i/numI, sectionBegin+i*sectionLength/numI);
    1136                                         addPlatformStatic(-(fieldWidth-platformWidth_/2)*i/numI, sectionBegin+i*sectionLength/numI);
    1137                                 }
    1138                         }
    1139                         else
    1140                         {
    1141                                 for (int i = 1; i < numI; ++ i)
    1142                                 {
    1143                                         addPlatformStatic((fieldWidth-platformWidth_/2)*i/numI, sectionBegin+(numI-i)*sectionLength/numI);
    1144                                         addPlatformStatic(-(fieldWidth-platformWidth_/2)*i/numI, sectionBegin+(numI-i)*sectionLength/numI);
    1145                                 }
    1146                         }
    1147                         break;
    1148                 }
     1127        {
     1128            int numI = 7;
     1129
     1130            addPlatformStatic(0.0, sectionBegin);
     1131            if (rand()%2 == 0)
     1132            {
     1133                for (int i = 1; i < numI; ++ i)
     1134                {
     1135                    addPlatformStatic((fieldWidth-platformWidth_/2)*i/numI, sectionBegin+i*sectionLength/numI);
     1136                    addPlatformStatic(-(fieldWidth-platformWidth_/2)*i/numI, sectionBegin+i*sectionLength/numI);
     1137                }
     1138            }
     1139            else
     1140            {
     1141                for (int i = 1; i < numI; ++ i)
     1142                {
     1143                    addPlatformStatic((fieldWidth-platformWidth_/2)*i/numI, sectionBegin+(numI-i)*sectionLength/numI);
     1144                    addPlatformStatic(-(fieldWidth-platformWidth_/2)*i/numI, sectionBegin+(numI-i)*sectionLength/numI);
     1145                }
     1146            }
     1147            break;
     1148        }
    11491149        case 2:
    1150                         {
    1151                                 int numI = 5;
    1152                                 for (int i = 0; i <= numI; ++ i)
    1153                                 {
    1154                                         addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth, sectionBegin);
    1155                                         addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth, sectionBegin+sectionLength/5);
    1156                                         addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth, sectionBegin+sectionLength*2/5);
    1157                                         addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth, sectionBegin+sectionLength*3/5);
    1158                                         addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth, sectionBegin+sectionLength*4/5);
    1159                                         addEnemy(4, (2*fieldWidth-platformWidth_)*i/numI-fieldWidth+platformWidth_/2, sectionBegin+sectionLength/2, -fieldWidth, fieldWidth, sectionBegin, sectionBegin + sectionLength, 0.0, 0.0);
    1160                                 }
    1161                                 break;
    1162                         }
     1150        {
     1151            int numI = 5;
     1152            for (int i = 0; i <= numI; ++ i)
     1153            {
     1154                addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth, sectionBegin);
     1155                addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth, sectionBegin+sectionLength/5);
     1156                addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth, sectionBegin+sectionLength*2/5);
     1157                addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth, sectionBegin+sectionLength*3/5);
     1158                addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth, sectionBegin+sectionLength*4/5);
     1159                addEnemy(4, (2*fieldWidth-platformWidth_)*i/numI-fieldWidth+platformWidth_/2, sectionBegin+sectionLength/2, -fieldWidth, fieldWidth, sectionBegin, sectionBegin + sectionLength, 0.0, 0.0);
     1160            }
     1161            break;
     1162        }
    11631163        case 3:
    1164                         {
    1165                                 addRocket(addPlatformStatic(0.0, sectionBegin));
    1166                                 addEnemy(2, 0.0, sectionBegin+sectionLength/5, 0.0,0.0, 0.0, 0.0, 0.0, 0.0);
    1167                                 break;
    1168                         }
     1164        {
     1165            addRocket(addPlatformStatic(0.0, sectionBegin));
     1166            addEnemy(2, 0.0, sectionBegin+sectionLength/5, 0.0,0.0, 0.0, 0.0, 0.0, 0.0);
     1167            break;
     1168        }
    11691169        case 4:
    1170                         {
    1171                                 addPropeller(addPlatformStatic(0.0, sectionBegin));
    1172                                 addPropeller(addPlatformStatic(-fieldWidth/2, sectionBegin));
    1173                                 addPropeller(addPlatformStatic(fieldWidth/2, sectionBegin));
    1174                                 break;
    1175                         }
     1170        {
     1171            addPropeller(addPlatformStatic(0.0, sectionBegin));
     1172            addPropeller(addPlatformStatic(-fieldWidth/2, sectionBegin));
     1173            addPropeller(addPlatformStatic(fieldWidth/2, sectionBegin));
     1174            break;
     1175        }
    11761176        default:
    1177                 return false;
     1177            return false;
    11781178        }
    11791179        sectionNumber_ +=2;
     
    11851185        float fieldWidth = center_->getFieldDimension().x;
    11861186
    1187         return (float)(rand()%(2*(int)fieldWidth)) - fieldWidth;
     1187        return (float)(rand()%(2*(int)fieldWidth)) - fieldWidth;
    11881188    }
    11891189
    11901190    float Jump::randomXPosition(int totalColumns, int culomn)
    11911191    {
    1192         float fieldWidth = center_->getFieldDimension().x;
    1193 
    1194         float halfWidth = fieldWidth/totalColumns;
    1195         float leftBound = culomn*halfWidth*2-fieldWidth;
    1196         float rightBound = leftBound + 2*halfWidth;
    1197 
    1198         return randomPosition(leftBound+platformWidth_/2, rightBound-platformWidth_/2);
     1192        float fieldWidth = center_->getFieldDimension().x;
     1193
     1194        float halfWidth = fieldWidth/totalColumns;
     1195        float leftBound = culomn*halfWidth*2-fieldWidth;
     1196        float rightBound = leftBound + 2*halfWidth;
     1197
     1198        return randomPosition(leftBound+platformWidth_/2, rightBound-platformWidth_/2);
    11991199    }
    12001200
    12011201    float Jump::randomXPositionLeft(int totalColumns, int culomn)
    12021202    {
    1203         float fieldWidth = center_->getFieldDimension().x;
    1204 
    1205         float halfWidth = fieldWidth/totalColumns;
    1206         float leftBound = culomn*halfWidth*2-fieldWidth;
    1207         float rightBound = leftBound + 2*halfWidth/3;
    1208 
    1209         return randomPosition(leftBound+platformWidth_/2, rightBound-platformWidth_/2);
     1203        float fieldWidth = center_->getFieldDimension().x;
     1204
     1205        float halfWidth = fieldWidth/totalColumns;
     1206        float leftBound = culomn*halfWidth*2-fieldWidth;
     1207        float rightBound = leftBound + 2*halfWidth/3;
     1208
     1209        return randomPosition(leftBound+platformWidth_/2, rightBound-platformWidth_/2);
    12101210    }
    12111211
    12121212    float Jump::randomXPositionRight(int totalColumns, int culomn)
    12131213    {
    1214         float fieldWidth = center_->getFieldDimension().x;
    1215 
    1216         float halfWidth = fieldWidth/totalColumns;
    1217         float rightBound = (culomn+1)*halfWidth*2-fieldWidth;
    1218         float leftBound = rightBound - 2*halfWidth/3;
    1219         return randomPosition(leftBound+platformWidth_/2, rightBound-platformWidth_/2);
     1214        float fieldWidth = center_->getFieldDimension().x;
     1215
     1216        float halfWidth = fieldWidth/totalColumns;
     1217        float rightBound = (culomn+1)*halfWidth*2-fieldWidth;
     1218        float leftBound = rightBound - 2*halfWidth/3;
     1219        return randomPosition(leftBound+platformWidth_/2, rightBound-platformWidth_/2);
    12201220    }
    12211221
    12221222    float Jump::randomZPosition(int totalRows, int row, float sectionBegin, float SectionEnd)
    12231223    {
    1224         float fieldHeight = SectionEnd - sectionBegin;
    1225         float halfHeight = fieldHeight/totalRows;
    1226         float lowerBound = row*halfHeight*2+sectionBegin;
    1227         float upperBound = lowerBound + 2*halfHeight;
    1228 
    1229         return randomPosition(lowerBound+platformHeight_/2, upperBound-platformHeight_/2);
     1224        float fieldHeight = SectionEnd - sectionBegin;
     1225        float halfHeight = fieldHeight/totalRows;
     1226        float lowerBound = row*halfHeight*2+sectionBegin;
     1227        float upperBound = lowerBound + 2*halfHeight;
     1228
     1229        return randomPosition(lowerBound+platformHeight_/2, upperBound-platformHeight_/2);
    12301230    }
    12311231
    12321232    float Jump::randomZPositionLower(int totalRows, int row, float sectionBegin, float SectionEnd)
    12331233    {
    1234         float fieldHeight = SectionEnd - sectionBegin;
    1235         float rowHeight = fieldHeight/totalRows;
    1236         float lowerBound = row*rowHeight+sectionBegin;
    1237         float upperBound = lowerBound + rowHeight/3;
    1238 
    1239         return randomPosition(lowerBound+platformHeight_/2, upperBound-platformHeight_/2);
     1234        float fieldHeight = SectionEnd - sectionBegin;
     1235        float rowHeight = fieldHeight/totalRows;
     1236        float lowerBound = row*rowHeight+sectionBegin;
     1237        float upperBound = lowerBound + rowHeight/3;
     1238
     1239        return randomPosition(lowerBound+platformHeight_/2, upperBound-platformHeight_/2);
    12401240    }
    12411241
    12421242    float Jump::randomZPositionUpper(int totalRows, int row, float sectionBegin, float SectionEnd)
    12431243    {
    1244         float fieldHeight = SectionEnd - sectionBegin;
    1245         float rowHeight = fieldHeight/totalRows;
    1246         float lowerBound = (row+1)*rowHeight+sectionBegin;
    1247         float upperBound = lowerBound - rowHeight/3;
    1248 
    1249         return randomPosition(lowerBound+platformHeight_/2, upperBound-platformHeight_/2);
     1244        float fieldHeight = SectionEnd - sectionBegin;
     1245        float rowHeight = fieldHeight/totalRows;
     1246        float lowerBound = (row+1)*rowHeight+sectionBegin;
     1247        float upperBound = lowerBound - rowHeight/3;
     1248
     1249        return randomPosition(lowerBound+platformHeight_/2, upperBound-platformHeight_/2);
    12501250    }
    12511251
    12521252    float Jump::randomPosition(float lowerBoundary, float upperBoundary)
    12531253    {
    1254         if (lowerBoundary >= upperBoundary)
    1255         {
    1256                 return (lowerBoundary + upperBoundary)/2;
    1257         }
    1258 
    1259         return (float)(rand()%(int)(100*(upperBoundary - lowerBoundary)))/100 + lowerBoundary;
     1254        if (lowerBoundary >= upperBoundary)
     1255        {
     1256            return (lowerBoundary + upperBoundary)/2;
     1257        }
     1258
     1259        return (float)(rand()%(int)(100*(upperBoundary - lowerBoundary)))/100 + lowerBoundary;
    12601260    }
    12611261
    12621262    float Jump::randomSpeed()
    12631263    {
    1264         float platformSpeed = center_->getPlatformSpeed();
    1265         return randomPosition(0.5*platformSpeed, 1.5*platformSpeed);
     1264        float platformSpeed = center_->getPlatformSpeed();
     1265        return randomPosition(0.5*platformSpeed, 1.5*platformSpeed);
    12661266    }
    12671267
  • code/branches/presentationFS14/src/modules/jump/JumpBoots.cc

    r10078 r10215  
    8383            if(figurePosition.x > rocketPosition.x-width_ && figurePosition.x < rocketPosition.x+width_ && figurePosition.z > rocketPosition.z-height_ && figurePosition.z < rocketPosition.z+height_)
    8484            {
    85                 touchFigure();
     85                touchFigure();
    8686            }
    8787        }
    8888        else if (attachedToFigure_ == true)
    8989        {
    90                 fuel_ -= dt;
    91                 if (fuel_ < 0.0)
    92                 {
    93                         figure_->StopBoots(this);
    94                 }
     90            fuel_ -= dt;
     91            if (fuel_ < 0.0)
     92            {
     93                figure_->StopBoots(this);
     94            }
    9595        }
    9696    }
     
    9898    void JumpBoots::touchFigure()
    9999    {
    100         JumpItem::touchFigure();
     100        JumpItem::touchFigure();
    101101
    102         attachedToFigure_ = figure_->StartBoots(this);
     102        attachedToFigure_ = figure_->StartBoots(this);
    103103    }
    104104}
  • code/branches/presentationFS14/src/modules/jump/JumpEnemy.cc

    r10078 r10215  
    107107        if ((position.x < leftBoundary_ && velocity.x < 0) || (position.x > rightBoundary_ && velocity.x > 0))
    108108        {
    109                 velocity.x = -velocity.x;
     109            velocity.x = -velocity.x;
    110110        }
    111111
    112112        if ((position.z < lowerBoundary_ && velocity.z < 0) || (position.z > upperBoundary_ && velocity.z > 0))
    113113        {
    114                 velocity.z = -velocity.z;
     114            velocity.z = -velocity.z;
    115115        }
    116116
     
    130130            if(figurePosition.x > enemyPosition.x-width_ && figurePosition.x < enemyPosition.x+width_ && figurePosition.z > enemyPosition.z-height_ && figurePosition.z < enemyPosition.z+height_)
    131131            {
    132                 touchFigure();
     132                touchFigure();
    133133            }
    134134        }
     
    158158    void JumpEnemy::touchFigure()
    159159    {
    160         if (dead_ == false)
    161         {
    162                 figure_->CollisionWithEnemy(this);
    163         }
     160        if (dead_ == false)
     161        {
     162            figure_->CollisionWithEnemy(this);
     163        }
    164164    }
    165165}
  • 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}
  • code/branches/presentationFS14/src/modules/jump/JumpFigure.h

    r10078 r10215  
    8585            const float getRocketPos() const
    8686                { return rocketPos_; }
    87                         void setPropellerPos(const float propellerPos)
    88                                 { propellerPos_ = propellerPos; }
    89                         const float getPropellerPos() const
    90                                 { return propellerPos_; }
    91                         void setBootsPos(const float bootsPos)
    92                                 { bootsPos_ = bootsPos; }
    93                         const float getBootsPos() const
    94                                 { return bootsPos_; }
     87            void setPropellerPos(const float propellerPos)
     88                { propellerPos_ = propellerPos; }
     89            const float getPropellerPos() const
     90                { return propellerPos_; }
     91            void setBootsPos(const float bootsPos)
     92                { bootsPos_ = bootsPos; }
     93            const float getBootsPos() const
     94                { return bootsPos_; }
    9595            void setJumpSpeed(const float jumpSpeed)
    9696                { jumpSpeed_ = jumpSpeed; }
  • code/branches/presentationFS14/src/modules/jump/JumpItem.cc

    r10078 r10215  
    8484        if ((position.x < leftBoundary_ && velocity.x < 0) || (position.x > rightBoundary_ && velocity.x > 0))
    8585        {
    86                 velocity.x = -velocity.x;
     86            velocity.x = -velocity.x;
    8787        }
    8888
    8989        if ((position.z < lowerBoundary_ && velocity.z < 0) || (position.z > upperBoundary_ && velocity.z > 0))
    9090        {
    91                 velocity.z = -velocity.z;
     91            velocity.z = -velocity.z;
    9292        }
    9393
  • code/branches/presentationFS14/src/modules/jump/JumpPlatform.cc

    r10078 r10215  
    5656        //initialize sound
    5757        if (GameMode::isMaster())
    58                 {
    59                         defScoreSound_ = new WorldSound(this->getContext());
    60                         defScoreSound_->setVolume(1.0f);
    61                         defBatSound_ = new WorldSound(this->getContext());
    62                         defBatSound_->setVolume(0.4f);
    63                         defBoundarySound_ = new WorldSound(this->getContext());
    64                         defBoundarySound_->setVolume(0.5f);
    65                 }
    66                 else
    67                 {
    68                         defScoreSound_ = 0;
    69                         defBatSound_ = 0;
    70                         defBoundarySound_ = 0;
    71                 }
     58        {
     59            defScoreSound_ = new WorldSound(this->getContext());
     60            defScoreSound_->setVolume(1.0f);
     61            defBatSound_ = new WorldSound(this->getContext());
     62            defBatSound_->setVolume(0.4f);
     63            defBoundarySound_ = new WorldSound(this->getContext());
     64            defBoundarySound_->setVolume(0.5f);
     65        }
     66        else
     67        {
     68            defScoreSound_ = 0;
     69            defBatSound_ = 0;
     70            defBoundarySound_ = 0;
     71        }
    7272
    7373        setPosition(Vector3(0,0,0));
     
    120120            if(figureVelocity.z < 0 && figurePosition.x > platformPosition.x-width_/2 && figurePosition.x < platformPosition.x+width_/2 && figurePosition.z > platformPosition.z-height_/2*tolerance && figurePosition.z < platformPosition.z+height_/2)
    121121            {
    122                 touchFigure();
     122                touchFigure();
    123123            }
    124124        }
  • code/branches/presentationFS14/src/modules/jump/JumpPlatformDisappear.cc

    r10078 r10215  
    7272    void JumpPlatformDisappear::setProperties(bool active)
    7373    {
    74         active_ = active;
     74        active_ = active;
    7575    }
    7676
    7777    bool JumpPlatformDisappear::isActive()
    7878    {
    79         return active_;
     79        return active_;
    8080    }
    8181
    8282    void JumpPlatformDisappear::touchFigure()
    8383    {
    84         if (isActive())
    85         {
    86                 figure_->JumpFromPlatform(this);
    87                 active_ = false;
    88         }
     84        if (isActive())
     85        {
     86            figure_->JumpFromPlatform(this);
     87            active_ = false;
     88        }
    8989    }
    9090}
  • code/branches/presentationFS14/src/modules/jump/JumpPlatformDisappear.h

    r10078 r10215  
    4545    {
    4646        public:
    47             JumpPlatformDisappear(Context* context);
     47            JumpPlatformDisappear(Context* context);
    4848            virtual ~JumpPlatformDisappear();
    4949            virtual void tick(float dt);
  • code/branches/presentationFS14/src/modules/jump/JumpPlatformFake.h

    r10078 r10215  
    4848    {
    4949        public:
    50             JumpPlatformFake(Context* context);
     50            JumpPlatformFake(Context* context);
    5151            virtual ~JumpPlatformFake();
    5252            virtual void tick(float dt);
  • code/branches/presentationFS14/src/modules/jump/JumpPlatformHMove.cc

    r10078 r10215  
    7272
    7373        {
    74                 velocity.x = -velocity.x;
     74            velocity.x = -velocity.x;
    7575        }
    7676
     
    8888    void JumpPlatformHMove::setProperties(float leftBoundary, float rightBoundary, float speed)
    8989    {
    90         leftBoundary_ = leftBoundary;
    91         rightBoundary_ = rightBoundary;
     90        leftBoundary_ = leftBoundary;
     91        rightBoundary_ = rightBoundary;
    9292        setVelocity(Vector3(speed,0,0));
    9393    }
     
    9595    void JumpPlatformHMove::touchFigure()
    9696    {
    97         figure_->JumpFromPlatform(this);
     97        figure_->JumpFromPlatform(this);
    9898    }
    9999}
  • code/branches/presentationFS14/src/modules/jump/JumpPlatformHMove.h

    r10078 r10215  
    4343    {
    4444        public:
    45             JumpPlatformHMove(Context* context);
     45            JumpPlatformHMove(Context* context);
    4646            virtual ~JumpPlatformHMove();
    4747            virtual void tick(float dt);
  • code/branches/presentationFS14/src/modules/jump/JumpPlatformStatic.cc

    r10078 r10215  
    6868    void JumpPlatformStatic::touchFigure()
    6969    {
    70         figure_->JumpFromPlatform(this);
     70        figure_->JumpFromPlatform(this);
    7171    }
    7272}
  • code/branches/presentationFS14/src/modules/jump/JumpPlatformStatic.h

    r10078 r10215  
    4242    {
    4343        public:
    44             JumpPlatformStatic(Context* context);
     44            JumpPlatformStatic(Context* context);
    4545            virtual ~JumpPlatformStatic();
    4646
  • code/branches/presentationFS14/src/modules/jump/JumpPlatformTimer.cc

    r10078 r10215  
    7575        {
    7676
    77                 particleSpawner_ = new ParticleSpawner(getContext());
    78                 particleSpawner_->setSource(effectPath_);
     77            particleSpawner_ = new ParticleSpawner(getContext());
     78            particleSpawner_->setSource(effectPath_);
    7979            particleSpawner_->setLoop(false);
    8080            particleSpawner_->setLOD(LODParticle::Low);
     
    8787    void JumpPlatformTimer::setProperties(float time)
    8888    {
    89         time_ = time;
     89        time_ = time;
    9090    }
    9191
    9292    bool JumpPlatformTimer::isActive(void)
    9393    {
    94         return time_ > 0.0;
     94        return time_ > 0.0;
    9595    }
    9696
    9797    void JumpPlatformTimer::touchFigure()
    9898    {
    99         if (isActive())
    100         {
    101                 figure_->JumpFromPlatform(this);
    102         }
     99        if (isActive())
     100        {
     101            figure_->JumpFromPlatform(this);
     102        }
    103103    }
    104104}
  • code/branches/presentationFS14/src/modules/jump/JumpPlatformTimer.h

    r10078 r10215  
    4949    {
    5050        public:
    51             JumpPlatformTimer(Context* context);
     51            JumpPlatformTimer(Context* context);
    5252            virtual ~JumpPlatformTimer();
    5353            virtual void tick(float dt);
  • code/branches/presentationFS14/src/modules/jump/JumpPlatformVMove.cc

    r10078 r10215  
    7171        if ((position.z < lowerBoundary_ && velocity.z < 0) || (position.z > upperBoundary_ && velocity.z > 0))
    7272        {
    73                 velocity.z = -velocity.z;
     73            velocity.z = -velocity.z;
    7474        }
    7575
     
    8787    void JumpPlatformVMove::setProperties(float lowerBoundary, float upperBoundary, float speed)
    8888    {
    89         lowerBoundary_ = lowerBoundary;
    90         upperBoundary_ = upperBoundary;
     89        lowerBoundary_ = lowerBoundary;
     90        upperBoundary_ = upperBoundary;
    9191
    9292        setVelocity(Vector3(0,0,speed));
     
    9696    void JumpPlatformVMove::touchFigure()
    9797    {
    98         figure_->JumpFromPlatform(this);
     98        figure_->JumpFromPlatform(this);
    9999    }
    100100}
  • code/branches/presentationFS14/src/modules/jump/JumpPlatformVMove.h

    r10078 r10215  
    3939    {
    4040        public:
    41             JumpPlatformVMove(Context* context);
     41            JumpPlatformVMove(Context* context);
    4242            virtual ~JumpPlatformVMove();
    4343            virtual void tick(float dt);
  • code/branches/presentationFS14/src/modules/jump/JumpProjectile.cc

    r10078 r10215  
    7171        Vector3 projectilePosition = getPosition();
    7272
    73                 for (ObjectList<JumpEnemy>::iterator it = ObjectList<JumpEnemy>::begin(); it != ObjectList<JumpEnemy>::end(); ++it)
    74                 {
    75                         Vector3 enemyPosition = it->getPosition();
    76                         float enemyWidth = it->getWidth();
    77                         float enemyHeight = it->getHeight();
     73        for (ObjectList<JumpEnemy>::iterator it = ObjectList<JumpEnemy>::begin(); it != ObjectList<JumpEnemy>::end(); ++it)
     74        {
     75            Vector3 enemyPosition = it->getPosition();
     76            float enemyWidth = it->getWidth();
     77            float enemyHeight = it->getHeight();
    7878
    79                         if(projectilePosition.x > enemyPosition.x-enemyWidth && projectilePosition.x < enemyPosition.x+enemyWidth && projectilePosition.z > enemyPosition.z-enemyHeight && projectilePosition.z < enemyPosition.z+enemyHeight)
    80                         {
    81                                 it->dead_ = true;
    82                         }
    83                 }
     79            if(projectilePosition.x > enemyPosition.x-enemyWidth && projectilePosition.x < enemyPosition.x+enemyWidth && projectilePosition.z > enemyPosition.z-enemyHeight && projectilePosition.z < enemyPosition.z+enemyHeight)
     80            {
     81                it->dead_ = true;
     82            }
     83        }
    8484    }
    8585
  • code/branches/presentationFS14/src/modules/jump/JumpPropeller.cc

    r10078 r10215  
    8383            if(figurePosition.x > PropellerPosition.x-width_ && figurePosition.x < PropellerPosition.x+width_ && figurePosition.z > PropellerPosition.z-height_ && figurePosition.z < PropellerPosition.z+height_)
    8484            {
    85                 touchFigure();
     85                touchFigure();
    8686            }
    8787        }
    8888        else if (attachedToFigure_ == true)
    8989        {
    90                 fuel_ -= dt;
    91                 if (fuel_ < 0.0)
    92                 {
    93                         figure_->StopPropeller(this);
    94                 }
     90            fuel_ -= dt;
     91            if (fuel_ < 0.0)
     92            {
     93                figure_->StopPropeller(this);
     94            }
    9595        }
    9696    }
     
    9898    void JumpPropeller::touchFigure()
    9999    {
    100         JumpItem::touchFigure();
     100        JumpItem::touchFigure();
    101101
    102         attachedToFigure_ = figure_->StartPropeller(this);
    103         if (attachedToFigure_)
    104         {
    105                 setAngularVelocity(Vector3(0,0,10.0));
    106         }
     102        attachedToFigure_ = figure_->StartPropeller(this);
     103        if (attachedToFigure_)
     104        {
     105            setAngularVelocity(Vector3(0,0,10.0));
     106        }
    107107    }
    108108}
  • code/branches/presentationFS14/src/modules/jump/JumpRocket.cc

    r10078 r10215  
    8080            if(figurePosition.x > rocketPosition.x-width_ && figurePosition.x < rocketPosition.x+width_ && figurePosition.z > rocketPosition.z-height_ && figurePosition.z < rocketPosition.z+height_)
    8181            {
    82                 touchFigure();
     82                touchFigure();
    8383            }
    8484        }
    8585        else if (attachedToFigure_ == true)
    8686        {
    87                 fuel_ -= dt;
    88                 if (fuel_ < 0.0)
    89                 {
    90                         figure_->StopRocket(this);
    91                 }
     87            fuel_ -= dt;
     88            if (fuel_ < 0.0)
     89            {
     90                figure_->StopRocket(this);
     91            }
    9292        }
    9393    }
     
    9595    void JumpRocket::touchFigure()
    9696    {
    97         JumpItem::touchFigure();
     97        JumpItem::touchFigure();
    9898
    99         attachedToFigure_ = figure_->StartRocket(this);
     99        attachedToFigure_ = figure_->StartRocket(this);
    100100    }
    101101}
  • code/branches/presentationFS14/src/modules/jump/JumpScore.cc

    r10078 r10215  
    7979                if (player_ != NULL)
    8080                {
    81                         if (showScore_ == true)
    82                         {
    83                         int score = owner_->getScore(player_);
     81                    if (showScore_ == true)
     82                    {
     83                        int score = owner_->getScore(player_);
    8484
    85                         std::string str = multi_cast<std::string>(score);
    86                         setCaption(str);
    87                         }
    88                         else if (showMessages_ == true)
    89                         {
     85                        std::string str = multi_cast<std::string>(score);
     86                        setCaption(str);
     87                    }
     88                    else if (showMessages_ == true)
     89                    {
    9090
    91                         setCaption(owner_->getDead(player_) == true ? gameOverText_ : "");
    92                         }
     91                        setCaption(owner_->getDead(player_) == true ? gameOverText_ : "");
     92                    }
    9393                }
    9494            }
  • code/branches/presentationFS14/src/modules/jump/JumpShield.cc

    r10078 r10215  
    8383            if(figurePosition.x > shieldPosition.x-width_ && figurePosition.x < shieldPosition.x+width_ && figurePosition.z > shieldPosition.z-height_ && figurePosition.z < shieldPosition.z+height_)
    8484            {
    85                 touchFigure();
     85                touchFigure();
    8686            }
    8787        }
    8888        else if (attachedToFigure_ == true)
    8989        {
    90                 fuel_ -= dt;
    91                 if (fuel_ < 0.0)
    92                 {
    93                         figure_->StopShield(this);
    94                 }
     90            fuel_ -= dt;
     91            if (fuel_ < 0.0)
     92            {
     93                figure_->StopShield(this);
     94            }
    9595        }
    9696    }
     
    9898    void JumpShield::touchFigure()
    9999    {
    100         JumpItem::touchFigure();
     100        JumpItem::touchFigure();
    101101
    102         attachedToFigure_ = figure_->StartShield(this);
     102        attachedToFigure_ = figure_->StartShield(this);
    103103    }
    104104}
  • code/branches/presentationFS14/src/modules/jump/JumpSpring.cc

    r10078 r10215  
    7474        if (stretch_ > 1.0)
    7575        {
    76                 stretch_ -= dt;
    77                 setScale3D(1.0, 1.0, stretch_);
     76            stretch_ -= dt;
     77            setScale3D(1.0, 1.0, stretch_);
    7878        }
    7979
     
    8787            if(figureVelocity.z < 0 && figurePosition.x > springPosition.x-width_ && figurePosition.x < springPosition.x+width_ && figurePosition.z > springPosition.z-height_ && figurePosition.z < springPosition.z+height_)
    8888            {
    89                 touchFigure();
     89                touchFigure();
    9090            }
    9191        }
     
    9494    void JumpSpring::touchFigure()
    9595    {
    96         JumpItem::touchFigure();
     96        JumpItem::touchFigure();
    9797
    98         stretch_ = 3.0;
     98        stretch_ = 3.0;
    9999
    100         accelerateFigure();
     100        accelerateFigure();
    101101    }
    102102
    103103    void JumpSpring::accelerateFigure()
    104104    {
    105         if (figure_ != 0)
    106         {
    107                         figure_->JumpFromSpring(this);
    108         }
     105        if (figure_ != 0)
     106        {
     107            figure_->JumpFromSpring(this);
     108        }
    109109    }
    110110}
Note: See TracChangeset for help on using the changeset viewer.