Changeset 12089 for code/branches/OrxoKart_HS18/src
- Timestamp:
- Nov 7, 2018, 11:42:26 AM (6 years ago)
- Location:
- code/branches/OrxoKart_HS18/src/modules/orxokart
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/OrxoKart_HS18/src/modules/orxokart/OrxoKart.cc
r12079 r12089 61 61 this->firstTick_ = false; 62 62 63 int n umCells= this->origin_->getNumCells();64 int cellSize= this->origin_->getCellSize();63 int n = this->origin_->getNumCells(); 64 int s = this->origin_->getCellSize(); 65 65 int cellHeight = this->origin_->getCellHeight(); 66 66 … … 75 75 ,1,1,1,1,1,0,0,0,1,1,1 76 76 ,0,0,0,0,1,0,0,0,0,0,1 77 ,0,0,0,0,1,1,1, 1,1,1,1};77 ,0,0,0,0,1,1,1,2,1,1,1}; 78 78 int* levelcode = levelcodeArray; 79 79 80 //Outer Walls81 for(int i = 0; i<numCells; i++){82 (new OrxoKartTile(origin_->getContext()))->init(0, i+1, cellSize, cellHeight, 1);83 (new OrxoKartTile(origin_->getContext()))->init(numCells, i+1, cellSize, cellHeight, 1);84 (new OrxoKartTile(origin_->getContext()))->init(i+1, 0, cellSize, cellHeight, 2);85 (new OrxoKartTile(origin_->getContext()))->init(i+1, numCells, cellSize, cellHeight, 2);86 }87 80 88 //Generate inner Walls according to levelcode 89 for(int y=0; y<numCells; y++){ 90 for(int x=0; x<numCells; x++){ 91 switch(levelcode[ y * numCells + x ]){ 92 case 1: (new OrxoKartTile(origin_->getContext()))->init(x+1, numCells-y, cellSize, cellHeight, 1); 93 break; 94 case 3: (new OrxoKartTile(origin_->getContext()))->init(x+1, numCells-y, cellSize, cellHeight, 1); 95 case 2: (new OrxoKartTile(origin_->getContext()))->init(x+1, numCells-y, cellSize, cellHeight, 0); 96 default: break; 97 } 81 //Generate floor according to levelcode 82 for(int i=0; i<n; i++){ 83 for(int j=0; j<n; j++){ 84 if (int type = levelcodeArray[i*n + j]) 85 (new OrxoKartTile(origin_->getContext()))->init((n-1-i)*s, j*s, s, type); 98 86 } 99 87 } -
code/branches/OrxoKart_HS18/src/modules/orxokart/OrxoKartTile.cc
r12062 r12089 83 83 Wall on the right side (1) or on top (2) of this square, 0-1 84 84 */ 85 void OrxoKartTile::init(int x, int y, int cellSize, int cellHeight, int orientation)85 void OrxoKartTile::init(int x, int z, int s, int type) 86 86 { 87 model_ = new Model(this->getContext()); 88 if (type == 1) { 89 model_->setMeshSource("OrxoKartStreckenabschnitt.mesh"); 90 } 91 else if (type == 2 ) { 92 model_->setMeshSource("OrxoKartStreckenabschnittZiel.mesh"); 93 } 94 model_->setScale3D(Vector3(s*1.0f, 8.0f, s*1.0f)); 95 model_->setPosition(Vector3(x*1.0f, 0.0f, z*1.0f)); 96 97 this->attach(model_); 98 99 cs_ = new BoxCollisionShape(this->getContext()); 100 cs_->setHalfExtents(Vector3(s/2.0f, 1.0f, s/2.0f)); 101 cs_->setPosition(Vector3(x*1.0f, -1.0f, z*1.0f)); 102 103 this->attachCollisionShape(cs_); 104 105 /* 106 87 107 int xSize_, zSize_, xPos_, zPos_; 88 108 … … 113 133 114 134 this->attachCollisionShape(cs_); 135 */ 115 136 } 116 137 } -
code/branches/OrxoKart_HS18/src/modules/orxokart/OrxoKartTile.h
r12062 r12089 49 49 virtual ~OrxoKartTile(); 50 50 51 void init(int x, int y, int cellSize, int cellHeight, int orientation);51 void init(int x, int z, int s, int type); 52 52 53 53 private:
Note: See TracChangeset
for help on using the changeset viewer.