Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- OatCube, you might already know this, but here is a rough sketch on how to optimize your auto tiling.
- Assuming you are not already doing something like this.
- Key Points :
- 1. Sprite Sheet For All Auto Tile Sets on ONE BITMAP.
- 2. 4 Bit Mask to calculate touching value ( t ).
- #####################################################################
- //: c : Current Tile ://
- //:gtv: Get Tile Value ://
- //: t : touching value ://
- var c = gtv( 0 , 0 );
- const ___ = ( 0 ) ;
- const x_0 = ( 0 - 1 ) ;
- const x_1 = ( 0 + 1 ) ;
- const y_0 = ( 0 - 1 ) ;
- const y_1 = ( 0 + 1 ) ;
- //: BINARY:::[ 1 1 1 1 ]
- //: SYMBOLIC:[ x_0 x_1 y_0 y_1 ]
- //: +-----+
- //: | y_0 |
- //: +-----+
- //: +-----++-----++-----+
- //: | x_0 || c || x_1 |
- //: +-----++-----++-----+
- //: +-----+
- //: | y_1 |
- //: +-----+
- //: Sprite Sheet, graphics patterns for all
- //: possible 16 touching values ( t ).
- BINARY: 0000 BINARY:1111
- | |
- [ 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | ... | 15 ]
- var t =( 0x00
- | ( ( c == gtv( x_0 , ___ ) ) << 3 )
- | ( ( c == gtv( x_1 , ___ ) ) << 2 )
- | ( ( c == gtv( ___ , y_0 ) ) << 1 )
- | ( ( c == gtv( ___ , y_1 ) ) << 0 )
- );;
- /// correct_sub_tile_graphic_index === t ///
- var graphic_origin_x =( t * tile_width_in_pixels );
- var graphic_origin_y =( tile_material_type * tile_height_in_pixels );
- Assuming your sprite sheet looks like
- X cell index === Sub Tile Index
- Y cell index === Material Type Index
- G == Graphic Cell
- 0 1 2 3 4 5 6 7 .... SubTileIndex
- +---+---+---+---+---+---+---+---+
- 0 | G | G | G | G | G | G | G | G |
- +---+---+---+---+---+---+---+---+
- 1 | G | G | G | G | G | G | G | G |
- +---+---+---+---+---+---+---+---+
- 2 | G | G | G | G | G | G | G | G |
- +---+---+---+---+---+---+---+---+
- 3 | G | G | G | G | G | G | G | G |
- +---+---+---+---+---+---+---+---+
- 4 | G | G | G | G | G | G | G | G |
- +---+---+---+---+---+---+---+---+
- #####################################################################
Add Comment
Please, Sign In to add comment