- Timestamp:
- Nov 21, 2018, 11:49:03 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/OrxoKart_HS18/src/modules/orxokart/OrxoKart.cc
r12108 r12111 58 58 SUPER(OrxoKart, tick, dt); 59 59 60 61 60 if(this->firstTick_ && this->origin_) 62 61 { 63 62 this->firstTick_ = false; 63 this->wayPoints = std::vector<OrxoKartTile*>(3, nullptr); 64 64 65 65 int n = this->origin_->getNumCells(); 66 66 int s = this->origin_->getCellSize(); 67 68 67 int map_1[] = {1,1,1,1,1,1,1,1,0,0,0 69 68 ,1,0,0,0,0,0,0,1,1,1,0 … … 106 105 107 106 108 int *levelcodeArray = map_ 2;107 int *levelcodeArray = map_1; 109 108 110 109 // int z = 0; 111 110 //Generate floor according to levelcode 112 111 for(int i=0; i<n; i++){ 113 112 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 } 116 126 } 117 127 } 118 119 128 //bottom flag 120 129 121 122 123 130 OrxoKartFlag* flag = new OrxoKartFlag(origin_->getContext()); 131 flag->init(n, s); 132 flag_ = flag; 124 133 125 134 … … 127 136 128 137 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 } 130 160 131 132 161 162 163 164 133 165 // Check if ship collided with the flag 134 166 if(flag_->getCollided()){ 135 167 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)); 138 169 player->setOrientation(Quaternion(1, 0, 0, 0)); // 0, 0, 0 139 170 player->setVelocity(Vector3(0,0,0)); 140 171 player->setAcceleration(Vector3(0,0,0)); 141 172 flag_->setCollided(false); 173 wayPointCounter = 0; 142 174 143 175 144 176 // flag_->destroyLater(); 145 177 // flags_.erase (flags_.begin()+i); 146 numberOfFlags_ = 0;178 //numberOfFlags_ = 0; 147 179 } 148 180
Note: See TracChangeset
for help on using the changeset viewer.