User Tools

Site Tools


en:tutorials:mapping:semi-dynamic_objects_and_level_mapping

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
tutorials:community:sausage:semi-dynamic_objects_and_level_mapping [2015/12/06 12:10 (8 years ago)] – external edit 127.0.0.1en:tutorials:mapping:semi-dynamic_objects_and_level_mapping [2020/08/31 06:54 (4 years ago)] (current) – ↷ Page moved from en:tutorials:community:sausage:semi-dynamic_objects_and_level_mapping to en:tutorials:mapping:semi-dynamic_objects_and_level_mapping sausage
Line 38: Line 38:
  
 [tile1@TilesGraphic] [tile1@TilesGraphic]
-TextureCorner = (0, 0, 0)+TextureOrigin = (0, 0, 0)
  
 [tile2@TilesGraphic] [tile2@TilesGraphic]
-TextureCorner = (80, 0, 0)+TextureOrigin = (80, 0, 0)
  
 [tile3@TilesGraphic] [tile3@TilesGraphic]
-TextureCorner = (160, 0, 0)+TextureOrigin = (160, 0, 0)
  
 [tile4@TilesGraphic] [tile4@TilesGraphic]
-TextureCorner = (0, 80, 0)+TextureOrigin = (0, 80, 0)
  
 [tile5@TilesGraphic] [tile5@TilesGraphic]
-TextureCorner = (80, 80, 0)+TextureOrigin = (80, 80, 0)
  
 [tile6@TilesGraphic] [tile6@TilesGraphic]
-TextureCorner = (160, 80, 0)+TextureOrigin = (160, 80, 0)
  
 [tile7@TilesGraphic] [tile7@TilesGraphic]
-TextureCorner = (0, 160, 0)+TextureOrigin = (0, 160, 0)
  
 [tile8@TilesGraphic] [tile8@TilesGraphic]
-TextureCorner = (80, 160, 0)+TextureOrigin = (80, 160, 0)
  
 [tile9@TilesGraphic] [tile9@TilesGraphic]
-TextureCorner = (160, 160, 0)</code>+TextureOrigin = (160, 160, 0)</code>
  
  
Line 83: Line 83:
 <code c>bool PaintTiles(int tileIndexPosition){ <code c>bool PaintTiles(int tileIndexPosition){
  
- int mapLength = sizeof(map) / sizeof(map[0]); +    int mapLength = sizeof(map) / sizeof(map[0]); 
- orxLOG("Length %d map[0] %d map %d", mapLength, sizeof(map[0]), sizeof(map)    ); +        orxLOG("Length %d map[0] %d map %d", mapLength, sizeof(map[0]), sizeof(map)    ); 
- if (tileIndexPosition >= mapLength) +    if (tileIndexPosition >= mapLength) 
- return false+        return false;
-  +
- for (int x=0; x<TILES_ACROSS; x++){ +
- int i = x + tileIndexPosition; +
-  +
- if (i > mapLength-1){ +
- return false; //out of tiles, no more drawing +
-+
-  +
- orxOBJECT *tile; +
- tile = orxObject_CreateFromConfig("TilesObject"); +
-  +
- orxGRAPHIC *graphic; +
- orxCHAR buffer[6]; +
- orxString_Print(buffer, "tile%d", map[i]); +
-  +
- graphic = orxGraphic_CreateFromConfig(buffer); +
- orxObject_LinkStructure(tile, orxSTRUCTURE(graphic));+
  
- orxVECTOR tilePos; +    for (int x=0x<TILES_ACROSS; x++){ 
- tilePos.fX = (80 * x) ; +        int i x + tileIndexPosition;
- tilePos.fY 160+
- tilePos.fZ 0; +
-  +
- orxObject_SetPosition(tile, &tilePos);+
  
- }+        if (i > mapLength-1){ 
 +            return false; //out of tiles, no more drawing 
 +        }
  
- return true;+        //Create String in format: Tile{Number}, for example "tile8"
 +        orxCHAR buffer[16] = {}; 
 +        orxString_NPrint(buffer, sizeof(buffer) - 1, "tile%d", map[i]); 
 + 
 +        //Create Tile{Number} object from config file, utilizing string created above. 
 +        //Note our tiles are stored as "[tile8@TilesGraphic]" in our config file.  
 +        orxGRAPHIC *graphic; 
 +        graphic = orxGraphic_CreateFromConfig(buffer); 
 + 
 +        //Create Default Tile object, which holds our fullsize image. 
 +        orxOBJECT *tile; 
 +        tile = orxObject_CreateFromConfig("TilesObject"); 
 + 
 +        //Link our Tile{Number} config to our fullsize image. 
 +        //The Tile{Number} config contains the portion of our fullsize tilemap image that we want to display. 
 +        orxObject_LinkStructure(tile, orxSTRUCTURE(graphic)); 
 + 
 +        //Position our tile on the screen. 
 +        orxVECTOR tilePos; 
 +        tilePos.fX = (80 * x); 
 +        tilePos.fY = 160; 
 +        tilePos.fZ = 0; 
 +        orxObject_SetPosition(tile, &tilePos); 
 + 
 +    } 
 + 
 +    return true;
 }</code> }</code>
  
en/tutorials/mapping/semi-dynamic_objects_and_level_mapping.1449432654.txt.gz · Last modified: 2017/05/30 00:50 (7 years ago) (external edit)