Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Legend:

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

    r10074 r10111  
    2121 *
    2222 *   Author:
    23  *      Fabian 'x3n' Landau
     23 *      Fabien Vultier
    2424 *   Co-authors:
    2525 *      ...
     
    2929/**
    3030    @file Jump.cc
    31     @brief Implementation of the Jump class.
     31    @brief This is the gametype for the awesome minigame. Here the level is randomly created, the camera is shifted, ...
    3232*/
    3333
    3434#include "Jump.h"
    35 
    3635#include "core/CoreIncludes.h"
    3736#include "core/EventIncludes.h"
    3837#include "core/command/Executor.h"
    3938#include "core/config/ConfigValueIncludes.h"
    40 
    4139#include "gamestates/GSLevel.h"
    4240#include "chat/ChatManager.h"
    43 
    4441#include "JumpCenterpoint.h"
    4542#include "JumpPlatform.h"
     
    5956#include "JumpBoots.h"
    6057#include "JumpShield.h"
    61 
    6258#include "infos/PlayerInfo.h"
    6359
    6460namespace orxonox
    6561{
    66     // Events to allow to react to scoring of a player, in the level-file.
    67     CreateEventName(JumpCenterpoint, right);
    68     CreateEventName(JumpCenterpoint, left);
    69 
    7062    RegisterUnloadableClass(Jump);
    7163
    72     /**
    73     @brief
    74         Constructor. Registers and initializes the object.
    75     */
    7664    Jump::Jump(Context* context) : Deathmatch(context)
    7765    {
     
    8169        figure_ = 0;
    8270        camera = 0;
    83 
    8471        setHUDTemplate("JumpHUD");
    8572
    86         scoreLimit_ = 10;
    8773        setConfigValues();
    8874    }
    8975
    90     /**
    91     @brief
    92         Destructor. Cleans up, if initialized.
    93     */
    9476    Jump::~Jump()
    9577    {
     
    10385    {
    10486        SUPER(Jump, tick, dt);
     87
    10588        if (figure_ != NULL)
    10689        {
     
    10891                Vector3 figureVelocity = figure_->getVelocity();
    10992
    110                 float boundary = totalScreenShift+center_->getCameraOffset();
     93                float boundary = totalScreenShift_+center_->getCameraOffset();
    11194
    11295                if (figurePosition.z > boundary)
    11396                {
    114                         screenShiftSinceLastUpdate += figurePosition.z - boundary;
    115                         totalScreenShift = figurePosition.z - center_->getCameraOffset();
    116 
    117                 // Falls noetig neue Platformen im neuen Bereich einfuegen
    118                 if (screenShiftSinceLastUpdate > center_->getSectionLength())
     97                        screenShiftSinceLastUpdate_ += figurePosition.z - boundary;
     98                        totalScreenShift_ = figurePosition.z - center_->getCameraOffset();
     99
     100                // Create new platforms if needed
     101                if (screenShiftSinceLastUpdate_ > center_->getSectionLength())
    119102                {
    120                         screenShiftSinceLastUpdate -= center_->getSectionLength();
    121                         if (sectionNumber_ > 2 && sectionNumber_%4 == 0 && rand()%2 == 0)
     103                        if (sectionNumber_ > 2 && sectionNumber_%4 == 0 && rand()%2 == 0 && figure_->propellerActive_ == false && figure_->rocketActive_ == false && addAdventure(adventureNumber_) == true)
    122104                        {
    123                                 if (addAdventure(adventureNumber_) == false)
    124                                                 {
    125                                         addSection();
    126                                                 }
    127                                 else
    128                                 {
    129                                         ++ adventureNumber_;
    130                                 }
     105                                screenShiftSinceLastUpdate_ -= 2*center_->getSectionLength();
     106                                                ++ adventureNumber_;
    131107                        }
    132108                        else
    133109                        {
     110                                screenShiftSinceLastUpdate_ -= center_->getSectionLength();
    134111                                addSection();
    135112                        }
     
    137114                }
    138115
    139                 // Spiel verloren wegen Ansturz?
    140                 if (figurePosition.z < totalScreenShift - center_->getFieldDimension().y + platformHeight_ && figureVelocity.z < 0)
     116                if (figurePosition.z < totalScreenShift_ - center_->getFieldDimension().y + platformHeight_ && figureVelocity.z < 0)
    141117                {
    142                         end();
     118                        figure_->dead_ = true;
    143119                }
    144120
    145                 // Schiessen
    146 
    147                 if (figure_->fireSignal)
     121                if (figure_->fireSignal_ == true)
    148122                {
    149                         figure_->fireSignal = false;
    150                         addProjectile(figurePosition.x, figurePosition.z + figure_->getPropellerPos());
     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                        }
    151132                }
    152133
     
    154135                if (camera != NULL)
    155136                        {
    156                                 Vector3 cameraPosition = Vector3(0, totalScreenShift, 0);
     137                                Vector3 cameraPosition = Vector3(0, totalScreenShift_, 0);
    157138                                camera->setPosition(cameraPosition);
    158139                        }
     
    160141                        {
    161142                                orxout() << "No camera found." << endl;
    162                                 //camera = figure_->getCamera();
    163143                        }
    164144        }
    165         else
    166         {
    167                 //orxout() << "No figure found." << endl;
    168         }
    169 
    170                 // Platformen, die zu weit unten sind entfernen
     145
    171146                ObjectList<JumpPlatform>::iterator beginPlatform = ObjectList<JumpPlatform>::begin();
    172147                ObjectList<JumpPlatform>::iterator endPlatform = ObjectList<JumpPlatform>::end();
     
    177152                {
    178153                        platformPosition = itPlatform->getPosition();
    179                         if (platformPosition.z < totalScreenShift - center_->getFieldDimension().y)
     154                        if (platformPosition.z < totalScreenShift_ - center_->getFieldDimension().y)
    180155                        {
    181156                                ObjectList<JumpPlatform>::iterator temp = itPlatform;
     
    190165                }
    191166
    192                 // DAS GEHT NICHT!!! it++ funktioniert nicht, falls eine Platform geloescht wurde -> Segmentation Error
    193                 /*
    194                 for (ObjectList<JumpPlatformDisappear>::iterator it = ObjectList<JumpPlatformDisappear>::begin(); orxout() << "E" << endl, it != ObjectList<JumpPlatformDisappear>::end(); orxout() << "F" << endl, ++it)
    195                 {
    196                         if (!it->isActive())
    197                         {
    198                                 // Entferne Platform
    199                                 center_->detach(*it);
    200                                 it->destroy();
    201                         }
    202                 }
    203                 */
    204 
    205                 // Deaktivierte Platformen entfernen
     167                // Deleted deactivated platforms
    206168                ObjectList<JumpPlatformDisappear>::iterator beginDisappear = ObjectList<JumpPlatformDisappear>::begin();
    207169                ObjectList<JumpPlatformDisappear>::iterator endDisappear = ObjectList<JumpPlatformDisappear>::end();
     
    223185                }
    224186
    225                 // Abgelaufene Timer-Platformen entfernen
    226187                ObjectList<JumpPlatformTimer>::iterator beginTimer = ObjectList<JumpPlatformTimer>::begin();
    227188                ObjectList<JumpPlatformTimer>::iterator endTimer = ObjectList<JumpPlatformTimer>::end();
     
    243204                }
    244205
    245                 // Projektile, die zu weit oben sind entfernen
    246206                ObjectList<JumpProjectile>::iterator beginProjectile = ObjectList<JumpProjectile>::begin();
    247207                ObjectList<JumpProjectile>::iterator endProjectile = ObjectList<JumpProjectile>::end();
     
    252212                {
    253213                        projectilePosition = itProjectile->getPosition();
    254                         if (projectilePosition.z > totalScreenShift + 5*center_->getFieldDimension().y)
     214                        if (projectilePosition.z > totalScreenShift_ + 5*center_->getFieldDimension().y)
    255215                        {
    256216                                ObjectList<JumpProjectile>::iterator temp = itProjectile;
     
    265225                }
    266226
    267                 // Gegner, die zu weit unten oder abgeschossen sind entfernen
    268227                ObjectList<JumpEnemy>::iterator beginEnemy = ObjectList<JumpEnemy>::begin();
    269228                ObjectList<JumpEnemy>::iterator endEnemy = ObjectList<JumpEnemy>::end();
     
    274233                {
    275234                        enemyPosition = itEnemy->getPosition();
    276                         if (enemyPosition.z < totalScreenShift - center_->getFieldDimension().y || itEnemy->dead_ == true)
     235                        if (enemyPosition.z < totalScreenShift_ - center_->getFieldDimension().y || itEnemy->dead_ == true)
    277236                        {
    278237                                ObjectList<JumpEnemy>::iterator temp = itEnemy;
     
    287246                }
    288247
    289                 // Items, die zu weit unten sind entfernen
    290248                ObjectList<JumpItem>::iterator beginItem = ObjectList<JumpItem>::begin();
    291249                ObjectList<JumpItem>::iterator endItem = ObjectList<JumpItem>::end();
     
    299257                        WorldEntity* parent = itItem->getParent();
    300258
    301                         if (itItem->attachedToFigure_ == false && itemPosition.z < totalScreenShift - center_->getFieldDimension().y && parent == center_)
     259                        if (itItem->attachedToFigure_ == false && itemPosition.z < totalScreenShift_ - center_->getFieldDimension().y && parent == center_)
    302260                        {
    303261                                ObjectList<JumpItem>::iterator temp = itItem;
     
    313271    }
    314272
    315     void Jump::setConfigValues()
    316     {
    317         SetConfigValue(scoreLimit_, 10).description("The player first reaching those points wins.");
    318     }
    319 
    320     /**
    321     @brief
    322         Cleans up the Gametype by destroying the ball and the bats.
    323     */
    324273    void Jump::cleanup()
    325274    {
    326                 if (figure_ != NULL)
    327                 {
    328                         //this->figure_->destroy();
    329                         //this->figure_ = 0;
    330                 }
    331275                camera = 0;
    332276    }
     
    354298        }
    355299
    356         // Set variable to temporarily force the player to spawn.
    357         bool temp = bForceSpawn_;
    358         bForceSpawn_ = true;
    359 
    360300        // Call start for the parent class.
    361301        Deathmatch::start();
    362 
    363         // Reset the variable.
    364         bForceSpawn_ = temp;
    365302
    366303        if (figure_ != NULL)
     
    369306        }
    370307
    371         totalScreenShift = 0.0;
    372         screenShiftSinceLastUpdate = 0.0;
     308        totalScreenShift_ = 0.0;
     309        screenShiftSinceLastUpdate_ = 0.0;
    373310        sectionNumber_ = 0;
    374311        adventureNumber_ = 0;
     
    379316    }
    380317
    381     /**
    382     @brief
    383         Ends the Jump minigame.
    384     */
    385318    void Jump::end()
    386319    {
     
    388321        GSLevel::startMainMenu();
    389322
    390         // Call end for the parent class.
    391323        Deathmatch::end();
    392324    }
    393325
    394     /**
    395     @brief
    396         Spawns the input player.
    397     @param player
    398         The player to be spawned.
    399     */
    400326    void Jump::spawnPlayer(PlayerInfo* player)
    401327    {
    402328        assert(player);
    403329
    404         // If the first (left) bat has no player.
    405         if (this->figure_->getPlayer() == NULL)
     330        if (figure_->getPlayer() == NULL)
    406331        {
    407             player->startControl(this->figure_);
    408             this->players_[player].state_ = PlayerState::Alive;
     332            player->startControl(figure_);
     333            players_[player].state_ = PlayerState::Alive;
    409334        }
    410335    }
    411336
    412     /**
    413     @brief
    414         Is called when the player scored.
    415     */
    416     void Jump::playerScored(PlayerInfo* player, int score)
    417     {
    418 
    419     }
    420 
    421     /**
    422     @brief
    423         Starts the ball with some default speed.
    424     */
    425     void Jump::startBall()
    426     {
    427 
    428     }
    429 
    430     /**
    431     @brief
    432         Get the left player.
    433     @return
    434         Returns a pointer to the player playing on the left. If there is no left player, NULL is returned.
    435     */
    436337    PlayerInfo* Jump::getPlayer() const
    437338    {
     
    494395    JumpPlatformTimer* Jump::addPlatformTimer(float xPosition, float zPosition, float time, float variance)
    495396    {
    496                 float additionalTime = (float)(rand()%100)/(100*variance) - variance/2;
     397                float additionalTime = (float)(rand()%100)/100.0*variance - variance/2.0;
    497398
    498399        JumpPlatformTimer* newPlatform = new JumpPlatformTimer(center_->getContext());
     
    752653            }
    753654            else if (rand()%2 == 0 && sectionNumber_ > 3)
    754                 switch(rand()%4)
    755                 {
    756                 case 0:
    757                         itemType = ITEM_PROPELLER;
    758                         break;
    759                 case 1:
    760                         itemType = ITEM_ROCKET;
    761                         break;
    762                 case 2:
    763                         itemType = ITEM_BOOTS;
    764                         break;
    765                 case 3:
    766                         itemType = ITEM_SHIELD;
    767                         break;
    768                 default:
    769                         break;
    770                 }
     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            }
    771674
    772675                switch((sectionNumber_ > 28) ? rand()%29 : rand()%(sectionNumber_+1))
     
    894797            }
    895798
    896             // Fill Matrix with selected platform types
     799            // Fill matrix with selected platform types
    897800            for (int i = 0; i < numI; ++ i)
    898801            {
    899802                          for (int j = 0; j < numJ; ++ j)
    900803                          {
    901                                         if (rand()%(sectionNumber_+1) == 0)
     804                                        if (rand()%3 == 0)
    902805                                        {
    903806                                            matrix[i][j].type = platformtype1;
     
    911814            }
    912815
    913             // Delete some platforms or replace them with fake platforms
    914             if (platformtype1 == platformtype2 && sectionNumber_ > 10)
     816            if (platformtype1 == platformtype2 && sectionNumber_ > 10 && rand()%2 == 0)
    915817            {
    916                 int j = rand()%numJ;
    917                         if (rand()%2 == 0)
    918                         {
    919                                 for (int i = 0; i <= j; ++ i)
    920                                 {
    921                                     matrix[rand()%numI][rand()%numJ].type = PLATFORM_EMPTY;
    922                                 }
    923                         }
    924                         else
    925                         {
    926                             for (int i = 0; i <= j; ++ i)
    927                                 {
    928                                       matrix[rand()%numI][rand()%numJ].type = PLATFORM_FAKE;
    929                                 }
    930                         }
     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                }
    931879            }
    932880
     
    968916                                                xPosition = randomXPosition(numJ, j);
    969917                                                zPosition = sectionBegin + i*sectionLength/numI;
    970                                                 platformList.push_back(addPlatformTimer(xPosition, zPosition, 10.0, 1.5));
     918                                                platformList.push_back(addPlatformTimer(xPosition, zPosition, 12.0, 1.5));
    971919                                            matrix[i][j].done = true;
    972920                                        break;
     
    1044992                                            break;
    1045993                                    default:
    1046                                         // ERROR
     994                                        //ERROR
    1047995                                        break;
    1048996
    1049997                        }
    1050 
    1051                                         /*if (platformtype1 != PLATFORM_TIMER && platformtype2 != PLATFORM_TIMER)
    1052                                         {
    1053                                                 switch (itemType)
    1054                                                 {
    1055                                                 case ITEM_SPRING:
    1056                                                         addSpring(xPosition, zPosition, leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity);
    1057                                                         itemType = ITEM_NOTHING;
    1058                                                         break;
    1059                                                 case ITEM_ROCKET:
    1060                                                         addRocket(xPosition, zPosition, leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity);
    1061                                                         itemType = ITEM_NOTHING;
    1062                                                         break;
    1063                                                 case ITEM_PROPELLER:
    1064                                                         addPropeller(xPosition, zPosition, leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity);
    1065                                                         itemType = ITEM_NOTHING;
    1066                                                         break;
    1067                                                 case ITEM_BOOTS:
    1068                                                         addBoots(xPosition, zPosition, leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity);
    1069                                                         itemType = ITEM_NOTHING;
    1070                                                         break;
    1071                                                 case ITEM_SHIELD:
    1072                                                         addShield(xPosition, zPosition, leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity);
    1073                                                         itemType = ITEM_NOTHING;
    1074                                                         break;
    1075                                                 default:
    1076                                                         // ERROR
    1077                                                         break;
    1078                                                 }
    1079                                         }*/
    1080998                    }
    1081999                }
     
    10851003        int numNewPlatforms = platformList.size();
    10861004
    1087         if (numNewPlatforms > 0)
     1005        if (rand()%4 == 0)
    10881006        {
    1089                 JumpPlatform* itemPlatform = platformList[rand()%numNewPlatforms];
    1090 
    1091                         switch (ITEM_BOOTS)
    1092                         {
    1093                         case ITEM_SPRING:
    1094                                 addSpring(itemPlatform);
    1095                                 break;
    1096                         case ITEM_ROCKET:
    1097                                 addRocket(itemPlatform);
    1098                                 break;
    1099                         case ITEM_PROPELLER:
    1100                                 addPropeller(itemPlatform);
    1101                                 break;
    1102                         case ITEM_BOOTS:
    1103                                 addBoots(itemPlatform);
    1104                                 break;
    1105                         case ITEM_SHIELD:
    1106                                 addShield(itemPlatform);
    1107                                 break;
    1108                         default:
    1109                                 break;
    1110                         }
     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                }
    11111075        }
    11121076
    11131077        if (sectionNumber_ >= 5 && rand()%3 == 0)
    11141078        {
    1115                 //  BEWEGUNG Verbessern, Grenzen anpassen !!!!!!!! Auch Vertikale Bewegung zulassen
    1116 
    1117 
    11181079            switch(rand()%4)
    11191080                {
    11201081            case 0:
    1121                 addEnemy(1, randomXPosition(), randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth, fieldWidth, sectionBegin, sectionBegin + sectionLength, 5.0, 0.0);
     1082                addEnemy(1, randomXPosition(), randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/3*2, fieldWidth/3*2, sectionBegin, sectionBegin + sectionLength, randomSpeed(), 0.0);
    11221083                break;
    11231084            case 1:
    1124                 addEnemy(2, randomXPosition(), randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth, fieldWidth, sectionBegin, sectionBegin + sectionLength, 5.0, 0.0);
     1085                addEnemy(2, randomXPosition(), randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/3*2, fieldWidth/3*2, sectionBegin, sectionBegin + sectionLength, randomSpeed(), 0.0);
    11251086                break;
    11261087            case 2:
    1127                 addEnemy(3, randomXPosition(), randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth, fieldWidth, sectionBegin, sectionBegin + sectionLength, 5.0, 0.0);
     1088                addEnemy(3, randomXPosition(), randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/3*2, fieldWidth/3*2, sectionBegin, sectionBegin + sectionLength, randomSpeed(), 0.0);
    11281089                break;
    11291090            case 3:
    1130                 addEnemy(4, randomXPosition(), randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth, fieldWidth, sectionBegin, sectionBegin + sectionLength, 5.0, 0.0);
     1091                addEnemy(4, randomXPosition(), randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/3*2, fieldWidth/3*2, sectionBegin, sectionBegin + sectionLength, randomSpeed(), 0.0);
    11311092                break;
    11321093                }
     
    11471108                        {
    11481109                                int numI = 10;
    1149                                 for (int i = 0; i < numI; ++ i)
     1110                                if (rand()%2 == 0)
    11501111                                {
    1151                                         addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth+platformWidth_/2, sectionBegin+i*sectionLength/numI);
     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                                        }
    11521123                                }
    11531124                                break;
     
    11581129
    11591130                        addPlatformStatic(0.0, sectionBegin);
    1160                         for (int i = 1; i < numI; ++ i)
    1161                         {
    1162                                 addPlatformStatic((fieldWidth-platformWidth_/2)*i/numI, sectionBegin+i*sectionLength/numI);
    1163                                 addPlatformStatic(-(fieldWidth-platformWidth_/2)*i/numI, sectionBegin+i*sectionLength/numI);
     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                                }
    11641146                        }
    11651147                        break;
     
    11681150                        {
    11691151                                int numI = 5;
    1170                                 for (int i = 0; i < numI; ++ i)
     1152                                for (int i = 0; i <= numI; ++ i)
    11711153                                {
    1172                                         addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth+platformWidth_/2, sectionBegin);
    1173                                         addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth+platformWidth_/2, sectionBegin+sectionLength/5);
    1174                                         addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth+platformWidth_/2, sectionBegin+sectionLength*2/5);
    1175                                         addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth+platformWidth_/2, sectionBegin+sectionLength*3/5);
    1176                                         addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth+platformWidth_/2, sectionBegin+sectionLength*4/5);
     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);
    11771159                                        addEnemy(4, (2*fieldWidth-platformWidth_)*i/numI-fieldWidth+platformWidth_/2, sectionBegin+sectionLength/2, -fieldWidth, fieldWidth, sectionBegin, sectionBegin + sectionLength, 0.0, 0.0);
    11781160                                }
     1161                                break;
     1162                        }
     1163        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                        }
     1169        case 4:
     1170                        {
     1171                                addPropeller(addPlatformStatic(0.0, sectionBegin));
     1172                                addPropeller(addPlatformStatic(-fieldWidth/2, sectionBegin));
     1173                                addPropeller(addPlatformStatic(fieldWidth/2, sectionBegin));
    11791174                                break;
    11801175                        }
     
    11951190    float Jump::randomXPosition(int totalColumns, int culomn)
    11961191    {
    1197         float fieldWidth = center_->getFieldDimension().x; //Width of the half field
    1198 
    1199         float halfWidth = fieldWidth/totalColumns; //Width of a half column
    1200         float leftBound = culomn*halfWidth*2-fieldWidth; //Left beginning of the column
     1192        float fieldWidth = center_->getFieldDimension().x;
     1193
     1194        float halfWidth = fieldWidth/totalColumns;
     1195        float leftBound = culomn*halfWidth*2-fieldWidth;
    12011196        float rightBound = leftBound + 2*halfWidth;
    12021197
     
    12061201    float Jump::randomXPositionLeft(int totalColumns, int culomn)
    12071202    {
    1208         float fieldWidth = center_->getFieldDimension().x; //Width of the half field
    1209 
    1210         float halfWidth = fieldWidth/totalColumns; //Width of a half column
    1211         float leftBound = culomn*halfWidth*2-fieldWidth; //LeftBeginning of the column
     1203        float fieldWidth = center_->getFieldDimension().x;
     1204
     1205        float halfWidth = fieldWidth/totalColumns;
     1206        float leftBound = culomn*halfWidth*2-fieldWidth;
    12121207        float rightBound = leftBound + 2*halfWidth/3;
    12131208
     
    12171212    float Jump::randomXPositionRight(int totalColumns, int culomn)
    12181213    {
    1219         float fieldWidth = center_->getFieldDimension().x; //Width of the half field
    1220 
    1221         float halfWidth = fieldWidth/totalColumns; //Width of a half column
     1214        float fieldWidth = center_->getFieldDimension().x;
     1215
     1216        float halfWidth = fieldWidth/totalColumns;
    12221217        float rightBound = (culomn+1)*halfWidth*2-fieldWidth;
    12231218        float leftBound = rightBound - 2*halfWidth/3;
     
    12271222    float Jump::randomZPosition(int totalRows, int row, float sectionBegin, float SectionEnd)
    12281223    {
    1229         float fieldHeight = SectionEnd - sectionBegin; //Heigt of the half field
    1230         float halfHeight = fieldHeight/totalRows; //Height of a half row
    1231         float lowerBound = row*halfHeight*2+sectionBegin; //Lower beginning of the row
     1224        float fieldHeight = SectionEnd - sectionBegin;
     1225        float halfHeight = fieldHeight/totalRows;
     1226        float lowerBound = row*halfHeight*2+sectionBegin;
    12321227        float upperBound = lowerBound + 2*halfHeight;
    12331228
     
    12371232    float Jump::randomZPositionLower(int totalRows, int row, float sectionBegin, float SectionEnd)
    12381233    {
    1239         float fieldHeight = SectionEnd - sectionBegin; //Heigt of the half field
    1240         float rowHeight = fieldHeight/totalRows; //Height of a row
    1241         float lowerBound = row*rowHeight+sectionBegin; //Lower beginning of the row
     1234        float fieldHeight = SectionEnd - sectionBegin;
     1235        float rowHeight = fieldHeight/totalRows;
     1236        float lowerBound = row*rowHeight+sectionBegin;
    12421237        float upperBound = lowerBound + rowHeight/3;
    12431238
     
    12471242    float Jump::randomZPositionUpper(int totalRows, int row, float sectionBegin, float SectionEnd)
    12481243    {
    1249         float fieldHeight = SectionEnd - sectionBegin; //Heigt of the half field
    1250         float rowHeight = fieldHeight/totalRows; //Height of a row
    1251         float lowerBound = (row+1)*rowHeight+sectionBegin; //Upper end of the row
     1244        float fieldHeight = SectionEnd - sectionBegin;
     1245        float rowHeight = fieldHeight/totalRows;
     1246        float lowerBound = (row+1)*rowHeight+sectionBegin;
    12521247        float upperBound = lowerBound - rowHeight/3;
    12531248
Note: See TracChangeset for help on using the changeset viewer.