Changeset 11040 for code/branches/presentationHS15
- Timestamp:
- Jan 4, 2016, 5:22:59 PM (9 years ago)
- Location:
- code/branches/presentationHS15
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentationHS15/data/levels/Hover.oxw
r11026 r11040 18 18 ?> 19 19 20 <?lua 21 MAZE_NUM_CELLS = 10 22 MAZE_CELL_SIZE = 100 23 MAZE_CELL_HEIGHT = 30 24 MAZE_SIZE = MAZE_NUM_CELLS*MAZE_CELL_SIZE 25 ?> 26 20 27 <Level 21 28 plugins = hover … … 32 39 gravity = "0, -200, 0" 33 40 > 34 35 41 42 <StaticEntity position="0,0,0" collisionType="static"> 43 <attached> 44 <HoverOrigin 45 numCells="<?lua print(MAZE_NUM_CELLS)?>" 46 cellSize="<?lua print(MAZE_CELL_SIZE)?>" 47 cellHeight="<?lua print(MAZE_CELL_HEIGHT)?>" 48 /> 49 <Model 50 position="<?lua print(MAZE_SIZE/2)?>,-16,<?lua print(MAZE_SIZE/2)?>" 51 scale3D="<?lua print(MAZE_SIZE/2)?>,16,<?lua print(MAZE_SIZE/2)?>" 52 mesh="CubeGround.mesh" 53 /> 54 </attached> 55 <collisionShapes> 56 <BoxCollisionShape 57 position="<?lua print(MAZE_SIZE/2)?>,<?lua print(MAZE_CELL_HEIGHT+1)?>,<?lua print(MAZE_SIZE/2)?>" 58 halfExtents="<?lua print(MAZE_SIZE/2)?>,1,<?lua print(MAZE_SIZE/2)?>" 59 /> 60 <BoxCollisionShape 61 position="<?lua print(MAZE_SIZE/2)?>,-1,<?lua print(MAZE_SIZE/2)?>" 62 halfExtents="<?lua print(MAZE_SIZE/2)?>,1,<?lua print(MAZE_SIZE/2)?>" 63 /> 64 </collisionShapes> 65 </StaticEntity> 36 66 37 38 39 <StaticEntity position="0,0,0" collisionType="static"> 40 <attached> 41 </attached> 42 <collisionShapes> 43 <BoxCollisionShape yaw="0" pitch="0" roll="0" position="500,0,0" halfExtents="500, 30, 2" /> 44 <BoxCollisionShape yaw="0" pitch="0" roll="0" position="500,0,1000" halfExtents="500, 30, 2" /> 45 <BoxCollisionShape yaw="0" pitch="0" roll="0" position="0,0,500" halfExtents="2, 30, 500" /> 46 <BoxCollisionShape yaw="0" pitch="0" roll="0" position="1000,0,500" halfExtents="2, 30, 500" /> 47 48 </collisionShapes> 49 </StaticEntity> 50 51 <StaticEntity position="0,0,0" collisionType="static"> 52 <attached> 53 <Model position="500, -16,500" yaw="0" pitch="0" roll="0" scale3D="500, 16, 500" mesh="CubeGround.mesh" /> 54 </attached> 55 <collisionShapes> 56 <BoxCollisionShape yaw="0" pitch="0" roll="0" position="0,50,0" halfExtents="10000, 1, 10000" /> 57 <BoxCollisionShape yaw="0" pitch="0" roll="0" position="0,-10,0" halfExtents="10000, 10, 10000" /> 58 <BoxCollisionShape yaw="0" pitch="0" roll="0" position="500, 0,0" halfExtents="1000, 1000, 1" /> 59 <BoxCollisionShape yaw="0" pitch="0" roll="0" position="500, 0, 1000" halfExtents="1000, 1000, 1" /> 60 <BoxCollisionShape yaw="0" pitch="0" roll="0" position="0, 0, 500" halfExtents="1, 1000, 1000" /> 61 <BoxCollisionShape yaw="0" pitch="0" roll="0" position="1000, 0, 500" halfExtents="1, 1000, 1000" /> 62 63 64 </collisionShapes> 65 </StaticEntity> 66 67 68 <MovableEntity position="0,0,0"> 69 <attached> 70 <HoverOrigin> 71 72 <attached> 73 74 </attached> 75 </HoverOrigin> 76 </attached> 77 </MovableEntity> 78 79 80 67 <Light 68 type=directional 69 position="-50,500,-50" 70 direction="0.577, -0.577, 0.577" 71 diffuse="1.0, 0.9, 0.9, 1.0" 72 specular="1.0, 0.9, 0.9, 1.0" 73 /> 81 74 82 <Light type=directional position="-50,500,-50" direction="0.577, -0.577, 0.577" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/> 83 <SpawnPoint team=0 position="50,20,50" lookat="100,20,100" spawnclass=HoverShip pawndesign=spaceshiphover /> 75 <SpawnPoint 76 team=0 77 position="50,20,50" 78 lookat="100,20,100" 79 spawnclass=HoverShip 80 pawndesign=spaceshiphover 81 /> 84 82 85 83 </Scene> -
code/branches/presentationHS15/src/modules/hover/Hover.cc
r11036 r11040 59 59 SUPER(Hover, tick, dt); 60 60 61 if(this->firstTick_ )61 if(this->firstTick_ && this->origin_) 62 62 { 63 63 this->firstTick_ = false; 64 64 65 MazeGenerator generator; 65 int numCells = this->origin_->getNumCells(); 66 int cellSize = this->origin_->getCellSize(); 67 int cellHeight = this->origin_->getCellHeight(); 68 69 MazeGenerator generator(numCells); 66 70 generator.generateMaze(); 67 71 generator.renderMaze(); 68 72 69 const int NUM_CELLS = generator.getNumCells();70 73 int* levelcode = generator.getLevelcode(); 71 74 72 75 //Outer Walls 73 for(int i = 0; i< NUM_CELLS; i++){74 new HoverWall(origin_->getContext(), 0, i+1, 1);75 new HoverWall(origin_->getContext(), NUM_CELLS, i+1, 1);76 new HoverWall(origin_->getContext(), i+1, 0, 2);77 new HoverWall(origin_->getContext(), i+1, NUM_CELLS, 2);76 for(int i = 0; i<numCells; i++){ 77 new HoverWall(origin_->getContext(), 0, i+1, cellSize, cellHeight, 1); 78 new HoverWall(origin_->getContext(), numCells, i+1, cellSize, cellHeight, 1); 79 new HoverWall(origin_->getContext(), i+1, 0, cellSize, cellHeight, 2); 80 new HoverWall(origin_->getContext(), i+1, numCells, cellSize, cellHeight, 2); 78 81 } 79 82 80 83 //Generate inner Walls according to levelcode 81 for(int y=0; y< NUM_CELLS; y++){82 for(int x=0; x< NUM_CELLS; x++){83 switch(levelcode[ y * NUM_CELLS+ x ]){84 case 1: new HoverWall(origin_->getContext(), x+1, NUM_CELLS-y, 1);84 for(int y=0; y<numCells; y++){ 85 for(int x=0; x<numCells; x++){ 86 switch(levelcode[ y * numCells + x ]){ 87 case 1: new HoverWall(origin_->getContext(), x+1, numCells-y, cellSize, cellHeight, 1); 85 88 break; 86 case 3: new HoverWall(origin_->getContext(), x+1, NUM_CELLS-y, 1);87 case 2: new HoverWall(origin_->getContext(), x+1, NUM_CELLS-y, 0);89 case 3: new HoverWall(origin_->getContext(), x+1, numCells-y, cellSize, cellHeight, 1); 90 case 2: new HoverWall(origin_->getContext(), x+1, numCells-y, cellSize, cellHeight, 0); 88 91 default: break; 89 92 } … … 93 96 //Generate 5 flags randomly 94 97 for ( int i = 0; i < 5; i++ ) 95 flagVector_.push_back(new HoverFlag(origin_->getContext(), rand()% NUM_CELLS, rand()%NUM_CELLS));98 flagVector_.push_back(new HoverFlag(origin_->getContext(), rand()%numCells, rand()%numCells, cellSize)); 96 99 97 100 flags_ = flagVector_.size(); -
code/branches/presentationHS15/src/modules/hover/HoverFlag.cc
r11030 r11040 64 64 Y-Coordinate of the flage, 0-9, origin is bottom left 65 65 */ 66 HoverFlag::HoverFlag(Context* context, int xCoordinate, int yCoordinate ) : StaticEntity(context)66 HoverFlag::HoverFlag(Context* context, int xCoordinate, int yCoordinate, int cellSize) : StaticEntity(context) 67 67 { 68 68 RegisterObject(HoverFlag); … … 74 74 model_->setMeshSource("ss_flag_eu.mesh"); 75 75 model_->setScale3D(Vector3(5, 5, 5)); 76 model_->setPosition(Vector3(xCoordinate* 100.0f + 50.0f,10.0f,yCoordinate*100.0f + 50.0f));76 model_->setPosition(Vector3(xCoordinate*cellSize*1.0f + cellSize/2,10.0f,yCoordinate*cellSize*1.0f + cellSize/2)); 77 77 78 78 this->attach(model_); … … 84 84 cs_ = new BoxCollisionShape(context); 85 85 cs_->setHalfExtents(Vector3(5, 5, 5)); 86 cs_->setPosition(Vector3(xCoordinate* 100.0f + 50.0f,0.0f,yCoordinate*100.0f + 50.0f));86 cs_->setPosition(Vector3(xCoordinate*cellSize*1.0f + cellSize/2,0.0f,yCoordinate*cellSize*1.0f + cellSize/2)); 87 87 88 88 this->attachCollisionShape(cs_); -
code/branches/presentationHS15/src/modules/hover/HoverFlag.h
r11029 r11040 49 49 public: 50 50 HoverFlag(Context* context); 51 HoverFlag(Context* context, int xCoordinate, int yCoordinate );51 HoverFlag(Context* context, int xCoordinate, int yCoordinate, int cellSize); 52 52 virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint); 53 53 virtual ~HoverFlag(); -
code/branches/presentationHS15/src/modules/hover/HoverOrigin.cc
r11026 r11040 50 50 { 51 51 SUPER(HoverOrigin, XMLPort, xmlelement, mode); 52 53 XMLPortParam(HoverOrigin, "numCells", setNumCells, getNumCells, xmlelement, mode); 54 XMLPortParam(HoverOrigin, "cellSize", setCellSize, getCellSize, xmlelement, mode); 55 XMLPortParam(HoverOrigin, "cellHeight", setCellHeight, getCellHeight, xmlelement, mode); 52 56 } 53 57 -
code/branches/presentationHS15/src/modules/hover/HoverOrigin.h
r11026 r11040 115 115 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method to create a HoverOrigin through XML. 116 116 117 inline void setNumCells(int numCells) 118 { this->numCells_ = numCells; } 119 inline int getNumCells() const 120 { return this->numCells_; } 121 122 inline void setCellSize(int cellSize) 123 { this->cellSize_ = cellSize; } 124 inline int getCellSize() const 125 { return this->cellSize_; } 126 127 inline void setCellHeight(int cellHeight) 128 { this->cellHeight_ = cellHeight; } 129 inline int getCellHeight() const 130 { return this->cellHeight_; } 131 117 132 private: 118 133 void checkGametype(); 119 134 135 int numCells_; 136 int cellSize_; 137 int cellHeight_; 120 138 }; 121 139 } -
code/branches/presentationHS15/src/modules/hover/HoverWall.cc
r11030 r11040 65 65 Wall on the right side (1) or on top (2) of this square, 0-1 66 66 */ 67 HoverWall::HoverWall(Context* context, int x, int y, int orientation) : StaticEntity(context)67 HoverWall::HoverWall(Context* context, int x, int y, int cellSize, int cellHeight, int orientation) : StaticEntity(context) 68 68 { 69 69 RegisterObject(HoverWall); … … 72 72 73 73 if(orientation == 1){ 74 xSize_ = 50;74 xSize_ = cellSize/2; 75 75 zSize_ = 2; 76 zPos_ = x* 100;77 xPos_ = y* 100 -50;76 zPos_ = x*cellSize; 77 xPos_ = y*cellSize-cellSize/2; 78 78 } 79 79 else{ 80 80 xSize_ = 2; 81 zSize_ = 50;82 zPos_ = x* 100-50;83 xPos_ = y* 100;81 zSize_ = cellSize/2; 82 zPos_ = x*cellSize-cellSize/2; 83 xPos_ = y*cellSize; 84 84 } 85 85 … … 87 87 model_ = new Model(context); 88 88 model_->setMeshSource("CuboidBody.mesh"); 89 model_->setScale3D(Vector3(xSize_*1.0f, 30.0f, zSize_*1.0f));89 model_->setScale3D(Vector3(xSize_*1.0f, cellHeight*1.0f, zSize_*1.0f)); 90 90 model_->setPosition(Vector3(xPos_*1.0f, 0.0f, zPos_*1.0f)); 91 91 … … 97 97 98 98 cs_ = new BoxCollisionShape(context); 99 cs_->setHalfExtents(Vector3(xSize_*1.0f, 30.0f, zSize_*1.0f));99 cs_->setHalfExtents(Vector3(xSize_*1.0f, cellHeight*1.0f, zSize_*1.0f)); 100 100 cs_->setPosition(Vector3(xPos_*1.0f, 0.0f, zPos_*1.0f)); 101 101 -
code/branches/presentationHS15/src/modules/hover/HoverWall.h
r11029 r11040 49 49 public: 50 50 HoverWall(Context* context); 51 HoverWall(Context* context, int x, int y, int orientation);51 HoverWall(Context* context, int x, int y, int cellSize, int cellHeight, int orientation); 52 52 virtual ~HoverWall(); 53 53 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); -
code/branches/presentationHS15/src/modules/hover/MazeGenerator.cc
r11036 r11040 44 44 namespace orxonox 45 45 { 46 MazeGenerator::MazeGenerator() 47 { 46 MazeGenerator::MazeGenerator(int numCells) 47 { 48 this->numCells_ = numCells; 49 48 50 //levelcode_ represents the pitch: It's a 10x10 field. 49 51 // 1 represents a Wall on the right side of this square … … 51 53 // 3 represents 2 and 1 at the same time 52 54 // Note: the levelcode_ is generated from the Maze-Generator functions at the beginning of the game 53 this->levelcode_ = new int[ NUM_CELLS*NUM_CELLS];;54 std::fill( levelcode_, levelcode_ + NUM_CELLS*NUM_CELLS, 0 );55 56 this->maze_ = new unsigned char[ NUM_CELLS*NUM_CELLS];57 std::fill( maze_, maze_ + NUM_CELLS*NUM_CELLS, 0 );55 this->levelcode_ = new int[ numCells_*numCells_ ];; 56 std::fill( levelcode_, levelcode_ + numCells_*numCells_, 0 ); 57 58 this->maze_ = new unsigned char[ numCells_*numCells_ ]; 59 std::fill( maze_, maze_ + numCells_*numCells_, 0 ); 58 60 59 61 // current traversing position … … 91 93 int NewY = ptY_ + headingY_[ Dir ]; 92 94 93 if ( !Dir || NewX < 0 || NewY < 0 || NewX >= NUM_CELLS || NewY >= NUM_CELLS) return false;94 95 return !maze_[ NewX + NUM_CELLS* NewY ];95 if ( !Dir || NewX < 0 || NewY < 0 || NewX >= numCells_ || NewY >= numCells_ ) return false; 96 97 return !maze_[ NewX + numCells_ * NewY ]; 96 98 } 97 99 … … 150 152 */ 151 153 void MazeGenerator::mazeOut(){ 152 for ( int y = 0; y < NUM_CELLS; y++ )153 { 154 for ( int x = 0; x < NUM_CELLS; x++ )155 { 156 char v = maze_[ y * NUM_CELLS+ x ];154 for ( int y = 0; y < numCells_; y++ ) 155 { 156 for ( int x = 0; x < numCells_; x++ ) 157 { 158 char v = maze_[ y * numCells_ + x ]; 157 159 orxout()<<"["; 158 160 if ( ( v & eDirection_Up ) ) orxout()<<"U"; … … 176 178 */ 177 179 void MazeGenerator::levelOut(){ 178 for ( int y = 0; y < NUM_CELLS; y++ )179 { 180 for ( int x = 0; x < NUM_CELLS; x++ )180 for ( int y = 0; y < numCells_; y++ ) 181 { 182 for ( int x = 0; x < numCells_; x++ ) 181 183 { 182 184 orxout()<<"["; 183 if ( levelcode_[ y * NUM_CELLS+ x ] < 2) orxout()<<"U";184 else orxout()<<" "; 185 if ( levelcode_[ y * NUM_CELLS+ x ] % 2 == 0) orxout()<<"R";185 if ( levelcode_[ y * numCells_ + x ] < 2) orxout()<<"U"; 186 else orxout()<<" "; 187 if ( levelcode_[ y * numCells_ + x ] % 2 == 0) orxout()<<"R"; 186 188 else orxout()<<" "; 187 189 … … 200 202 void MazeGenerator::renderMaze() 201 203 { 202 for ( int y = 0; y < NUM_CELLS; y++ ) 203 { 204 for ( int x = 0; x < NUM_CELLS; x++ ) 205 { 206 char v = maze_[ y * NUM_CELLS + x ]; 207 208 if ( !( v & eDirection_Up ) && y >0) levelcode_[ y * NUM_CELLS + x ] |= 2; 209 if ( !( v & eDirection_Right ) && x <9) levelcode_[ y * NUM_CELLS + x ] |= 1; 210 } 211 } 212 for ( int y = 3; y < 7; y++ ) 213 { 214 for ( int x = 3; x < 7; x++ ) 215 { 216 217 if(y == 3 && x != 7) 218 levelcode_[ y * NUM_CELLS + x ] &= 2; 219 else if (x == 7 && y != 3) 220 levelcode_[ y * NUM_CELLS + x ] &= 1; 221 else if(x != 7) 222 levelcode_[ y * NUM_CELLS + x ] = 0; 204 for ( int y = 0; y < numCells_; y++ ) 205 { 206 for ( int x = 0; x < numCells_; x++ ) 207 { 208 char v = maze_[ y * numCells_ + x ]; 209 210 if ( !( v & eDirection_Up ) && y >0) levelcode_[ y * numCells_ + x ] |= 2; 211 if ( !( v & eDirection_Right ) && x <(numCells_-1)) levelcode_[ y * numCells_ + x ] |= 1; 212 } 213 } 214 215 // leave an empty space in the middle of the maze 216 int lowerBound = numCells_ / 2 - 2; 217 int upperBound = numCells_ / 2 + 2; 218 for ( int y = lowerBound; y < upperBound; y++ ) 219 { 220 for ( int x = lowerBound; x < upperBound; x++ ) 221 { 222 223 if(y == lowerBound && x != upperBound) 224 levelcode_[ y * numCells_ + x ] &= 2; 225 else if (x == upperBound && y != lowerBound) 226 levelcode_[ y * numCells_ + x ] &= 1; 227 else if(x != upperBound) 228 levelcode_[ y * numCells_ + x ] = 0; 223 229 } 224 230 } … … 229 235 int MazeGenerator::cellIdx() 230 236 { 231 return ptX_ + NUM_CELLS* ptY_;237 return ptX_ + numCells_ * ptY_; 232 238 } 233 239 234 240 int MazeGenerator::randomInt() 235 241 { 236 return (rand() % NUM_CELLS);242 return (rand() % numCells_); 237 243 } 238 244 -
code/branches/presentationHS15/src/modules/hover/MazeGenerator.h
r11036 r11040 51 51 { 52 52 public: 53 MazeGenerator( );53 MazeGenerator(int numCells); 54 54 55 55 void generateMaze(); … … 60 60 int* getLevelcode() const 61 61 { return this->levelcode_; } 62 int getNumCells() const63 { return NUM_CELLS; }64 62 65 63 private: … … 71 69 int randomInt4(); 72 70 73 static const int NUM_CELLS = 10;71 int numCells_; 74 72 int* levelcode_; 75 73 unsigned char* maze_;
Note: See TracChangeset
for help on using the changeset viewer.