This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
en:orx:tutorials:community:sausage:semi-dynamic_objects_and_level_mapping [2010/11/17 12:24 (14 years ago)] – - Better create/delete symmetry (safest too :) ) iarwain | en: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 22: | Line 22: | ||
I have provided a set of tiles for this tutorial here. | I have provided a set of tiles for this tutorial here. | ||
- | {{:en:orx:tutorials: | + | {{tutorials: |
They' | They' | ||
Line 38: | Line 38: | ||
[tile1@TilesGraphic] | [tile1@TilesGraphic] | ||
- | TextureCorner | + | TextureOrigin |
[tile2@TilesGraphic] | [tile2@TilesGraphic] | ||
- | TextureCorner | + | TextureOrigin |
[tile3@TilesGraphic] | [tile3@TilesGraphic] | ||
- | TextureCorner | + | TextureOrigin |
[tile4@TilesGraphic] | [tile4@TilesGraphic] | ||
- | TextureCorner | + | TextureOrigin |
[tile5@TilesGraphic] | [tile5@TilesGraphic] | ||
- | TextureCorner | + | TextureOrigin |
[tile6@TilesGraphic] | [tile6@TilesGraphic] | ||
- | TextureCorner | + | TextureOrigin |
[tile7@TilesGraphic] | [tile7@TilesGraphic] | ||
- | TextureCorner | + | TextureOrigin |
[tile8@TilesGraphic] | [tile8@TilesGraphic] | ||
- | TextureCorner | + | TextureOrigin |
[tile9@TilesGraphic] | [tile9@TilesGraphic] | ||
- | TextureCorner | + | TextureOrigin |
Line 83: | Line 83: | ||
<code c>bool PaintTiles(int tileIndexPosition){ | <code c>bool PaintTiles(int tileIndexPosition){ | ||
- | int mapLength = sizeof(map) / sizeof(map[0]); | + | |
- | orxLOG(" | + | orxLOG(" |
- | if (tileIndexPosition >= mapLength) | + | if (tileIndexPosition >= mapLength) |
- | return false; | + | return false; |
- | + | ||
- | for (int x=0; x< | + | |
- | int i = x + tileIndexPosition; | + | |
- | + | ||
- | if (i > mapLength-1){ | + | |
- | return false; //out of tiles, no more drawing | + | |
- | } | + | |
- | + | ||
- | orxOBJECT *tile; | + | |
- | tile = orxObject_CreateFromConfig(" | + | |
- | + | ||
- | orxGRAPHIC *graphic; | + | |
- | orxCHAR buffer[6]; | + | |
- | orxString_Print(buffer, | + | |
- | + | ||
- | graphic = orxGraphic_CreateFromConfig(buffer); | + | |
- | orxObject_LinkStructure(tile, | + | |
- | orxVECTOR tilePos; | + | for (int x=0; x< |
- | tilePos.fX = (80 * x) ; | + | int i = x + tileIndexPosition; |
- | tilePos.fY | + | |
- | tilePos.fZ | + | |
- | + | ||
- | orxObject_SetPosition(tile, | + | |
- | } | + | if (i > mapLength-1){ |
+ | return false; //out of tiles, no more drawing | ||
+ | | ||
- | return true; | + | //Create String in format: Tile{Number}, |
+ | orxCHAR buffer[16] = {}; | ||
+ | orxString_NPrint(buffer, | ||
+ | |||
+ | //Create Tile{Number} object from config file, utilizing string created above. | ||
+ | //Note our tiles are stored as " | ||
+ | orxGRAPHIC *graphic; | ||
+ | graphic = orxGraphic_CreateFromConfig(buffer); | ||
+ | |||
+ | //Create Default Tile object, which holds our fullsize image. | ||
+ | orxOBJECT *tile; | ||
+ | tile = orxObject_CreateFromConfig(" | ||
+ | |||
+ | //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, | ||
+ | |||
+ | //Position our tile on the screen. | ||
+ | orxVECTOR tilePos; | ||
+ | tilePos.fX = (80 * x); | ||
+ | tilePos.fY = 160; | ||
+ | tilePos.fZ = 0; | ||
+ | orxObject_SetPosition(tile, | ||
+ | |||
+ | } | ||
+ | |||
+ | | ||
}</ | }</ | ||