Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/pickupsFS14/src/modules/jump/Jump.cc @ 10074

Last change on this file since 10074 was 10074, checked in by fvultier, 10 years ago

new items added. improved level generator.

File size: 39.8 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Fabian 'x3n' Landau
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29/**
30    @file Jump.cc
31    @brief Implementation of the Jump class.
32*/
33
34#include "Jump.h"
35
36#include "core/CoreIncludes.h"
37#include "core/EventIncludes.h"
38#include "core/command/Executor.h"
39#include "core/config/ConfigValueIncludes.h"
40
41#include "gamestates/GSLevel.h"
42#include "chat/ChatManager.h"
43
44#include "JumpCenterpoint.h"
45#include "JumpPlatform.h"
46#include "JumpPlatformStatic.h"
47#include "JumpPlatformHMove.h"
48#include "JumpPlatformVMove.h"
49#include "JumpPlatformDisappear.h"
50#include "JumpPlatformTimer.h"
51#include "JumpPlatformFake.h"
52#include "JumpProjectile.h"
53#include "JumpEnemy.h"
54#include "JumpFigure.h"
55#include "JumpItem.h"
56#include "JumpSpring.h"
57#include "JumpRocket.h"
58#include "JumpPropeller.h"
59#include "JumpBoots.h"
60#include "JumpShield.h"
61
62#include "infos/PlayerInfo.h"
63
64namespace orxonox
65{
66    // Events to allow to react to scoring of a player, in the level-file.
67    CreateEventName(JumpCenterpoint, right);
68    CreateEventName(JumpCenterpoint, left);
69
70    RegisterUnloadableClass(Jump);
71
72    /**
73    @brief
74        Constructor. Registers and initializes the object.
75    */
76    Jump::Jump(Context* context) : Deathmatch(context)
77    {
78        RegisterObject(Jump);
79
80        center_ = 0;
81        figure_ = 0;
82        camera = 0;
83
84        setHUDTemplate("JumpHUD");
85
86        scoreLimit_ = 10;
87        setConfigValues();
88    }
89
90    /**
91    @brief
92        Destructor. Cleans up, if initialized.
93    */
94    Jump::~Jump()
95    {
96        if (isInitialized())
97        {
98            cleanup();
99        }
100    }
101
102    void Jump::tick(float dt)
103    {
104        SUPER(Jump, tick, dt);
105        if (figure_ != NULL)
106        {
107                Vector3 figurePosition = figure_->getPosition();
108                Vector3 figureVelocity = figure_->getVelocity();
109
110                float boundary = totalScreenShift+center_->getCameraOffset();
111
112                if (figurePosition.z > boundary)
113                {
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())
119                {
120                        screenShiftSinceLastUpdate -= center_->getSectionLength();
121                        if (sectionNumber_ > 2 && sectionNumber_%4 == 0 && rand()%2 == 0)
122                        {
123                                if (addAdventure(adventureNumber_) == false)
124                                                {
125                                        addSection();
126                                                }
127                                else
128                                {
129                                        ++ adventureNumber_;
130                                }
131                        }
132                        else
133                        {
134                                addSection();
135                        }
136                }
137                }
138
139                // Spiel verloren wegen Ansturz?
140                if (figurePosition.z < totalScreenShift - center_->getFieldDimension().y + platformHeight_ && figureVelocity.z < 0)
141                {
142                        end();
143                }
144
145                // Schiessen
146
147                if (figure_->fireSignal)
148                {
149                        figure_->fireSignal = false;
150                        addProjectile(figurePosition.x, figurePosition.z + figure_->getPropellerPos());
151                }
152
153
154                if (camera != NULL)
155                        {
156                                Vector3 cameraPosition = Vector3(0, totalScreenShift, 0);
157                                camera->setPosition(cameraPosition);
158                        }
159                        else
160                        {
161                                orxout() << "No camera found." << endl;
162                                //camera = figure_->getCamera();
163                        }
164        }
165        else
166        {
167                //orxout() << "No figure found." << endl;
168        }
169
170                // Platformen, die zu weit unten sind entfernen
171                ObjectList<JumpPlatform>::iterator beginPlatform = ObjectList<JumpPlatform>::begin();
172                ObjectList<JumpPlatform>::iterator endPlatform = ObjectList<JumpPlatform>::end();
173                ObjectList<JumpPlatform>::iterator itPlatform = beginPlatform;
174                Vector3 platformPosition;
175
176                while (itPlatform != endPlatform)
177                {
178                        platformPosition = itPlatform->getPosition();
179                        if (platformPosition.z < totalScreenShift - center_->getFieldDimension().y)
180                        {
181                                ObjectList<JumpPlatform>::iterator temp = itPlatform;
182                                ++ itPlatform;
183                                center_->detach(*temp);
184                                temp->destroy();
185                        }
186                        else
187                        {
188                                ++ itPlatform;
189                        }
190                }
191
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
206                ObjectList<JumpPlatformDisappear>::iterator beginDisappear = ObjectList<JumpPlatformDisappear>::begin();
207                ObjectList<JumpPlatformDisappear>::iterator endDisappear = ObjectList<JumpPlatformDisappear>::end();
208                ObjectList<JumpPlatformDisappear>::iterator itDisappear = beginDisappear;
209
210                while (itDisappear != endDisappear)
211                {
212                        if (!itDisappear->isActive())
213                        {
214                                ObjectList<JumpPlatformDisappear>::iterator temp = itDisappear;
215                                ++ itDisappear;
216                                center_->detach(*temp);
217                                temp->destroy();
218                        }
219                        else
220                        {
221                                ++ itDisappear;
222                        }
223                }
224
225                // Abgelaufene Timer-Platformen entfernen
226                ObjectList<JumpPlatformTimer>::iterator beginTimer = ObjectList<JumpPlatformTimer>::begin();
227                ObjectList<JumpPlatformTimer>::iterator endTimer = ObjectList<JumpPlatformTimer>::end();
228                ObjectList<JumpPlatformTimer>::iterator itTimer = beginTimer;
229
230                while (itTimer != endTimer)
231                {
232                        if (!itTimer->isActive())
233                        {
234                                ObjectList<JumpPlatformTimer>::iterator temp = itTimer;
235                                ++ itTimer;
236                                center_->detach(*temp);
237                                temp->destroy();
238                        }
239                        else
240                        {
241                                ++ itTimer;
242                        }
243                }
244
245                // Projektile, die zu weit oben sind entfernen
246                ObjectList<JumpProjectile>::iterator beginProjectile = ObjectList<JumpProjectile>::begin();
247                ObjectList<JumpProjectile>::iterator endProjectile = ObjectList<JumpProjectile>::end();
248                ObjectList<JumpProjectile>::iterator itProjectile = beginProjectile;
249                Vector3 projectilePosition;
250
251                while (itProjectile != endProjectile)
252                {
253                        projectilePosition = itProjectile->getPosition();
254                        if (projectilePosition.z > totalScreenShift + 5*center_->getFieldDimension().y)
255                        {
256                                ObjectList<JumpProjectile>::iterator temp = itProjectile;
257                                ++ itProjectile;
258                                center_->detach(*temp);
259                                temp->destroy();
260                        }
261                        else
262                        {
263                                ++ itProjectile;
264                        }
265                }
266
267                // Gegner, die zu weit unten oder abgeschossen sind entfernen
268                ObjectList<JumpEnemy>::iterator beginEnemy = ObjectList<JumpEnemy>::begin();
269                ObjectList<JumpEnemy>::iterator endEnemy = ObjectList<JumpEnemy>::end();
270                ObjectList<JumpEnemy>::iterator itEnemy = beginEnemy;
271                Vector3 enemyPosition;
272
273                while (itEnemy != endEnemy)
274                {
275                        enemyPosition = itEnemy->getPosition();
276                        if (enemyPosition.z < totalScreenShift - center_->getFieldDimension().y || itEnemy->dead_ == true)
277                        {
278                                ObjectList<JumpEnemy>::iterator temp = itEnemy;
279                                ++ itEnemy;
280                                center_->detach(*temp);
281                                temp->destroy();
282                        }
283                        else
284                        {
285                                ++ itEnemy;
286                        }
287                }
288
289                // Items, die zu weit unten sind entfernen
290                ObjectList<JumpItem>::iterator beginItem = ObjectList<JumpItem>::begin();
291                ObjectList<JumpItem>::iterator endItem = ObjectList<JumpItem>::end();
292                ObjectList<JumpItem>::iterator itItem = beginItem;
293                Vector3 itemPosition;
294
295                while (itItem != endItem)
296                {
297                        itemPosition = itItem->getPosition();
298
299                        WorldEntity* parent = itItem->getParent();
300
301                        if (itItem->attachedToFigure_ == false && itemPosition.z < totalScreenShift - center_->getFieldDimension().y && parent == center_)
302                        {
303                                ObjectList<JumpItem>::iterator temp = itItem;
304                                ++ itItem;
305                                center_->detach(*temp);
306                                temp->destroy();
307                        }
308                        else
309                        {
310                                ++ itItem;
311                        }
312                }
313    }
314
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    */
324    void Jump::cleanup()
325    {
326                if (figure_ != NULL)
327                {
328                        //this->figure_->destroy();
329                        //this->figure_ = 0;
330                }
331                camera = 0;
332    }
333
334    void Jump::start()
335    {
336        if (center_ != NULL) // There needs to be a JumpCenterpoint, i.e. the area the game takes place.
337        {
338                        if (figure_ == NULL)
339                        {
340                                figure_ = new JumpFigure(center_->getContext());
341                                figure_->addTemplate(center_->getFigureTemplate());
342                                figure_->InitializeAnimation(center_->getContext());
343                        }
344
345            center_->attach(figure_);
346            figure_->setPosition(0, 0, 0);
347            figure_->setFieldDimension(center_->getFieldDimension());
348        }
349        else // If no centerpoint was specified, an error is thrown and the level is exited.
350        {
351            orxout(internal_error) << "Jump: No Centerpoint specified." << endl;
352            GSLevel::startMainMenu();
353            return;
354        }
355
356        // Set variable to temporarily force the player to spawn.
357        bool temp = bForceSpawn_;
358        bForceSpawn_ = true;
359
360        // Call start for the parent class.
361        Deathmatch::start();
362
363        // Reset the variable.
364        bForceSpawn_ = temp;
365
366        if (figure_ != NULL)
367        {
368                camera = figure_->getCamera();
369        }
370
371        totalScreenShift = 0.0;
372        screenShiftSinceLastUpdate = 0.0;
373        sectionNumber_ = 0;
374        adventureNumber_ = 0;
375
376        addStartSection();
377        addSection();
378        addSection();
379    }
380
381    /**
382    @brief
383        Ends the Jump minigame.
384    */
385    void Jump::end()
386    {
387        cleanup();
388        GSLevel::startMainMenu();
389
390        // Call end for the parent class.
391        Deathmatch::end();
392    }
393
394    /**
395    @brief
396        Spawns the input player.
397    @param player
398        The player to be spawned.
399    */
400    void Jump::spawnPlayer(PlayerInfo* player)
401    {
402        assert(player);
403
404        // If the first (left) bat has no player.
405        if (this->figure_->getPlayer() == NULL)
406        {
407            player->startControl(this->figure_);
408            this->players_[player].state_ = PlayerState::Alive;
409        }
410    }
411
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    */
436    PlayerInfo* Jump::getPlayer() const
437    {
438        if (this->figure_ != NULL)
439        {
440            return this->figure_->getPlayer();
441        }
442        else
443        {
444            return 0;
445        }
446    }
447
448    void Jump::addPlatform(JumpPlatform* newPlatform, std::string platformTemplate, float xPosition, float zPosition)
449    {
450        if (newPlatform != NULL && center_ != NULL)
451                {
452                newPlatform->addTemplate(platformTemplate);
453                newPlatform->setPosition(Vector3(xPosition, 0.0, zPosition));
454                newPlatform->setFigure(this->figure_);
455                center_->attach(newPlatform);
456                }
457    }
458
459    JumpPlatformStatic* Jump::addPlatformStatic(float xPosition, float zPosition)
460    {
461                JumpPlatformStatic* newPlatform = new JumpPlatformStatic(center_->getContext());
462                addPlatform(newPlatform, center_->getPlatformStaticTemplate(), xPosition, zPosition);
463
464                return newPlatform;
465    }
466
467    JumpPlatformHMove* Jump::addPlatformHMove(float xPosition, float zPosition, float leftBoundary, float rightBoundary, float speed)
468    {
469        JumpPlatformHMove* newPlatform = new JumpPlatformHMove(center_->getContext());
470                newPlatform->setProperties(leftBoundary, rightBoundary, speed);
471                addPlatform(newPlatform, center_->getPlatformHMoveTemplate(), xPosition, zPosition);
472
473                return newPlatform;
474    }
475
476    JumpPlatformVMove* Jump::addPlatformVMove(float xPosition, float zPosition, float lowerBoundary, float upperBoundary, float speed)
477    {
478        JumpPlatformVMove* newPlatform = new JumpPlatformVMove(center_->getContext());
479                newPlatform->setProperties(lowerBoundary, upperBoundary, speed);
480                addPlatform(newPlatform, center_->getPlatformVMoveTemplate(), xPosition, zPosition);
481
482                return newPlatform;
483    }
484
485    JumpPlatformDisappear* Jump::addPlatformDisappear(float xPosition, float zPosition)
486    {
487                JumpPlatformDisappear* newPlatform = new JumpPlatformDisappear(center_->getContext());
488                newPlatform->setProperties(true);
489                addPlatform(newPlatform, center_->getPlatformDisappearTemplate(), xPosition, zPosition);
490
491                return newPlatform;
492    }
493
494    JumpPlatformTimer* Jump::addPlatformTimer(float xPosition, float zPosition, float time, float variance)
495    {
496                float additionalTime = (float)(rand()%100)/(100*variance) - variance/2;
497
498        JumpPlatformTimer* newPlatform = new JumpPlatformTimer(center_->getContext());
499                newPlatform->setProperties(time + additionalTime);
500                addPlatform(newPlatform, center_->getPlatformTimerTemplate(), xPosition, zPosition);
501
502                return newPlatform;
503    }
504
505    JumpPlatformFake* Jump::addPlatformFake(float xPosition, float zPosition)
506    {
507                JumpPlatformFake* newPlatform = new JumpPlatformFake(center_->getContext());
508                addPlatform(newPlatform, center_->getPlatformFakeTemplate(), xPosition, zPosition);
509                newPlatform->setAngularVelocity(Vector3(0, 0, 2.0));
510
511                return newPlatform;
512    }
513
514
515    void Jump::addProjectile(float xPosition, float zPosition)
516    {
517        JumpProjectile* newProjectile = new JumpProjectile(center_->getContext());
518        if (newProjectile != NULL && center_ != NULL)
519                {
520                newProjectile->addTemplate(center_->getProjectileTemplate());
521                newProjectile->setPosition(Vector3(xPosition, 0.0, zPosition));
522                newProjectile->setFieldDimension(center_->getFieldDimension());
523                newProjectile->setFigure(this->figure_);
524                center_->attach(newProjectile);
525                }
526    }
527
528    void Jump::addSpring(float xPosition, float zPosition, float leftBoundary, float rightBoundary, float lowerBoundary, float upperBoundary, float xVelocity, float zVelocity)
529    {
530        JumpSpring* newSpring = new JumpSpring(center_->getContext());
531        if (newSpring != NULL && center_ != NULL)
532                {
533                newSpring->addTemplate(center_->getSpringTemplate());
534                newSpring->setPosition(Vector3(xPosition, 0.0, zPosition));
535                newSpring->setProperties(leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity);
536                newSpring->setFigure(figure_);
537                center_->attach(newSpring);
538                }
539    }
540
541    void Jump::addSpring(JumpPlatform* platform)
542    {
543        JumpSpring* newSpring = new JumpSpring(center_->getContext());
544        if (newSpring != NULL && center_ != NULL)
545                {
546                newSpring->addTemplate(center_->getSpringTemplate());
547                newSpring->setPosition(Vector3(0.0, 0.0, 0.0));
548                newSpring->setProperties(-10.0, 10.0, -10.0, 10.0, 0.0, 0.0);
549                newSpring->setFigure(figure_);
550                platform->attach(newSpring);
551                }
552    }
553
554    void Jump::addRocket(float xPosition, float zPosition, float leftBoundary, float rightBoundary, float lowerBoundary, float upperBoundary, float xVelocity, float zVelocity)
555    {
556        JumpRocket* newRocket = new JumpRocket(center_->getContext());
557        if (newRocket != NULL && center_ != NULL)
558                {
559                newRocket->addTemplate(center_->getRocketTemplate());
560                newRocket->setPosition(Vector3(xPosition, 0.0, zPosition));
561                newRocket->setProperties(leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity);
562                newRocket->setFigure(figure_);
563                center_->attach(newRocket);
564                }
565    }
566
567    void Jump::addRocket(JumpPlatform* platform)
568    {
569        JumpRocket* newRocket = new JumpRocket(center_->getContext());
570        if (newRocket != NULL && center_ != NULL)
571                {
572                newRocket->addTemplate(center_->getRocketTemplate());
573                newRocket->setPosition(Vector3(0.0, 0.0, 0.0));
574                newRocket->setProperties(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
575                newRocket->setFigure(figure_);
576                platform->attach(newRocket);
577                }
578    }
579
580    void Jump::addPropeller(float xPosition, float zPosition, float leftBoundary, float rightBoundary, float lowerBoundary, float upperBoundary, float xVelocity, float zVelocity)
581    {
582        JumpPropeller* newPropeller = new JumpPropeller(center_->getContext());
583        if (newPropeller != NULL && center_ != NULL)
584                {
585                newPropeller->addTemplate(center_->getPropellerTemplate());
586                newPropeller->setPosition(Vector3(xPosition, 0.0, zPosition));
587                newPropeller->setProperties(leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity);
588                newPropeller->setFigure(figure_);
589                center_->attach(newPropeller);
590                }
591    }
592
593    void Jump::addPropeller(JumpPlatform* platform)
594    {
595        JumpPropeller* newPropeller = new JumpPropeller(center_->getContext());
596        if (newPropeller != NULL && center_ != NULL)
597                {
598                newPropeller->addTemplate(center_->getPropellerTemplate());
599                newPropeller->setPosition(Vector3(0.0, 0.0, 0.0));
600                newPropeller->setProperties(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
601                newPropeller->setFigure(figure_);
602                platform->attach(newPropeller);
603                }
604    }
605
606    void Jump::addBoots(float xPosition, float zPosition, float leftBoundary, float rightBoundary, float lowerBoundary, float upperBoundary, float xVelocity, float zVelocity)
607    {
608        JumpBoots* newBoots = new JumpBoots(center_->getContext());
609        if (newBoots != NULL && center_ != NULL)
610                {
611                newBoots->addTemplate(center_->getBootsTemplate());
612                newBoots->setPosition(Vector3(xPosition, 0.0, zPosition));
613                newBoots->setProperties(leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity);
614                newBoots->setFigure(figure_);
615                center_->attach(newBoots);
616                }
617    }
618
619    void Jump::addBoots(JumpPlatform* platform)
620    {
621        JumpBoots* newBoots = new JumpBoots(center_->getContext());
622        if (newBoots != NULL && center_ != NULL)
623                {
624                newBoots->addTemplate(center_->getBootsTemplate());
625                newBoots->setPosition(Vector3(0.0, 0.0, 0.0));
626                newBoots->setProperties(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
627                newBoots->setFigure(figure_);
628                platform->attach(newBoots);
629                }
630    }
631
632    void Jump::addShield(float xPosition, float zPosition, float leftBoundary, float rightBoundary, float lowerBoundary, float upperBoundary, float xVelocity, float zVelocity)
633    {
634        JumpShield* newShield = new JumpShield(center_->getContext());
635        if (newShield != NULL && center_ != NULL)
636                {
637                newShield->addTemplate(center_->getShieldTemplate());
638                newShield->setPosition(Vector3(xPosition, 0.0, zPosition));
639                newShield->setProperties(leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity);
640                newShield->setFigure(figure_);
641                center_->attach(newShield);
642                }
643    }
644
645    void Jump::addShield(JumpPlatform* platform)
646    {
647        JumpShield* newShield = new JumpShield(center_->getContext());
648        if (newShield != NULL && center_ != NULL)
649                {
650                newShield->addTemplate(center_->getShieldTemplate());
651                newShield->setPosition(Vector3(0.0, 0.0, 0.0));
652                newShield->setProperties(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
653                newShield->setFigure(figure_);
654                platform->attach(newShield);
655                }
656    }
657
658    void Jump::addEnemy(int type, float xPosition, float zPosition, float leftBoundary, float rightBoundary, float lowerBoundary, float upperBoundary, float xVelocity, float zVelocity)
659    {
660        JumpEnemy* newEnemy = new JumpEnemy(center_->getContext());
661        if (newEnemy != NULL && center_ != NULL)
662                {
663                switch (type)
664                {
665                case 1:
666                        newEnemy->addTemplate(center_->getEnemy1Template());
667                        break;
668                case 2:
669                        newEnemy->addTemplate(center_->getEnemy2Template());
670                        break;
671                case 3:
672                        newEnemy->addTemplate(center_->getEnemy3Template());
673                        break;
674                case 4:
675                        newEnemy->addTemplate(center_->getEnemy4Template());
676                        break;
677                default:
678                        return;
679                }
680
681                newEnemy->setPosition(Vector3(xPosition, 0.0, zPosition));
682                newEnemy->setProperties(leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity);
683                newEnemy->setFieldDimension(center_->getFieldDimension());
684                newEnemy->setFigure(this->figure_);
685                center_->attach(newEnemy);
686                }
687    }
688
689    void Jump::addStartSection()
690    {
691                JumpPlatform* newPlatform;
692
693                float sectionLength = center_->getSectionLength();
694
695                newPlatform = new JumpPlatformStatic(center_->getContext());
696                addPlatform(newPlatform, center_->getPlatformStaticTemplate(), 0.0, -0.05*sectionLength);
697
698                platformWidth_ = newPlatform->getWidth();
699                platformHeight_ = newPlatform->getHeight();
700
701                for (float xPosition = platformWidth_; xPosition <= center_->getFieldDimension().x; xPosition += platformWidth_)
702                {
703                        newPlatform = new JumpPlatformStatic(center_->getContext());
704                        addPlatform(newPlatform, center_->getPlatformStaticTemplate(), xPosition, -0.05*sectionLength);
705                        newPlatform = new JumpPlatformStatic(center_->getContext());
706                        addPlatform(newPlatform, center_->getPlatformStaticTemplate(), -xPosition, -0.05*sectionLength);
707                }
708    }
709
710    void Jump::addSection()
711    {
712        float fieldWidth = center_->getFieldDimension().x;
713        float sectionLength = center_->getSectionLength();
714        float sectionBegin = sectionNumber_ * sectionLength;
715        float sectionEnd = (1 + sectionNumber_) * sectionLength;
716
717        int numI = 6;
718        int numJ = 4;
719
720        enum PlatformType
721        {
722                PLATFORM_EMPTY, PLATFORM_STATIC, PLATFORM_HMOVE, PLATFORM_VMOVE, PLATFORM_DISAPPEAR, PLATFORM_TIMER, PLATFORM_FAKE
723        };
724
725        enum ItemType
726        {
727                ITEM_NOTHING, ITEM_SPRING, ITEM_PROPELLER, ITEM_ROCKET, ITEM_BOOTS, ITEM_SHIELD
728        };
729
730        struct PlatformMatrix
731        {
732                PlatformType type;
733            bool done;
734        } matrix[numI][numJ];
735
736
737                for (int i = 0; i < numI; ++i)
738                {
739                        for (int j = 0; j < numJ; ++j)
740                        {
741                                matrix[i][j].type = PLATFORM_EMPTY;
742                                matrix[i][j].done = false;
743                        }
744                }
745                PlatformType platformtype1;
746                PlatformType platformtype2;
747                ItemType itemType = ITEM_NOTHING;
748
749            if (rand()%2 == 0)
750            {
751                itemType = ITEM_SPRING;
752            }
753            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                }
771
772                switch((sectionNumber_ > 28) ? rand()%29 : rand()%(sectionNumber_+1))
773            {
774            case 0:
775                platformtype1 = PLATFORM_STATIC;
776                platformtype2 = PLATFORM_STATIC;
777                break;
778            case 1:
779                platformtype1 = PLATFORM_STATIC;
780                platformtype2 = PLATFORM_STATIC;
781                break;
782            case 2:
783              platformtype1 = PLATFORM_STATIC;
784              platformtype2 = PLATFORM_HMOVE;
785              break;
786            case 3:
787              platformtype1 = PLATFORM_STATIC;
788              platformtype2 = PLATFORM_DISAPPEAR;
789              break;
790            case 4:
791              platformtype1 = PLATFORM_STATIC;
792              platformtype2 = PLATFORM_VMOVE;
793              break;
794            case 5:
795              platformtype1 = PLATFORM_STATIC;
796              platformtype2 = PLATFORM_TIMER;
797              break;
798            case 6:
799              platformtype1 = PLATFORM_HMOVE;
800              platformtype2 = PLATFORM_STATIC;
801              break;
802            case 7:
803              platformtype1 = PLATFORM_HMOVE;
804              platformtype2 = PLATFORM_HMOVE;
805              break;
806            case 8:
807              platformtype1 = PLATFORM_HMOVE;
808              platformtype2 = PLATFORM_HMOVE;
809              break;
810            case 9:
811              platformtype1 = PLATFORM_HMOVE;
812              platformtype2 = PLATFORM_DISAPPEAR;
813              break;
814            case 10:
815              platformtype1 = PLATFORM_HMOVE;
816              platformtype2 = PLATFORM_VMOVE;
817              break;
818            case 11:
819              platformtype1 = PLATFORM_HMOVE;
820              platformtype2 = PLATFORM_TIMER;
821              break;
822            case 12:
823              platformtype1 = PLATFORM_DISAPPEAR;
824              platformtype2 = PLATFORM_STATIC;
825              break;
826            case 13:
827              platformtype1 = PLATFORM_DISAPPEAR;
828              platformtype2 = PLATFORM_HMOVE;
829              break;
830            case 14:
831              platformtype1 = PLATFORM_DISAPPEAR;
832              platformtype2 = PLATFORM_DISAPPEAR;
833              break;
834            case 15:
835              platformtype1 = PLATFORM_DISAPPEAR;
836              platformtype2 = PLATFORM_DISAPPEAR;
837              break;
838            case 16:
839              platformtype1 = PLATFORM_DISAPPEAR;
840              platformtype2 = PLATFORM_VMOVE;
841              break;
842            case 17:
843              platformtype1 = PLATFORM_DISAPPEAR;
844              platformtype2 = PLATFORM_TIMER;
845              break;
846            case 18:
847              platformtype1 = PLATFORM_VMOVE;
848              platformtype2 = PLATFORM_STATIC;
849              break;
850            case 19:
851              platformtype1 = PLATFORM_VMOVE;
852              platformtype2 = PLATFORM_HMOVE;
853              break;
854            case 20:
855              platformtype1 = PLATFORM_VMOVE;
856              platformtype2 = PLATFORM_DISAPPEAR;
857              break;
858            case 21:
859              platformtype1 = PLATFORM_VMOVE;
860              platformtype2 = PLATFORM_VMOVE;
861              break;
862            case 22:
863              platformtype1 = PLATFORM_VMOVE;
864              platformtype2 = PLATFORM_VMOVE;
865              break;
866            case 23:
867              platformtype1 = PLATFORM_VMOVE;
868              platformtype2 = PLATFORM_TIMER;
869              break;
870            case 24:
871              platformtype1 = PLATFORM_TIMER;
872              platformtype2 = PLATFORM_STATIC;
873              break;
874            case 25:
875              platformtype1 = PLATFORM_TIMER;
876              platformtype2 = PLATFORM_HMOVE;
877              break;
878            case 26:
879              platformtype1 = PLATFORM_TIMER;
880              platformtype2 = PLATFORM_DISAPPEAR;
881              break;
882            case 27:
883                platformtype1 = PLATFORM_TIMER;
884                platformtype2 = PLATFORM_VMOVE;
885                break;
886            case 28:
887                platformtype1 = PLATFORM_TIMER;
888                platformtype2 = PLATFORM_TIMER;
889                break;
890            default:
891                platformtype1 = PLATFORM_TIMER;
892                platformtype2 = PLATFORM_TIMER;
893                break;
894            }
895
896            // Fill Matrix with selected platform types
897            for (int i = 0; i < numI; ++ i)
898            {
899                          for (int j = 0; j < numJ; ++ j)
900                          {
901                                        if (rand()%(sectionNumber_+1) == 0)
902                                        {
903                                            matrix[i][j].type = platformtype1;
904                                        }
905                                        else
906                                        {
907                                                matrix[i][j].type = platformtype2;
908                                        }
909                                        matrix[i][j].done = false;
910                          }
911            }
912
913            // Delete some platforms or replace them with fake platforms
914            if (platformtype1 == platformtype2 && sectionNumber_ > 10)
915            {
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                        }
931            }
932
933            std::vector<JumpPlatform*> platformList;
934
935            for (int i = 0; i < numI; ++ i)
936            {
937                for (int j = 0; j < numJ; ++ j)
938                {
939                    if (matrix[i][j].done == false)
940                    {
941                        float xPosition = 0.0;
942                        float zPosition = 0.0;
943                                float leftBoundary = 0.0;
944                                float rightBoundary = 0.0;
945                                float lowerBoundary = 0.0;
946                                float upperBoundary = 0.0;
947                                float xVelocity = 0.0;
948                                float zVelocity = 0.0;
949
950                        switch(matrix[i][j].type)
951                                    {
952                                    case PLATFORM_EMPTY:
953                                            matrix[i][j].done = true;
954                                            break;
955                                    case PLATFORM_STATIC:
956                                                xPosition = randomXPosition(numJ, j);
957                                                zPosition = sectionBegin + i*sectionLength/numI;
958                                                platformList.push_back(addPlatformStatic(xPosition, zPosition));
959                                                matrix[i][j].done = true;
960                                        break;
961                                    case PLATFORM_FAKE:
962                                                xPosition = randomXPosition(numJ, j);
963                                                zPosition = sectionBegin + i*sectionLength/numI;
964                                                platformList.push_back(addPlatformFake(xPosition, zPosition));
965                                            matrix[i][j].done = true;
966                                        break;
967                                    case PLATFORM_TIMER:
968                                                xPosition = randomXPosition(numJ, j);
969                                                zPosition = sectionBegin + i*sectionLength/numI;
970                                                platformList.push_back(addPlatformTimer(xPosition, zPosition, 10.0, 1.5));
971                                            matrix[i][j].done = true;
972                                        break;
973                                    case PLATFORM_DISAPPEAR:
974                                                xPosition = randomXPosition(numJ, j);
975                                                zPosition = sectionBegin + i*sectionLength/numI;
976                                                platformList.push_back(addPlatformDisappear(xPosition, zPosition));
977                                            matrix[i][j].done = true;
978                                        break;
979                                    case PLATFORM_HMOVE:
980                                        xVelocity = randomSpeed();
981                                            if (j <= numJ-3 && matrix[i][j+1].type == PLATFORM_HMOVE && matrix[i][j+2].type == PLATFORM_HMOVE && rand()%2 == 0)
982                                            {
983                                                leftBoundary = randomXPositionLeft(numJ, j);
984                                                rightBoundary = randomXPositionRight(numJ, j+2);
985                                                xPosition = randomPosition(leftBoundary, rightBoundary);
986                                                        zPosition = sectionBegin + i*sectionLength/numI;
987                                                        platformList.push_back(addPlatformHMove(xPosition, zPosition, leftBoundary, rightBoundary, xVelocity));
988                                                matrix[i][j].done = true;
989                                                matrix[i][j+1].done = true;
990                                                matrix[i][j+2].done = true;
991                                            }
992                                            else if (j <= numJ-2 && matrix[i][j+1].type == PLATFORM_HMOVE && rand()%2 == 0)
993                                            {
994                                                leftBoundary = randomXPositionLeft(numJ, j);
995                                                rightBoundary = randomXPositionRight(numJ, j+1);
996                                                xPosition = randomPosition(leftBoundary, rightBoundary);
997                                                        zPosition = sectionBegin + i*sectionLength/numI;
998                                                        platformList.push_back(addPlatformHMove(xPosition, zPosition, leftBoundary, rightBoundary, xVelocity));
999                                                matrix[i][j].done = true;
1000                                                matrix[i][j+1].done = true;
1001                                            }
1002                                            else
1003                                            {
1004                                                leftBoundary = randomXPositionLeft(numJ, j);
1005                                                rightBoundary = randomXPositionRight(numJ, j);
1006                                                xPosition = randomPosition(leftBoundary, rightBoundary);
1007                                                        zPosition = sectionBegin + i*sectionLength/numI;
1008                                                        platformList.push_back(addPlatformHMove(xPosition, zPosition, leftBoundary, rightBoundary, xVelocity));
1009                                                matrix[i][j].done = true;
1010                                            }
1011                                            break;
1012                                    case PLATFORM_VMOVE:
1013                                        zVelocity = randomSpeed();
1014                                            if (i <= numI-3 && matrix[i+1][j].type == PLATFORM_VMOVE && matrix[i+2][j].type == PLATFORM_VMOVE && rand()%2 == 0)
1015                                            {
1016                                                lowerBoundary = randomZPositionLower(numI, i, sectionBegin, sectionEnd);
1017                                                upperBoundary = randomZPositionUpper(numI, i+2, sectionBegin, sectionEnd);
1018                                                zPosition = randomPosition(lowerBoundary, upperBoundary);
1019                                                xPosition = randomXPosition(numJ, j);
1020                                                platformList.push_back(addPlatformVMove(xPosition, zPosition, lowerBoundary, upperBoundary, zVelocity));
1021                                                matrix[i][j].done = true;
1022                                                matrix[i+1][j].done = true;
1023                                                matrix[i+2][j].done = true;
1024                                            }
1025                                            else if (i <= numI-2 && matrix[i+1][j].type == PLATFORM_VMOVE && rand()%2 == 0)
1026                                            {
1027                                                lowerBoundary = randomZPositionLower(numI, i, sectionBegin, sectionEnd);
1028                                                upperBoundary = randomZPositionUpper(numI, i+1, sectionBegin, sectionEnd);
1029                                                zPosition = randomPosition(lowerBoundary, upperBoundary);
1030                                                xPosition = randomXPosition(numJ, j);
1031                                                platformList.push_back(addPlatformVMove(xPosition, zPosition, lowerBoundary, upperBoundary, zVelocity));
1032                                                matrix[i][j].done = true;
1033                                                matrix[i+1][j].done = true;
1034                                            }
1035                                            else
1036                                            {
1037                                                lowerBoundary = randomZPositionLower(numI, i, sectionBegin, sectionEnd);
1038                                                upperBoundary = randomZPositionUpper(numI, i, sectionBegin, sectionEnd);
1039                                                zPosition = randomPosition(lowerBoundary, upperBoundary);
1040                                                xPosition = randomXPosition(numJ, j);
1041                                                platformList.push_back(addPlatformVMove(xPosition, zPosition, lowerBoundary, upperBoundary, zVelocity));
1042                                                matrix[i][j].done = true;
1043                                            }
1044                                            break;
1045                                    default:
1046                                        // ERROR
1047                                        break;
1048
1049                        }
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                                        }*/
1080                    }
1081                }
1082            }
1083
1084            //Add items
1085        int numNewPlatforms = platformList.size();
1086
1087        if (numNewPlatforms > 0)
1088        {
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                        }
1111        }
1112
1113        if (sectionNumber_ >= 5 && rand()%3 == 0)
1114        {
1115                //  BEWEGUNG Verbessern, Grenzen anpassen !!!!!!!! Auch Vertikale Bewegung zulassen
1116
1117
1118            switch(rand()%4)
1119                {
1120            case 0:
1121                addEnemy(1, randomXPosition(), randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth, fieldWidth, sectionBegin, sectionBegin + sectionLength, 5.0, 0.0);
1122                break;
1123            case 1:
1124                addEnemy(2, randomXPosition(), randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth, fieldWidth, sectionBegin, sectionBegin + sectionLength, 5.0, 0.0);
1125                break;
1126            case 2:
1127                addEnemy(3, randomXPosition(), randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth, fieldWidth, sectionBegin, sectionBegin + sectionLength, 5.0, 0.0);
1128                break;
1129            case 3:
1130                addEnemy(4, randomXPosition(), randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth, fieldWidth, sectionBegin, sectionBegin + sectionLength, 5.0, 0.0);
1131                break;
1132                }
1133        }
1134                ++ sectionNumber_;
1135    }
1136
1137    bool Jump::addAdventure(int number)
1138    {
1139        float fieldWidth = center_->getFieldDimension().x;
1140        float sectionLength = center_->getSectionLength();
1141        float sectionBegin = sectionNumber_ * sectionLength;
1142        sectionLength *= 2;
1143
1144        switch(number)
1145        {
1146        case 0:
1147                        {
1148                                int numI = 10;
1149                                for (int i = 0; i < numI; ++ i)
1150                                {
1151                                        addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth+platformWidth_/2, sectionBegin+i*sectionLength/numI);
1152                                }
1153                                break;
1154                        }
1155        case 1:
1156                {
1157                        int numI = 7;
1158
1159                        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);
1164                        }
1165                        break;
1166                }
1167        case 2:
1168                        {
1169                                int numI = 5;
1170                                for (int i = 0; i < numI; ++ i)
1171                                {
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);
1177                                        addEnemy(4, (2*fieldWidth-platformWidth_)*i/numI-fieldWidth+platformWidth_/2, sectionBegin+sectionLength/2, -fieldWidth, fieldWidth, sectionBegin, sectionBegin + sectionLength, 0.0, 0.0);
1178                                }
1179                                break;
1180                        }
1181        default:
1182                return false;
1183        }
1184        sectionNumber_ +=2;
1185        return true;
1186    }
1187
1188    float Jump::randomXPosition()
1189    {
1190        float fieldWidth = center_->getFieldDimension().x;
1191
1192        return (float)(rand()%(2*(int)fieldWidth)) - fieldWidth;
1193    }
1194
1195    float Jump::randomXPosition(int totalColumns, int culomn)
1196    {
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
1201        float rightBound = leftBound + 2*halfWidth;
1202
1203        return randomPosition(leftBound+platformWidth_/2, rightBound-platformWidth_/2);
1204    }
1205
1206    float Jump::randomXPositionLeft(int totalColumns, int culomn)
1207    {
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
1212        float rightBound = leftBound + 2*halfWidth/3;
1213
1214        return randomPosition(leftBound+platformWidth_/2, rightBound-platformWidth_/2);
1215    }
1216
1217    float Jump::randomXPositionRight(int totalColumns, int culomn)
1218    {
1219        float fieldWidth = center_->getFieldDimension().x; //Width of the half field
1220
1221        float halfWidth = fieldWidth/totalColumns; //Width of a half column
1222        float rightBound = (culomn+1)*halfWidth*2-fieldWidth;
1223        float leftBound = rightBound - 2*halfWidth/3;
1224        return randomPosition(leftBound+platformWidth_/2, rightBound-platformWidth_/2);
1225    }
1226
1227    float Jump::randomZPosition(int totalRows, int row, float sectionBegin, float SectionEnd)
1228    {
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
1232        float upperBound = lowerBound + 2*halfHeight;
1233
1234        return randomPosition(lowerBound+platformHeight_/2, upperBound-platformHeight_/2);
1235    }
1236
1237    float Jump::randomZPositionLower(int totalRows, int row, float sectionBegin, float SectionEnd)
1238    {
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
1242        float upperBound = lowerBound + rowHeight/3;
1243
1244        return randomPosition(lowerBound+platformHeight_/2, upperBound-platformHeight_/2);
1245    }
1246
1247    float Jump::randomZPositionUpper(int totalRows, int row, float sectionBegin, float SectionEnd)
1248    {
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
1252        float upperBound = lowerBound - rowHeight/3;
1253
1254        return randomPosition(lowerBound+platformHeight_/2, upperBound-platformHeight_/2);
1255    }
1256
1257    float Jump::randomPosition(float lowerBoundary, float upperBoundary)
1258    {
1259        if (lowerBoundary >= upperBoundary)
1260        {
1261                return (lowerBoundary + upperBoundary)/2;
1262        }
1263
1264        return (float)(rand()%(int)(100*(upperBoundary - lowerBoundary)))/100 + lowerBoundary;
1265    }
1266
1267    float Jump::randomSpeed()
1268    {
1269        float platformSpeed = center_->getPlatformSpeed();
1270        return randomPosition(0.5*platformSpeed, 1.5*platformSpeed);
1271    }
1272
1273    int Jump::getScore(PlayerInfo* player) const
1274    {
1275        return sectionNumber_ - 2;
1276    }
1277
1278    bool Jump::getDead(PlayerInfo* player) const
1279    {
1280        return figure_->dead_;
1281    }
1282}
Note: See TracBrowser for help on using the repository browser.