Index: code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrx.cc
===================================================================
--- code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrx.cc	(revision 11521)
+++ code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrx.cc	(revision 11529)
@@ -47,4 +47,5 @@
 #include "FlappyOrxCenterPoint.h"
 #include "FlappyOrxShip.h"
+#include "FlappyOrxAsteroid.h"
 
 #include "core/command/ConsoleCommand.h"
@@ -67,32 +68,25 @@
         multiplier = 1;
         b_combo = false;
-        
+        this->spawnDistance=300;
+        this->tubeOffsetX=500;
         this->setHUDTemplate("FlappyOrxHUD");
     }
 
+    void FlappyOrx::updatePlayerPos(int x){
+        if(this->tubes.size()==0||x-this->tubes.back()-tubeOffsetX>spawnDistance){
+            spawnTube();
+            this->tubes.push(x+tubeOffsetX);
+        }
+        if(this->tubes.size()!=0&&x>this->tubes.front()){
+            this->tubes.pop();
+            levelUp();
+        }
+    }
+
     void FlappyOrx::levelUp()
     {
         level++;
-        if (getPlayer() != nullptr)
-        {
-            for (int i = 0; i < 7; i++)
-            {
-
-                WeakPtr<ExplosionPart> chunk5 = new ExplosionPart(this->center_->getContext());
-                chunk5->setPosition(this->center_->getPosition());
-                chunk5->setVelocity(Vector3(1000, 0, 0));  //player->getVelocity()
-                chunk5->setScale(10);
-                chunk5->setEffect1("Orxonox/explosion2b");
-                chunk5->setEffect2("Orxonox/smoke6");
-                chunk5->setMinSpeed(0);
-                chunk5->setMaxSpeed(0);
-                chunk5->Explode();
-
-            }
-        }
-        addPoints(multiplier * 42);
-        multiplier *= 2;
-        toggleShowLevel();
-        showLevelTimer.setTimer(1.0f, false, createExecutor(createFunctor(&FlappyOrx::toggleShowLevel, this)));
+        //toggleShowLevel();
+        //showLevelTimer.setTimer(3.0f, false, createExecutor(createFunctor(&FlappyOrx::toggleShowLevel, this)));
     }
 
@@ -108,5 +102,62 @@
     }
 
-
+    void FlappyOrx::spawnTube()
+    {
+        int space = 90;
+        int height = (float(rand())/RAND_MAX-0.5)*(280-space);
+           
+        if (getPlayer() == nullptr)
+            return;
+
+        Vector3 pos = player->getPosition();
+
+        asteroidField(pos.x+tubeOffsetX,height-space/2,0.8);
+        asteroidField(pos.x+tubeOffsetX,height+space/2,-0.8);   
+    }
+
+    void FlappyOrx::asteroidField(int x, int y, float slope){
+        int r = 20;
+        int noadd = 0;
+
+        ClearAsteroids();
+        Circle newAsteroid = Circle();
+        while(r>0){
+            if(slope>0)
+                newAsteroid.y=float(rand())/RAND_MAX*(150+y)-150;
+            else
+                newAsteroid.y=float(rand())/RAND_MAX*(150-y)+y;
+            
+            newAsteroid.x=x+(float(rand())/RAND_MAX-0.5)*(y-newAsteroid.y)/slope;
+            newAsteroid.r=r;
+           
+            int i = addIfPossible(newAsteroid);
+            if(i==0)
+                noadd++;
+            else if(i==2)
+                r=0;
+            if(noadd>=5){
+                noadd=0;
+                r-=5;
+            }
+        }
+    }
+
+    void FlappyOrx::createAsteroid(Circle &c){
+        orxout() << "created Asteroid at x="<<c.x<<" y="<<c.y << std::endl;
+        MovableEntity* newAsteroid = new MovableEntity(this->center_->getContext());
+        if(c.r<=5)
+            newAsteroid->addTemplate(Asteroid5[rand()%6]);
+        else if(c.r<=10)
+            newAsteroid->addTemplate(Asteroid10[rand()%6]);
+        else if(c.r<=15)
+            newAsteroid->addTemplate(Asteroid15[rand()%6]);
+        else
+            newAsteroid->addTemplate(Asteroid20[rand()%6]);
+        
+        newAsteroid->setPosition(Vector3(c.x, 0, c.y));
+        newAsteroid->setOrientation(Vector3::UNIT_Z, Degree(rand()%360));
+        newAsteroid->setOrientation(Vector3::UNIT_Y, Degree(rand()%360));
+
+    }
 
     void FlappyOrx::setCenterpoint(FlappyOrxCenterPoint* center)
