Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 21, 2018, 11:49:03 AM (5 years ago)
Author:
ottka
Message:

stop timer after round

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/OrxoKart_HS18/src/modules/orxokart/OrxoKart.cc

    r12108 r12111  
    5858        SUPER(OrxoKart, tick, dt);
    5959
    60 
    6160        if(this->firstTick_ && this->origin_)
    6261        {
    6362            this->firstTick_ = false;
     63            this->wayPoints = std::vector<OrxoKartTile*>(3, nullptr);
    6464
    6565            int n = this->origin_->getNumCells();
    6666            int s = this->origin_->getCellSize();
    67 
    6867            int map_1[] =   {1,1,1,1,1,1,1,1,0,0,0
    6968                            ,1,0,0,0,0,0,0,1,1,1,0
     
    106105
    107106
    108             int *levelcodeArray =  map_2;
     107            int *levelcodeArray =  map_1;
    109108
    110 
     109            // int z = 0;
    111110            //Generate floor according to levelcode
    112111            for(int i=0; i<n; i++){
    113112                for(int j=0; j<n; j++){
    114                     if (int type = levelcodeArray[i*n + j])
    115                     (new OrxoKartTile(origin_->getContext()))->init((n-1-i)*s, j*s, s, type);
     113                    if (int type = levelcodeArray[i*n + j]) {
     114                        OrxoKartTile* tile = new OrxoKartTile(origin_->getContext());
     115                        tile->init((n-1-i)*s, j*s, s, type);
     116                        // tiles.push_back(tile);
     117                        //++z;
     118                        if ( i == 10 && j == 4 )
     119                            wayPoints.at(0) = tile;
     120
     121                        if ( i == 0 && j == 0)
     122                            wayPoints.at(1) = tile;
     123                        if ( i == 10 && j == 7)
     124                            wayPoints.at(2) = tile;
     125                    }
    116126                }   
    117127            }
    118 
    119128            //bottom flag
    120129           
    121                 OrxoKartFlag* flag = new OrxoKartFlag(origin_->getContext());
    122                 flag->init(n, s);
    123                 flag_ = flag;
     130            OrxoKartFlag* flag = new OrxoKartFlag(origin_->getContext());
     131            flag->init(n, s);
     132            flag_ = flag;
    124133           
    125134
     
    127136           
    128137
    129         }//firsttick end
     138        } //firsttick end
     139        /*
     140        for (std::vector<OrxoKartTile*>::iterator it = tiles.begin(); it != tiles.end(); ++it ) {
     141            if ((*it)->getCollided())
     142                tiles.erase(it);
     143        }
     144        if (tiles.empty())
     145            numberOfFlags_ = 0;
     146        */
     147        if (wayPointCounter >= 3)
     148            numberOfFlags_ = 0;
     149        else if (wayPointCounter < 3 && wayPointCounter >= 0 && wayPoints.at(wayPointCounter) != nullptr) {
     150            if (wayPoints.at(wayPointCounter)->getCollided()) {
     151                for (int i = 0; i < 3; ++i) {
     152                    wayPoints.at(i)->setCollided(false);
     153                }
     154                ++wayPointCounter;
     155            }
     156        }
     157        else {
     158            orxout() << " Should not happen, look in OrxoKart.cc";
     159        }
    130160
    131        
    132            
     161
     162
     163
     164
    133165        // Check if ship collided with the flag
    134166        if(flag_->getCollided()){
    135167            OrxoKartKart* player = flag_->getObjectofCollision();
    136             orxout() << "Orientation= " << player->getOrientation() << endl;
    137             player->setPosition(Vector3(80*0, 40, 80*18));
     168            player->setPosition(Vector3(80*0, 20, 80*8));
    138169            player->setOrientation(Quaternion(1, 0, 0, 0));   // 0, 0, 0
    139170            player->setVelocity(Vector3(0,0,0));
    140171            player->setAcceleration(Vector3(0,0,0));
    141172            flag_->setCollided(false);
     173            wayPointCounter = 0;
    142174
    143175
    144176            // flag_->destroyLater();
    145177           // flags_.erase (flags_.begin()+i);
    146             numberOfFlags_ = 0;
     178            //numberOfFlags_ = 0;
    147179        }
    148180       
Note: See TracChangeset for help on using the changeset viewer.