Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10050


Ignore:
Timestamp:
May 8, 2014, 4:14:31 PM (10 years ago)
Author:
fvultier
Message:

Added a whole bunch of code

Location:
code/branches/pickupsFS14
Files:
25 added
6 edited

Legend:

Unmodified
Added
Removed
  • code/branches/pickupsFS14/src/modules/jump/CMakeLists.txt

    r10041 r10050  
    66  JumpPlatformHMove.cc
    77  JumpPlatformVMove.cc
     8  JumpPlatformDisappear.cc
     9  JumpPlatformTimer.cc
     10  JumpPlatformFake.cc
     11  JumpProjectile.cc
     12  JumpEnemy.cc
    813  JumpFigure.cc
     14  JumpItem.cc
    915  JumpCenterpoint.cc
    1016  JumpScore.cc
  • code/branches/pickupsFS14/src/modules/jump/Jump.cc

    r10041 r10050  
    4747#include "JumpPlatformHMove.h"
    4848#include "JumpPlatformVMove.h"
     49#include "JumpPlatformDisappear.h"
     50#include "JumpPlatformTimer.h"
     51#include "JumpPlatformFake.h"
     52#include "JumpProjectile.h"
     53#include "JumpEnemy.h"
    4954#include "JumpFigure.h"
    5055
     
    7075        this->figure_ = 0;
    7176        this->camera = 0;
    72 
    73         platformList.clear();
     77        this->fakeAdded_ = false;
    7478
    7579        this->setHUDTemplate("JumpHUD");
     
    7882        this->starttimer_.setTimer(1.0, false, createExecutor(createFunctor(&Jump::startBall, this)));
    7983        this->starttimer_.stopTimer();
    80 
    8184
    8285        this->scoreLimit_ = 10;
     
    111114
    112115                // Falls noetig neue Platformen im neuen Bereich einfuegen
    113                 if (screenShiftSinceLastUpdate > sectionLength)
     116                if (screenShiftSinceLastUpdate > center_->getSectionLength())
    114117                {
    115                         screenShiftSinceLastUpdate -= sectionLength;
     118                        screenShiftSinceLastUpdate -= center_->getSectionLength();
    116119                    addSection();
    117120                }
     
    124127                }
    125128
     129                // Schiessen
     130                if (figure_->fireSignal)
     131                {
     132                        figure_->fireSignal = false;
     133                        addProjectile(figurePosition.x, figurePosition.z, 0.0, 150.0);
     134                }
     135
    126136
    127137                if (this->camera != NULL)
     
    133143                        {
    134144                                orxout() << "No camera found." << endl;
    135                                 //this->camera = this->figure_->getCamera();
     145                                //camera = figure_->getCamera();
    136146                        }
    137147        }
     
    142152
    143153                // Platformen, die zu weit unten sind entfernen
     154                ObjectList<JumpPlatform>::iterator beginPlatform = ObjectList<JumpPlatform>::begin();
     155                ObjectList<JumpPlatform>::iterator endPlatform = ObjectList<JumpPlatform>::end();
     156                ObjectList<JumpPlatform>::iterator itPlatform = beginPlatform;
    144157                Vector3 platformPosition;
    145                 for (std::list<JumpPlatform*>::iterator it = platformList.begin(); it != platformList.end(); it++)
    146                 {
    147                         // IDEE: Statt durch alle platformen in der Liste, wie im Tutorial durch alle objekte im Spiel iterieren --> eigene liste unnoetig
    148                         platformPosition = (**it).getPosition();
     158
     159                while (itPlatform != endPlatform)
     160                {
     161                        platformPosition = itPlatform->getPosition();
    149162                        if (platformPosition.z < totalScreenShift - center_->getFieldDimension().y)
    150163                        {
     164                                ObjectList<JumpPlatform>::iterator temp = itPlatform;
     165                                ++ itPlatform;
     166                                center_->detach(*temp);
     167                                temp->destroy();
     168                        }
     169                        else
     170                        {
     171                                ++ itPlatform;
     172                        }
     173                }
     174
     175                // DAS GEHT NICHT!!! it++ funktioniert nicht, falls eine Platform geloescht wurde -> Segmentation Error
     176                /*
     177                for (ObjectList<JumpPlatformDisappear>::iterator it = ObjectList<JumpPlatformDisappear>::begin(); orxout() << "E" << endl, it != ObjectList<JumpPlatformDisappear>::end(); orxout() << "F" << endl, ++it)
     178                {
     179                        if (!it->isActive())
     180                        {
    151181                                // Entferne Platform
    152                                 orxout() << "position = " << (**it).getPosition().y << endl;
    153182                                center_->detach(*it);
    154                                 it = platformList.erase(it);
    155                         }
    156                 }
    157     }
    158 
     183                                it->destroy();
     184                        }
     185                }
     186                */
     187
     188                // Deaktivierte Platformen entfernen
     189                ObjectList<JumpPlatformDisappear>::iterator beginDisappear = ObjectList<JumpPlatformDisappear>::begin();
     190                ObjectList<JumpPlatformDisappear>::iterator endDisappear = ObjectList<JumpPlatformDisappear>::end();
     191                ObjectList<JumpPlatformDisappear>::iterator itDisappear = beginDisappear;
     192
     193                while (itDisappear != endDisappear)
     194                {
     195                        if (!itDisappear->isActive())
     196                        {
     197                                ObjectList<JumpPlatformDisappear>::iterator temp = itDisappear;
     198                                ++ itDisappear;
     199                                center_->detach(*temp);
     200                                temp->destroy();
     201                        }
     202                        else
     203                        {
     204                                ++ itDisappear;
     205                        }
     206                }
     207
     208                // Abgelaufene Timer-Platformen entfernen
     209                ObjectList<JumpPlatformTimer>::iterator beginTimer = ObjectList<JumpPlatformTimer>::begin();
     210                ObjectList<JumpPlatformTimer>::iterator endTimer = ObjectList<JumpPlatformTimer>::end();
     211                ObjectList<JumpPlatformTimer>::iterator itTimer = beginTimer;
     212
     213                while (itTimer != endTimer)
     214                {
     215                        if (!itTimer->isActive())
     216                        {
     217                                ObjectList<JumpPlatformTimer>::iterator temp = itTimer;
     218                                ++ itTimer;
     219                                center_->detach(*temp);
     220                                temp->destroy();
     221                        }
     222                        else
     223                        {
     224                                ++ itTimer;
     225                        }
     226                }
     227
     228                // Projektile, die zu weit oben sind entfernen
     229                ObjectList<JumpProjectile>::iterator beginProjectile = ObjectList<JumpProjectile>::begin();
     230                ObjectList<JumpProjectile>::iterator endProjectile = ObjectList<JumpProjectile>::end();
     231                ObjectList<JumpProjectile>::iterator itProjectile = beginProjectile;
     232                Vector3 projectilePosition;
     233
     234                while (itProjectile != endProjectile)
     235                {
     236                        projectilePosition = itProjectile->getPosition();
     237                        if (projectilePosition.z > totalScreenShift + 5*center_->getFieldDimension().y)
     238                        {
     239                                ObjectList<JumpProjectile>::iterator temp = itProjectile;
     240                                ++ itProjectile;
     241                                center_->detach(*temp);
     242                                temp->destroy();
     243                        }
     244                        else
     245                        {
     246                                ++ itProjectile;
     247                        }
     248                }
     249
     250
     251
     252    }
    159253
    160254    void Jump::setConfigValues()
     
    169263    void Jump::cleanup()
    170264    {
    171         /*if (this->ball_ != NULL) // Destroy the ball, if present.
    172         {
    173             this->ball_->destroy();
    174             this->ball_ = 0;
    175         }*/
    176 
    177         // Destroy both bats, if present.
    178265                if (this->figure_ != NULL)
    179266                {
    180                         this->figure_->destroy();
    181                         this->figure_ = 0;
     267                        //this->figure_->destroy();
     268                        //this->figure_ = 0;
    182269                }
    183270                this->camera = 0;
     
    207294                        {
    208295                                this->figure_ = new JumpFigure(this->center_->getContext());
    209                                 this->figure_->addTemplate(this->center_->getBattemplate());
     296                                this->figure_->addTemplate(this->center_->getFigureTemplate());
    210297                        }
    211298
     
    213300            this->center_->attach(this->figure_);
    214301            this->figure_->setPosition(-this->center_->getFieldDimension().x / 2, 0, 0);
    215             this->figure_->yaw(Degree(-90));
    216             this->figure_->setSpeed(this->center_->getBatSpeed());
    217302            this->figure_->setFieldDimension(this->center_->getFieldDimension());
    218             this->figure_->setLength(this->center_->getBatLength());
    219 
    220 
    221303        }
    222304        else // If no centerpoint was specified, an error is thrown and the level is exited.
     
    248330        screenShiftSinceLastUpdate = 0.0;
    249331        sectionNumber = 0;
    250         sectionLength = 100.0;
    251332
    252333        addStartSection();
     
    261342    void Jump::end()
    262343    {
    263         this->cleanup();
     344        cleanup();
     345        GSLevel::startMainMenu();
    264346
    265347        // Call end for the parent class.
     
    393475    }
    394476
    395     void Jump::addPlatform(JumpPlatform* newPlatform, float xPosition, float zPosition)
    396     {
    397         if (newPlatform != NULL)
    398                 {
     477    void Jump::addPlatform(JumpPlatform* newPlatform, std::string platformTemplate, float xPosition, float zPosition)
     478    {
     479        if (newPlatform != NULL && center_ != NULL)
     480                {
     481                newPlatform->addTemplate(platformTemplate);
    399482                newPlatform->setPosition(Vector3(xPosition, 0.0, zPosition));
    400483                newPlatform->setFieldDimension(center_->getFieldDimension());
    401484                newPlatform->setFigure(this->figure_);
    402485                center_->attach(newPlatform);
    403                 platformList.push_front(newPlatform);
     486                }
     487    }
     488
     489    void Jump::addPlatformStatic(float xPosition, float zPosition)
     490    {
     491                if (fakeAdded_ == false && rand()%5 == 0)
     492                {
     493                        addPlatformFake(xPosition, zPosition);
     494                }
     495                else
     496                {
     497                JumpPlatformStatic* newPlatform = new JumpPlatformStatic(center_->getContext());
     498                        addPlatform(newPlatform, center_->getPlatformStaticTemplate(), xPosition, zPosition);
     499                }
     500    }
     501
     502    void Jump::addPlatformHMove(float xPosition, float zPosition, float leftBoundary, float rightBoundary, float speed)
     503    {
     504        JumpPlatformHMove* newPlatform = new JumpPlatformHMove(center_->getContext());
     505                newPlatform->setProperties(leftBoundary, rightBoundary, speed);
     506                addPlatform(newPlatform, center_->getPlatformHMoveTemplate(), xPosition, zPosition);
     507    }
     508
     509    void Jump::addPlatformVMove(float xPosition, float zPosition, float lowerBoundary, float upperBoundary, float speed)
     510    {
     511        JumpPlatformVMove* newPlatform = new JumpPlatformVMove(center_->getContext());
     512                newPlatform->setProperties(lowerBoundary, upperBoundary, speed);
     513                addPlatform(newPlatform, center_->getPlatformVMoveTemplate(), xPosition, zPosition);
     514    }
     515
     516    void Jump::addPlatformDisappear(float xPosition, float zPosition)
     517    {
     518                JumpPlatformDisappear* newPlatform = new JumpPlatformDisappear(center_->getContext());
     519                newPlatform->setProperties(true);
     520                addPlatform(newPlatform, center_->getPlatformDisappearTemplate(), xPosition, zPosition);
     521    }
     522
     523    void Jump::addPlatformTimer(float xPosition, float zPosition, float time, float variance)
     524    {
     525                float additionalTime = (float)(rand()%100)/(100*variance) - variance/2;
     526
     527        JumpPlatformTimer* newPlatform = new JumpPlatformTimer(center_->getContext());
     528                newPlatform->setProperties(time + additionalTime);
     529                addPlatform(newPlatform, center_->getPlatformTimerTemplate(), xPosition, zPosition);
     530    }
     531
     532    void Jump::addPlatformFake(float xPosition, float zPosition)
     533    {
     534        fakeAdded_ = true;
     535
     536                JumpPlatformFake* newPlatform = new JumpPlatformFake(center_->getContext());
     537                addPlatform(newPlatform, center_->getPlatformFakeTemplate(), xPosition, zPosition);
     538                newPlatform->setAngularVelocity(Vector3(0, 0, 2.0));
     539    }
     540
     541
     542    void Jump::addProjectile(float xPosition, float zPosition, float xVelocity, float zVelocity)
     543    {
     544        JumpProjectile* newProjectile = new JumpProjectile(center_->getContext());
     545        if (newProjectile != NULL && center_ != NULL)
     546                {
     547                newProjectile->addTemplate(center_->getProjectileTemplate());
     548                newProjectile->setPosition(Vector3(xPosition, 0.0, zPosition));
     549                newProjectile->setVelocity(Vector3(xVelocity, 0.0, zVelocity));
     550                newProjectile->setFieldDimension(center_->getFieldDimension());
     551                newProjectile->setFigure(this->figure_);
     552                center_->attach(newProjectile);
     553                }
     554    }
     555
     556    void Jump::addEnemy1(float xPosition, float zPosition, float leftBoundary, float rightBoundary, float lowerBoundary, float upperBoundary, float xVelocity, float zVelocity)
     557    {
     558        JumpEnemy* newEnemy = new JumpEnemy(center_->getContext());
     559        if (newEnemy != NULL && center_ != NULL)
     560                {
     561                newEnemy->addTemplate(center_->getEnemy1Template());
     562                newEnemy->setPosition(Vector3(xPosition, 0.0, zPosition));
     563                newEnemy->setProperties(leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity);
     564                newEnemy->setFieldDimension(center_->getFieldDimension());
     565                newEnemy->setFigure(this->figure_);
     566                center_->attach(newEnemy);
    404567                }
    405568    }
     
    409572                JumpPlatform* newPlatform;
    410573
    411                 for (float xPosition = -center_->getFieldDimension().x; xPosition <= center_->getFieldDimension().x; xPosition += 12.0)
     574                float sectionLength = center_->getSectionLength();
     575                float platformLength = center_->getPlatformLength();
     576
     577                for (float xPosition = -center_->getFieldDimension().x; xPosition <= center_->getFieldDimension().x; xPosition += platformLength)
    412578                {
    413579                        newPlatform = new JumpPlatformStatic(center_->getContext());
    414                         addPlatform(newPlatform, xPosition, -0.05*sectionLength);
     580                        addPlatform(newPlatform, center_->getPlatformStaticTemplate(), xPosition, -0.05*sectionLength);
    415581                }
    416582    }
     
    419585    {
    420586        float fieldWidth = center_->getFieldDimension().x;
    421         float fieldHeight = center_->getFieldDimension().y;
     587        float sectionLength = center_->getSectionLength();
     588        float platformLength = center_->getPlatformLength();
    422589
    423590        float sectionBegin = sectionNumber * sectionLength;
    424591        float sectionEnd = (1.0 + sectionNumber) * sectionLength;
    425592
    426         JumpPlatformStatic* newPlatformStatic;
    427         JumpPlatformHMove* newPlatformHMove;
    428         JumpPlatformVMove* newPlatformVMove;
    429 
    430                 switch (rand()%3)
     593                int randPos1 = rand()%10;
     594                int randPos2 = rand()%10;
     595                int randPos3 = rand()%10;
     596                int randPos4 = rand()%10;
     597
     598                if (rand()%5 == 0)
     599                {
     600                        addEnemy1(randomXPosition(), sectionBegin + sectionLength/10, -fieldWidth, fieldWidth, sectionBegin + sectionLength/10, sectionBegin + sectionLength/10, 5.0, 0.0);
     601                }
     602
     603        switch (rand()%12)
    431604                {
    432605                case 0:
    433                         for (int i = 0; i < 10; ++i)
    434                         {
    435                                 newPlatformStatic = new JumpPlatformStatic(center_->getContext());
    436                                 addPlatform(newPlatformStatic, randomXPosition(), sectionBegin + i*sectionLength/10);
     606                        // Doppelt statisch
     607                        for (int i = 0; i < 10; ++i)
     608                        {
     609                                for (int j = 0; j < 2; ++j)
     610                                {
     611                                        addPlatformStatic(randomXPosition(2, j), sectionBegin + i*sectionLength/10);
     612                                }
    437613                        }
    438614                        break;
    439615                case 1:
    440                         for (int i = 0; i < 10; ++i)
    441                         {
    442                                 newPlatformHMove = new JumpPlatformHMove(center_->getContext());
    443                                 newPlatformHMove->setProperties(-fieldWidth, fieldWidth, 30.0);
    444                                 addPlatform(newPlatformHMove, randomXPosition(), sectionBegin + i*sectionLength/10);
    445                         }
    446 
     616                        // Dreifach statisch
     617                        for (int i = 0; i < 10; ++i)
     618                        {
     619                                for (int j = 0; j < 3; ++j)
     620                                {
     621                                        addPlatformStatic(randomXPosition(3, j), sectionBegin + i*sectionLength/10);
     622                                }
     623                        }
    447624                        break;
    448625                case 2:
    449                         for (int i = 0; i < 10; ++i)
    450                         {
    451                                 newPlatformVMove = new JumpPlatformVMove(center_->getContext());
    452                                 newPlatformVMove->setProperties(sectionBegin, sectionEnd, 20.0);
    453                                 addPlatform(newPlatformVMove, -fieldWidth + i*fieldWidth*2/10, randomYPosition(sectionBegin, sectionEnd));
     626                        // statisch mit 1 horizontal
     627                        for (int i = 0; i < 10; ++i)
     628                        {
     629                                if (i == randPos1)
     630                                {
     631                                        addPlatformHMove(randomXPosition(), sectionBegin + i*sectionLength/10, -fieldWidth, fieldWidth, 30.0);
     632                                }
     633                                else
     634                                {
     635                                        addPlatformStatic(randomXPosition(), sectionBegin + i*sectionLength/10);
     636                                }
     637                        }
     638                        break;
     639                case 3:
     640                        // statisch mit 2 horizontal
     641                        for (int i = 0; i < 10; ++i)
     642                        {
     643                                if (i == randPos1 || i == randPos2)
     644                                {
     645                                        addPlatformHMove(randomXPosition(), sectionBegin + i*sectionLength/10, -fieldWidth, fieldWidth, 30.0);
     646                                }
     647                                else
     648                                {
     649                                        addPlatformStatic(randomXPosition(), sectionBegin + i*sectionLength/10);
     650                                }
     651                        }
     652                        break;
     653                case 4:
     654                        // statisch mit 3 horizontal
     655                        for (int i = 0; i < 10; ++i)
     656                        {
     657                                if (i == randPos1 || i == randPos2 || i == randPos3)
     658                                {
     659                                        addPlatformHMove(randomXPosition(), sectionBegin + i*sectionLength/10, -fieldWidth, fieldWidth, 30.0);
     660                                }
     661                                else
     662                                {
     663                                        addPlatformStatic(randomXPosition(), sectionBegin + i*sectionLength/10);
     664                                }
     665                        }
     666                        break;
     667                case 5:
     668                        // statisch mit 4 horizontal
     669                        for (int i = 0; i < 10; ++i)
     670                        {
     671                                if (i == randPos1 || i == randPos2 || i == randPos3 || i == randPos4)
     672                                {
     673                                        addPlatformHMove(randomXPosition(), sectionBegin + i*sectionLength/10, -fieldWidth, fieldWidth, 30.0);
     674                                }
     675                                else
     676                                {
     677                                        addPlatformStatic(randomXPosition(), sectionBegin + i*sectionLength/10);
     678                                }
     679                        }
     680                        break;
     681                        // Einfach horizontal
     682                case 6:
     683                        for (int i = 0; i < 10; ++i)
     684                        {
     685                                addPlatformHMove(randomXPosition(), sectionBegin + i*sectionLength/10, -fieldWidth, fieldWidth, 30.0);
     686                        }
     687                        break;
     688                        // Doppelt horizontal
     689                case 7:
     690                        for (int i = 0; i < 10; ++i)
     691                        {
     692                                        float mediumPos = randomXPosition(3, 1);
     693                                        addPlatformHMove(randomXPosition(3, 0), sectionBegin + i*sectionLength/10, -fieldWidth, mediumPos - platformLength/2, 30.0);
     694                                        addPlatformHMove(randomXPosition(3, 2), sectionBegin + i*sectionLength/10, mediumPos+platformLength/2, fieldWidth, 30.0);
     695                        }
     696                        break;
     697                        // Einfach vertikal
     698                case 8:
     699                        for (int i = 0; i < 7; ++i)
     700                        {
     701                                addPlatformVMove(-fieldWidth + i*fieldWidth*2/10, randomYPosition(sectionBegin, sectionEnd), sectionBegin, sectionEnd, 20.0);
     702                        }
     703                        break;
     704                        // Doppelt vertikal
     705                case 9:
     706                        for (int i = 0; i < 14; ++i)
     707                        {
     708                                addPlatformVMove(-fieldWidth + i*fieldWidth*2/10, randomYPosition(sectionBegin, sectionEnd), sectionBegin, sectionEnd, 20.0);
     709                        }
     710                        break;
     711                        // Doppelt verschwindend
     712                case 10:
     713                        for (int i = 0; i < 10; ++i)
     714                        {
     715                                for (int j = 0; j < 2; ++j)
     716                                {
     717                                        addPlatformDisappear(randomXPosition(2, j), randomYPosition(sectionBegin, sectionEnd));
     718                                }
     719                        }
     720                        break;
     721                        // Doppelt Timer
     722                case 11:
     723                        for (int i = 0; i < 10; ++i)
     724                        {
     725                                for (int j = 0; j < 2; ++j)
     726                                {
     727                                        addPlatformTimer(randomXPosition(2, j), randomYPosition(sectionBegin, sectionEnd), 6.0, 1.5);
     728                                }
    454729                        }
    455730                        break;
     
    457732                orxout() << "new section added with number "<< sectionNumber << endl;
    458733
     734                fakeAdded_ = false;
     735
    459736                ++ sectionNumber;
    460737    }
     
    462739    float Jump::randomXPosition()
    463740    {
    464         return (float)(rand()%(2*(int)center_->getFieldDimension().x)) - center_->getFieldDimension().x;
     741        float fieldWidth = center_->getFieldDimension().x;
     742
     743        return (float)(rand()%(2*(int)fieldWidth)) - fieldWidth;
     744    }
     745
     746    float Jump::randomXPosition(int totalColumns, int culomn)
     747    {
     748        float fieldWidth = center_->getFieldDimension().x;
     749
     750        float width = 2*fieldWidth/totalColumns;
     751        float leftBound = culomn*width-fieldWidth;
     752        float platformLength = center_->getPlatformLength();
     753
     754        return (float)(rand()%(int)(width-platformLength)) + leftBound + platformLength/2;
    465755    }
    466756
    467757    float Jump::randomYPosition(float lowerBoundary, float upperBoundary)
    468758    {
    469         return (float)(rand()%(int)(upperBoundary - lowerBoundary)) + lowerBoundary;
     759        return (float)(rand()%(int)(100*(upperBoundary - lowerBoundary)))/100 + lowerBoundary;
    470760    }
    471761
  • code/branches/pickupsFS14/src/modules/jump/Jump.h

    r10041 r10050  
    8080            virtual void playerScored(PlayerInfo* player, int score = 1); //!< Is called when the player scored.
    8181
    82             virtual void addPlatform(JumpPlatform* newPlatform, float xPosition, float zPosition);
    83             virtual void addStartSection();
    84             virtual void addSection();
    85             virtual float randomXPosition();
    86             virtual float randomYPosition(float lowerBoundary, float upperBoundary);
    87 
    8882            int getScore(PlayerInfo* player) const;
    8983
     
    10498            void cleanup(); //!< Cleans up the Gametype by destroying the ball and the bats.
    10599
     100            virtual void addPlatform(JumpPlatform* newPlatform, std::string platformTemplate, float xPosition, float zPosition);
     101
     102            virtual void addPlatformStatic(float xPosition, float zPosition);
     103            virtual void addPlatformHMove(float xPosition, float zPosition, float leftBoundary, float rightBoundary, float speed);
     104            virtual void addPlatformVMove(float xPosition, float zPosition, float lowerBoundary, float upperBoundary, float speed);
     105            virtual void addPlatformDisappear(float xPosition, float zPosition);
     106            virtual void addPlatformTimer(float xPosition, float zPosition, float time, float variance);
     107            virtual void addPlatformFake(float xPosition, float zPosition);
     108            virtual void addProjectile(float xPosition, float zPosition, float xVelocity, float zVelocity);
     109            virtual void addEnemy1(float xPosition, float zPosition, float leftBoundary, float rightBoundary, float lowerBoundary, float upperBoundary, float xVelocity, float zVelocity);
     110
     111            virtual void addStartSection();
     112            virtual void addSection();
     113
     114            virtual float randomXPosition();
     115            virtual float randomXPosition(int totalColumns, int culomn);
     116            virtual float randomYPosition(float lowerBoundary, float upperBoundary);
     117
    106118            WeakPtr<JumpCenterpoint> center_; //!< The playing field.
    107             //WeakPtr<JumpPlatform> ball_; //!< The Jump ball.
    108119            WeakPtr<JumpFigure> figure_; //!< The two bats.
    109120            WeakPtr<Camera> camera;
     
    113124            float totalScreenShift;
    114125            float screenShiftSinceLastUpdate;
    115             float sectionLength;
    116126            int sectionNumber;
    117             std::list<JumpPlatform*> platformList;
     127
     128            bool fakeAdded_;
    118129    };
    119130}
  • code/branches/pickupsFS14/src/modules/jump/JumpPlatform.cc

    r10041 r10050  
    5959
    6060        this->figure_ = 0;
    61         this->bDeleteBats_ = false;
    62         this->batID_ = new unsigned int[1];
    63         this->batID_[0] = OBJECTID_UNKNOWN;
    64         this->relMercyOffset_ = 0.05f;
    65 
    66         this->registerVariables();
    6761
    6862        //initialize sound
     
    8680        this->setVelocity(Vector3(0,0,0));
    8781        this->setAcceleration(Vector3(0,0,0));
    88 
    89         model = NULL;
    9082    }
    9183
     
    116108    /**
    117109    @brief
    118         Register variables to synchronize over the network.
    119     */
    120     void JumpPlatform::registerVariables()
    121     {
    122         registerVariable( this->fieldWidth_ );
    123         registerVariable( this->fieldHeight_ );
    124         registerVariable( this->relMercyOffset_ );
    125         registerVariable( this->batID_[0] );
    126         //registerVariable( this->batID_[1], VariableDirection::ToClient, new NetworkCallback<JumpPlatform>( this, &JumpPlatform::applyBats) );
    127     }
    128 
    129     /**
    130     @brief
    131110        Is called every tick.
    132111        Handles the movement of the ball and its interaction with the boundaries and bats.
     
    147126            if(figureVelocity.z < 0 && figurePosition.x > platformPosition.x-10 && figurePosition.x < platformPosition.x+10 && figurePosition.z > platformPosition.z-4 && figurePosition.z < platformPosition.z+4)
    148127            {
    149                 figure_->JumpFromPlatform(200.0f);
     128                touchFigure();
    150129            }
    151130        }
     
    249228    void JumpPlatform::setFigure(WeakPtr<JumpFigure> newFigure)
    250229    {
    251         if (this->bDeleteBats_) // If there are already some bats, delete them.
    252         {
    253             delete this->figure_;
    254             this->bDeleteBats_ = false;
    255         }
    256 
    257         this->figure_ = newFigure;
    258         // Also store their object IDs, for synchronization.
    259         this->batID_[0] = this->figure_->getObjectID();
    260     }
    261 
    262     /**
    263     @brief
    264         Get the bats over the network.
    265     */
    266     void JumpPlatform::applyBats()
    267     {
    268         // Make space for the bats, if they don't exist, yet.
    269         if (this->figure_ == NULL)
    270         {
    271             this->figure_ = *(new WeakPtr<JumpFigure>);
    272             this->bDeleteBats_ = true;
    273         }
    274 
    275         if (this->batID_[0] != OBJECTID_UNKNOWN)
    276         {
    277                 // WAR IM PONG NICHT AUSKOMMENTIERT!!!
    278             //this->figure_ = orxonox_cast<JumpFigure>(Synchronisable::getSynchronisable(this->batID_[0]));
    279         }
     230        figure_ = newFigure;
     231    }
     232
     233    void JumpPlatform::accelerateFigure()
     234    {
     235        figure_->JumpFromPlatform(this);
     236    }
     237
     238    void JumpPlatform::touchFigure()
     239    {
     240
    280241    }
    281242
  • code/branches/pickupsFS14/src/modules/jump/JumpPlatform.h

    r10041 r10050  
    8989
    9090            void setFigure(WeakPtr<JumpFigure> bats); //!< Set the bats for the ball.
    91             void applyBats(); //!< Get the bats over the network.
     91
     92            virtual void accelerateFigure();
     93            virtual void touchFigure();
    9294
    9395            static const float MAX_REL_Z_VELOCITY;
     
    101103
    102104        protected:
    103             void registerVariables();
    104 
    105105            float fieldWidth_; //!< The width of the playing field.
    106106            float fieldHeight_; //!< The height of the playing field.
    107107            WeakPtr<JumpFigure> figure_; //!< An array with the two bats.
    108             bool bDeleteBats_; //!< Bool, to keep track, of whether this->bat_ exists or not.
    109             unsigned int* batID_; //!< The object IDs of the bats, to be able to synchronize them over the network.
    110             float relMercyOffset_; //!< Offset, that makes the player not loose, when, in all fairness, he would have.
    111108            WorldSound* defScoreSound_;
    112109            WorldSound* defBatSound_;
    113             Model* model;
    114110            WorldSound* defBoundarySound_;
    115111    };
  • code/branches/pickupsFS14/src/modules/jump/JumpPrereqs.h

    r10041 r10050  
    7373    class JumpPlatformHMove;
    7474    class JumpPlatformVMove;
     75    class JumpPlatformDisappear;
     76    class JumpPlatformTimer;
     77    class JumpPlatformFake;
     78    class JumpProjectile;
     79    class JumpEnemy;
     80    class JumpItem;
    7581    class JumpFigure;
    7682    class JumpCenterpoint;
Note: See TracChangeset for help on using the changeset viewer.