Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11935


Ignore:
Timestamp:
May 3, 2018, 3:57:08 PM (6 years ago)
Author:
jacobsr
Message:

new functin for generating streets

Location:
code/branches/OrxyRoad_FS18/src/modules/orxyroad
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoad.cc

    r11934 r11935  
    5757        pattern = 3;
    5858        lastPosition = 0;
     59        roadWidth = 3000;
     60
     61       
     62
     63
     64
    5965        // spawn enemy every 3.5 seconds
    6066        //enemySpawnTimer.setTimer(3.5f, true, createExecutor(createFunctor(&OrxyRoad::spawnEnemy, this)));
     
    8894        showLevelTimer.setTimer(1.0f, false, createExecutor(createFunctor(&OrxyRoad::toggleShowLevel, this)));
    8995    }
     96    int OrxyRoad::generateStreet(int type, OrxyRoadShip* player){
     97        int trafficVelocities[]= {20,1000,500, 200};
     98        int numObjects[] = {60,10,40,60}; // default, spaceship, sattellite, asteroid
     99        int streetSize[] = {3 , 1, 2, 4};
     100        int trackWidth = 800;
     101     
     102        for(int j = 0; j < streetSize[type]; j++)//width of Street
     103            {
     104                for(int i = -numObjects[type]/2; i<numObjects[type]/2; i++)
     105                {
     106                        OrxyRoadCube* cube = new OrxyRoadCube(this->center_->getContext());
     107                        cubeList.push_back(cube);
     108                        switch(type)
     109                        {
     110                        case 0 : cube->addTemplate("SingleOrxyRoadCube");//default
     111                        break;
     112                        case 1:
     113                       
     114                        cube->addTemplate("SingleOrxyRoadCube");//spaceship
     115
     116                        break;
     117                        case 2: cube->addTemplate("SingleOrxyRoadCube");//satellite
     118                        break;
     119                        case 3: cube->addTemplate("SingleOrxyRoadCube");//asteroid
     120
     121                        }
     122
     123                        int distance = trafficVelocities[type]; //Todo better calculation of distance between objects
     124                       
     125                        cube->setPosition(player->getWorldPosition() + Vector3(1000.0f+j*trackWidth, 0.0f, i*600.0f+j*trackWidth));
     126                       
     127                        /* experimental */
     128
     129                        cube->setVelocity(0,0,trafficVelocities[type]);
     130
     131                        /* experimental */
     132
     133
     134                        //stEntity->setScale3D(50,50,50);                   
     135                }
     136            }
     137            return streetSize[type] * trackWidth;
     138    }
     139       
     140
     141
    90142
    91143    void OrxyRoad::tick(float dt)
     
    111163            }
    112164
     165           
     166
     167
    113168            if(counter >= 3000)
    114169            {
    115                 counter = 0;
    116                 for(int j = 0; j < 3; j++)//deepth cube
    117                 {
    118                     for(int i = -30; i<30; i++)
    119                     {
    120                         OrxyRoadCube* cube = new OrxyRoadCube(this->center_->getContext());
    121                         cubeList.push_back(cube);
    122                         switch(pattern)
    123                         {
    124                         case 1: cube->addTemplate("OrxyRoadCube01");
    125                         break;
    126                         case 2: cube->addTemplate("OrxyRoadCube01");
    127                         break;
    128                         case 3: cube->addTemplate("SingleOrxyRoadCube");
    129 
    130                         }
    131 
    132                         cube->setPosition(player->getWorldPosition() + Vector3(1000.0f+j*800.0f, 0.0f, i*600.0f+j*300));
    133                        
    134                         /* experimental */
    135 
    136                         cube->setVelocity(0,0,500);
    137 
    138                         /* experimental */
    139 
    140 
    141                         //stEntity->setScale3D(50,50,50);
    142                     }
    143                 }
    144 
     170                int type  = rand() % 4;
     171                orxout(user_info) << "Random : "<<type<< endl;
     172
     173                roadWidth = generateStreet(type,player);//Generate street to specific type type = 0 default, type = 1 space ship type  = 2 statellite/cubes, type = 3 asteroids
     174                counter = 0;               
    145175
    146176                //pattern %= 2;
  • code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoad.h

    r11899 r11935  
    118118
    119119
     120            int generateStreet(int type, OrxyRoadShip* player);
     121            int roadWidth;
     122            //int trafficVelocities[4];
     123            //int numObjects[4];
     124            //int streetSize[4];
     125
     126
    120127         /*
    121128
  • code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadShip.cc

    r11934 r11935  
    200200            steeredLeft = false;
    201201            steeredRight = true;       
    202             orxout(user_info) << "Steering RIGHT "<<steering_.x << endl;
     202            //orxout(user_info) << "Steering RIGHT "<<steering_.x << endl;
    203203        }else {
    204204            steeredRight = false;
    205205            steeredLeft = true;
    206              orxout(user_info) << "Steering LEFT "<<steering_.x << endl;
     206             //orxout(user_info) << "Steering LEFT "<<steering_.x << endl;
    207207
    208208        }
  • code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadShip.h

    r11908 r11935  
    9090                float y;
    9191            } velocity, desiredVelocity;
     92           
    9293
    9394    };
Note: See TracChangeset for help on using the changeset viewer.