Index: code/branches/towerdefenseFS15/src/modules/towerdefense/TowerDefense.cc
===================================================================
--- code/branches/towerdefenseFS15/src/modules/towerdefense/TowerDefense.cc	(revision 10430)
+++ code/branches/towerdefenseFS15/src/modules/towerdefense/TowerDefense.cc	(revision 10451)
@@ -95,4 +95,7 @@
     static const int upgradeCost = 20;
     static const int towerCost = 20;
+    unsigned int maxspaceships = 30;
+    int maxspaceshipsstandard = 30;
+
 
 
@@ -419,21 +422,36 @@
     void TowerDefense::nextwave()
     {
+
+    	orxout() << "newwave" << endl;
     	TowerDefenseEnemyvector.clear();
     	waves_++;
+        //maxspaceships = round(maxspaceshipsstandard + 0.25*(waves_));
     	time=0;
-        float randomnumber1 = rand()*100*5;
-        float randomnumber2 = rand()*100*1;
-        float randomnumber3 = rand()*100*1.5;
-
-        float totalnumber = (randomnumber1 + randomnumber2 + randomnumber3)*1.3;
-
-        int newspaceships = (int)(maxspaceships* randomnumber1 / totalnumber);
-        int neweggs = (int)(maxspaceships*randomnumber2 / totalnumber);
-        int newufos = (int)(maxspaceships*randomnumber3 / totalnumber);
-        int newrandomships = maxspaceships -spaceships - eggs - ufos;
-        int spaceships =newspaceships;
-        int eggs=neweggs;
-        int ufos=newufos;
-        int randomships=newrandomships;
+
+    	int helpnumber = 40 -(waves_);
+    	if(helpnumber <= 0) {helpnumber =1;}
+        float numSpaceships = std::abs((rand() % 100)*5*(helpnumber));
+        float numEggs = std::abs((rand() % 100)*1*(waves_));
+        float numUfos = std::abs((rand() % 100)*1.5*(0.5*(waves_))) ;
+
+        float totalnumber = (numSpaceships + numEggs + numUfos)*1.3;
+
+        int newspaceships = (int)(maxspaceships* numSpaceships / totalnumber);
+        int neweggs = (int)(maxspaceships*numEggs / totalnumber);
+        int newufos = (int)(maxspaceships*numUfos / totalnumber);
+        int newrandomships = maxspaceships -newspaceships - neweggs - newufos;
+        spaceships =newspaceships;
+        eggs=neweggs;
+        ufos=newufos;
+        randomships=newrandomships;
+
+        orxout() << spaceships << endl;
+        orxout() << eggs << endl;
+        orxout() << ufos << endl;
+        orxout() << randomships << endl;
+
+
+
+
 
     }
@@ -469,22 +487,26 @@
 				        if(towerTurretMatrix[x][y]->upgrade < towerTurretMatrix[x][y]->upgradeMax)
 				        {
-				        	this->buyTower((int)(upgradeCost*(std::pow(1.5,towerTurretMatrix[x][y]->upgrade))));
-							switch(towerTurretMatrix[x][y]->upgrade)
-						   {
-							   case 1 :
-								   towerModelMatrix[x][y]->setMeshSource("TD_T2.mesh");
-								   break;
-
-							   case 2 :
-								   towerModelMatrix[x][y]->setMeshSource("TD_T3.mesh");
-								   break;
-			                   case 3 :
-			                	   towerModelMatrix[x][y]->setMeshSource("TD_T4.mesh");
-			                	   break;
-			                   case 4 :
-			                	   towerModelMatrix[x][y]->setMeshSource("TD_T5.mesh");
-			                	   break;
-
-						   }
+				        	int specificupgradecost = (int)(upgradeCost*(std::pow(1.5,towerTurretMatrix[x][y]->upgrade)));
+				        	if(this->credit_ >= specificupgradecost)
+				        	{
+					        	this->buyTower(specificupgradecost);
+								switch(towerTurretMatrix[x][y]->upgrade)
+							   {
+								   case 1 :
+									   towerModelMatrix[x][y]->setMeshSource("TD_T2.mesh");
+									   break;
+
+								   case 2 :
+									   towerModelMatrix[x][y]->setMeshSource("TD_T3.mesh");
+									   break;
+				                   case 3 :
+				                	   towerModelMatrix[x][y]->setMeshSource("TD_T4.mesh");
+				                	   break;
+				                   case 4 :
+				                	   towerModelMatrix[x][y]->setMeshSource("TD_T5.mesh");
+				                	   break;
+
+							   }
+				        	}
 
 
@@ -501,10 +523,10 @@
 
 
-        int enemytype = this->getWaveNumber() % 3 +1;
+
 
 
         if(time>=TowerDefenseEnemyvector.size() && TowerDefenseEnemyvector.size() < maxspaceships)
 		{
-			orxout() << "enemyerstellen" << endl;
+
         	//adds different types of enemys depending on the WaveNumber progressively making the combination of enemys more difficult
         	if(spaceships>0)
Index: code/branches/towerdefenseFS15/src/modules/towerdefense/TowerDefense.h
===================================================================
--- code/branches/towerdefenseFS15/src/modules/towerdefense/TowerDefense.h	(revision 10430)
+++ code/branches/towerdefenseFS15/src/modules/towerdefense/TowerDefense.h	(revision 10451)
@@ -80,5 +80,4 @@
         int ufos;
         int randomships;
-        int maxspaceships = 30;
 
 
Index: code/branches/towerdefenseFS15/src/modules/towerdefense/TowerDefenseSelecter.cc
===================================================================
--- code/branches/towerdefenseFS15/src/modules/towerdefense/TowerDefenseSelecter.cc	(revision 10430)
+++ code/branches/towerdefenseFS15/src/modules/towerdefense/TowerDefenseSelecter.cc	(revision 10451)
@@ -52,5 +52,5 @@
         moveRightPressed_ = false;
         firePressed_ = false;
-        setSelectedPosition(0,0);
+        setSelectedPosition(6,6);
         timerSetFire_=0;
     }
