[Orxonox-commit 7355] r11972 - code/branches/OrxyRoad_FS18/src/modules/orxyroad

jacobsr at orxonox.net jacobsr at orxonox.net
Thu May 17 15:58:17 CEST 2018


Author: jacobsr
Date: 2018-05-17 15:58:17 +0200 (Thu, 17 May 2018)
New Revision: 11972

Modified:
   code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoad.cc
   code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadShip.cc
Log:
changed control, traffic distance, randomly choose type and template

Modified: code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoad.cc
===================================================================
--- code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoad.cc	2018-05-17 13:55:27 UTC (rev 11971)
+++ code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoad.cc	2018-05-17 13:58:17 UTC (rev 11972)
@@ -94,40 +94,77 @@
         showLevelTimer.setTimer(1.0f, false, createExecutor(createFunctor(&OrxyRoad::toggleShowLevel, this)));
     }
     int OrxyRoad::generateStreet(int type, OrxyRoadShip* player){
-        int trafficVelocities[]= {20,1000,500, 200};
-        int numObjects[] = {60,10,40,60}; // default, spaceship, sattellite, asteroid
+        int trafficVelocities[]= {200,1400,500, 300};
+        int numObjects[] = {60,100,40,60}; // default, spaceship, sattellite, asteroid per track
         int streetSize[] = {3 , 1, 2, 4};
-        int trackWidth = 800;
+        int trackWidth = 700;
       
         for(int j = 0; j < streetSize[type]; j++)//width of Street
             {
+                int sign = rand()%2;
+
+                orxout(internal_error) << sign<< endl;
+                
+                
+
                 for(int i = -numObjects[type]/2; i<numObjects[type]/2; i++)
                 {
                         OrxyRoadCube* cube = new OrxyRoadCube(this->center_->getContext());
                         cubeList.push_back(cube);
+                        int templateType = rand()%2;
                         switch(type)
                         {
-                        case 0 : cube->addTemplate("asteroid");//default
+                        case 0 :
+                            if(templateType >=1){
+                                cube->addTemplate("asteroid");//default
+                            }else {
+                                cube->addTemplate("asteroid");//default
+                            }
                         break;
                         case 1:
-                        
-                        cube->addTemplate("spacecruiser");//spaceship
+                         if(templateType >=1){
+                                cube->addTemplate("asteroid");//spaceship1
+                            }else {
+                                cube->addTemplate("spacecruiser");//spaceship2
+                            }                        
+                            
 
                         break;
-                        case 2: cube->addTemplate("spacecruiser");//satellite
+                        case 2: 
+                            if(templateType >=1){
+                                cube->addTemplate("asteroid");//satellite
+                            }else {
+                                cube->addTemplate("spacecruiser");//satellite
+                            }                      
+
+                            
                         break;
-                        case 3: cube->addTemplate("asteroid");//asteroid
+                        case 3: 
+                            if(templateType >=1){
+                                cube->addTemplate("asteroid");//asteroid
+                            }else {
+                                cube->addTemplate("spacecruiser");//asteroid
+                            }                      
 
+
                         }
 
-                        int distance = trafficVelocities[type]; //Todo better calculation of distance between objects
+                        int distance = trafficVelocities[type]*3; //Todo better calculation of distance between objects
                        
-                        cube->setPosition(player->getWorldPosition() + Vector3(1000.0f+j*trackWidth, 0.0f, i*600.0f+j*trackWidth));
+                        cube->setPosition(player->getWorldPosition() + Vector3(1000.0f+j*trackWidth, 0.0f, i*distance+j*trackWidth));
                         
                         /* experimental */
+                        
 
-                        cube->setVelocity(0,0,trafficVelocities[type]);
+                        if(sign>=1){
+                            cube->setVelocity(0,0,trafficVelocities[type]);
+                        } else{
+                             cube->setVelocity(0,0,-trafficVelocities[type]);
+                        }
+                        
 
+                        
+
                         /* experimental */
 
 
@@ -165,7 +202,7 @@
             
 
 
-            if(counter >= 3000)
+            if(counter >= roadWidth)
             {
                 int type  = rand() % 4;
                 orxout(user_info) << "Random : "<<type<< endl;

Modified: code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadShip.cc
===================================================================
--- code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadShip.cc	2018-05-17 13:55:27 UTC (rev 11971)
+++ code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadShip.cc	2018-05-17 13:58:17 UTC (rev 11972)
@@ -81,6 +81,7 @@
             if(forward){
                 if(velocity.y < 200){// Limit for max velocity
                     velocity.y += 10;
+                    forward = false;
                 }
                 
 
@@ -90,6 +91,7 @@
                 }else {
                     velocity.y = 0; // Prevent players from going backwards
                 }
+                backward = false;
                           
             }else {
                 velocity.y = 0.9 * velocity.y;//reduce speed
@@ -118,12 +120,17 @@
 
 
             if(steeredLeft){
-                velocity.x += 100;
-                steeredLeft = false;
+                if(!forward){
+                    velocity.x += 5;
+                    steeredLeft = false;
+                }
+                
 
             }else if(steeredRight) {
-                velocity.x += -100;
-                steeredRight = false;
+                if(!forward){
+                    velocity.x += -5;
+                    steeredRight = false;
+                }
             }else {
                 if(velocity.x < -2 || velocity.x > 2 ){
                     velocity.x  = velocity.x *0.9;
@@ -205,8 +212,7 @@
             steeredLeft = true;
              //orxout(user_info) << "Steering LEFT "<<steering_.x << endl;
 
-        }
-        
+        }        
 
         //lastTimeLeft = 0;
         //desiredVelocity.x = value.x * speed;



More information about the Orxonox-commit mailing list