Index: code/branches/tgidronFS16/src/modules/hover/Hover.cc
===================================================================
--- code/branches/tgidronFS16/src/modules/hover/Hover.cc	(revision 11184)
+++ code/branches/tgidronFS16/src/modules/hover/Hover.cc	(revision 11192)
@@ -64,4 +64,6 @@
         cellHeight = 0;
 
+        bShowLevel = false;
+
         totFlags = 0;
 
@@ -80,4 +82,17 @@
             cellSize = this->origin_->getCellSize();
             cellHeight = this->origin_->getCellHeight();
+
+            /*
+            bool occupiedCells[numCells][numCells];
+
+            for(int i = 0; i < numCells; i++)
+            {
+                for(int j = 0; j < numCells; j++)
+                {
+                    occupiedCells[i][j] = false;
+                }
+            }
+            occupiedCells[0][0] = true;
+            */
 
             MazeGenerator generator(numCells);
@@ -93,4 +108,16 @@
                 (new HoverWall(origin_->getContext()))->init(i+1,      0,        cellSize, cellHeight, 2);
                 (new HoverWall(origin_->getContext()))->init(i+1,      numCells, cellSize, cellHeight, 2);
+            }
+
+
+            //Ground
+            for(int i = 0; i<numCells; i++){
+                for(int j = 0; j<numCells; j++){
+                    StaticEntity* groundCell = new StaticEntity(origin_->getContext());
+
+                    groundCell->addTemplate(origin_->getGroundTemplate());
+                    groundCell->setPosition(get3dCoordinates(i,j,-60));
+                }
+
             }
 
@@ -112,5 +139,106 @@
             }
 
