Changeset 12111 for code/branches
- Timestamp:
- Nov 21, 2018, 11:49:03 AM (6 years ago)
- Location:
- code/branches/OrxoKart_HS18
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/OrxoKart_HS18/data/levels/OrxoKart1.oxw
r12108 r12111 19 19 <?lua 20 20 --number of tiles 21 N = 25 21 N = 11 22 -- or 25 22 23 --scaling factor 23 24 S = 80 … … 62 63 specular="1.0, 0.9, 0.9, 1.0" 63 64 /> 64 65 <!-- 19 --> 65 66 <SpawnPoint 66 67 team=0 67 position="<?lua print(S*0)?>,40,<?lua print(19*S)?>" 68 69 position="<?lua print(S*0)?>,40,<?lua print(8*S)?>" 68 70 lookat="0,40,0" 69 71 spawnclass=OrxoKartKart -
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 -
code/branches/OrxoKart_HS18/src/modules/orxokart/OrxoKart.h
r12108 r12111 61 61 WeakPtr<OrxoKartOrigin> origin_; 62 62 OrxoKartFlag* flag_; 63 //std::vector<OrxoKartFlag*> flags_; 63 std::vector<OrxoKartTile*> tiles; 64 int numberOfWP; 65 std::vector<OrxoKartTile*> wayPoints; 66 int wayPointCounter = 0; 64 67 int numberOfFlags_; 65 68 bool firstTick_; -
code/branches/OrxoKart_HS18/src/modules/orxokart/OrxoKartTile.cc
r12090 r12111 104 104 this->attachCollisionShape(cs_); 105 105 } 106 107 /** 108 @brief 109 Checks if the OrxoKartship collided with the flag 110 */ 111 bool OrxoKartTile::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) 112 { 113 if(otherObject->isA(Class(OrxoKartKart))) { 114 collided_ = true; 115 kartCollider = (OrxoKartKart*) otherObject; 116 } 117 118 return false; 119 } 120 121 106 122 } -
code/branches/OrxoKart_HS18/src/modules/orxokart/OrxoKartTile.h
r12089 r12111 39 39 #include "objects/ObjectsPrereqs.h" 40 40 41 #include "OrxoKartKart.h" 41 42 #include "worldentities/StaticEntity.h" 42 43 … … 51 52 void init(int x, int z, int s, int type); 52 53 54 virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override; 55 56 inline bool getCollided() const 57 { return this->collided_; } 58 59 inline OrxoKartKart* getObjectofCollision() const 60 { return this->kartCollider; } 61 62 inline void setCollided(bool setValue) 63 { this->collided_ = setValue; } 64 53 65 private: 54 66 Model* model_; 55 67 BoxCollisionShape* cs_; 68 bool collided_; 69 OrxoKartKart* kartCollider; 56 70 }; 57 71 }
Note: See TracChangeset
for help on using the changeset viewer.