-            //Generate 5 flags randomly (test only 1 flag)
+            createFlags();
+
+            //Generate 3 PickupSpawners randomly (destroy hover pickup)
+            for (int i = 0; i<3; i++)
+            {
+                PickupSpawner* pickupSpawner = new PickupSpawner(origin_->getContext());
+
+                pickupSpawner->setPosition(get3dCoordinates(rand()%numCells, rand()%numCells, 0.0f));
+                pickupSpawner->setPickupTemplateName(origin_->getPickupTemplate());
+                pickupSpawner->setMaxSpawnedItems(3);
+                pickupSpawner->setRespawnTime(30);
+                pickupSpawner->setTriggerDistance(40);
+                // Add pickup spawner to the pickup spawner list
+                pickupSpawners_.push_back(pickupSpawner);
+            }
+            
+            //Generate 3 PickupSpawners randomly (speed pickup)
+            for (int i = 0; i<3; i++)
+            {
+                PickupSpawner* pickupSpawner = new PickupSpawner(origin_->getContext());
+
+                pickupSpawner->setPosition(get3dCoordinates(rand()%numCells, rand()%numCells, 0.0f));
+                pickupSpawner->setPickupTemplateName(origin_->getPickupTemplateSpeed());
+                pickupSpawner->setMaxSpawnedItems(3);
+                pickupSpawner->setRespawnTime(30);
+                pickupSpawner->setTriggerDistance(40);
+                // Add pickup spawner to the pickup spawner list
+                pickupSpawners_.push_back(pickupSpawner);
+            }
+
+            //Generate 3 PickupSpawners randomly (shrink pickup)
+            for (int i = 0; i<3; i++)
+            {
+                PickupSpawner* pickupSpawner = new PickupSpawner(origin_->getContext());
+
+                pickupSpawner->setPosition(get3dCoordinates(rand()%numCells, rand()%numCells, 0.0f));
+                pickupSpawner->setPickupTemplateName(origin_->getPickupTemplateShrink());
+                pickupSpawner->setMaxSpawnedItems(3);
+                pickupSpawner->setRespawnTime(30);
+                pickupSpawner->setTriggerDistance(40);
+                // Add pickup spawner to the pickup spawner list
+                pickupSpawners_.push_back(pickupSpawner);
+            }
+
+            //*****************************************************************************
+
+            //Generate destroyable crates randomly on field
+
+            for (int i = 0; i<10; i++){
+
+                Pawn* crate = new Pawn(origin_->getContext());
+
+                crate->addTemplate(origin_->getObstacleTemplate());  
+                crate->setPosition(get3dCoordinates(rand()%numCells, rand()%numCells, 43.0f));
+
+
+            }    
+            
+
+
+
+             //If no lives are left, end game
+            if(lives <= 0)
+            {
+                GSLevel::startMainMenu();
+            }
+            // Debug
+            orxout() << this->origin_->getPickupTemplate() << endl;
+            orxout() << this->origin_->getPickupRepresentationTemplate() << endl;
+
+
+            orxout() << this->origin_->getPickupTemplateSpeed() << endl;
+            orxout() << this->origin_->getPickupRepresentationTemplateSpeed() << endl;
+
+            orxout() << this->origin_->getObstacleTemplate() << endl;
+            //orxout() << crate->getPosition() << endl;
+        }
+    }
+
+
+    // Start new level
+    void Hover::createFlags()
+    {
+        //Generate 5 flags randomly (test only 1 flag)
+
+          /*  do
+            {
+                int i = 0;
+
+                HoverFlag* flag = new HoverFlag(origin_->getContext());
+                int x = rand()%numCells;
+                int y = rand()%numCells;
+                flag->init(x, y, cellSize);
+                flags_.push_back(flag);
+
+                occupiedCells[x][y] = true;
+
+                i++;
+
+            }while( i<5 || occupiedCells[x][y] == true);
+            */
+
             for ( int i = 0; i < 5; i++ )
             {
@@ -118,90 +246,12 @@
                 flag->init(rand()%numCells, rand()%numCells, cellSize);
                 flags_.push_back(flag);
-            }
+
             
 
-            //Generate 3 PickupSpawners randomly (destroy hover pickup)
-            for (int i = 0; i<3; i++)
-            {
-                PickupSpawner* pickupSpawner = new PickupSpawner(origin_->getContext());
-
-                pickupSpawner->setPosition(get3dCoordinates(rand()%numCells, rand()%numCells, 10.0f));
-                pickupSpawner->setPickupTemplateName(origin_->getPickupTemplate());
-                pickupSpawner->setMaxSpawnedItems(3);
-                pickupSpawner->setRespawnTime(30);
-                pickupSpawner->setTriggerDistance(5);
-                // Add pickup spawner to the pickup spawner list
-                pickupSpawners_.push_back(pickupSpawner);
-            }
-            
-            //Generate 3 PickupSpawners randomly (speed pickup)
-            for (int i = 0; i<3; i++)
-            {
-                PickupSpawner* pickupSpawner = new PickupSpawner(origin_->getContext());
-
-                pickupSpawner->setPosition(get3dCoordinates(rand()%numCells, rand()%numCells, 10.0f));
-                pickupSpawner->setPickupTemplateName(origin_->getPickupTemplateSpeed());
-                pickupSpawner->setMaxSpawnedItems(3);
-                pickupSpawner->setRespawnTime(30);
-                pickupSpawner->setTriggerDistance(5);
-                // Add pickup spawner to the pickup spawner list
-                pickupSpawners_.push_back(pickupSpawner);
-            }
-
-            //Generate 3 PickupSpawners randomly (shrink pickup)
-            for (int i = 0; i<3; i++)
-            {
-                PickupSpawner* pickupSpawner = new PickupSpawner(origin_->getContext());
-
-                pickupSpawner->setPosition(get3dCoordinates(rand()%numCells, rand()%numCells, 10.0f));
-                pickupSpawner->setPickupTemplateName(origin_->getPickupTemplateShrink());
-                pickupSpawner->setMaxSpawnedItems(3);
-                pickupSpawner->setRespawnTime(30);
-                pickupSpawner->setTriggerDistance(5);
-                // Add pickup spawner to the pickup spawner list
-                pickupSpawners_.push_back(pickupSpawner);
-            }
-
-            //*****************************************************************************
-
-            //Generate a destroyable crate randomly on field
-
-            Pawn* crate = new Pawn(origin_->getContext());
-
-            
-            crate->addTemplate(origin_->getObstacleTemplate());  
-            crate->setPosition(get3dCoordinates(rand()%numCells, rand()%numCells, 10.0f));
-            //ate->setInitialHealth(100.0f);
-            
-
-
-
-             //If no lives are left, end game
-            if(lives <= 0)
-            {
-                GSLevel::startMainMenu();
-            }
-            // Debug
-            orxout() << this->origin_->getPickupTemplate() << endl;
-            orxout() << this->origin_->getPickupRepresentationTemplate() << endl;
-
-            orxout() << this->origin_->getPickupTemplateSpeed() << endl;
-            orxout() << this->origin_->getPickupRepresentationTemplateSpeed() << endl;
-
-            orxout() << this->origin_->getObstacleTemplate() << endl;
-            orxout() << crate->getPosition() << endl;
-        }
-    }
-
-
-    // Start new level
-    void Hover::newLevel()
-    {
-        //Generate 5 flags randomly (test only 1 flag)
-            for ( int i = 0; i < 5; i++ )
-            {
-                HoverFlag* flag = new HoverFlag(origin_->getContext());
-                flag->init(rand()%numCells, rand()%numCells, cellSize);
-                flags_.push_back(flag);
+                if(flags_[i]->getPosition() == get3dCoordinates(0,0,-60))
+                {
+                    flags_[i]->destroyLater();
+                    flags_.erase(flags_.begin()+i);
+                }
             }
             
@@ -245,5 +295,7 @@
             lives++;
         }
-        newLevel();
+        createFlags();
+        toggleShowLevel();
+        showLevelTimer.setTimer(1.0f, false, createExecutor(createFunctor(&Hover::toggleShowLevel, this)));
 
     }
