Fix off-by-one error as a blank tile is pushed before all the others
parent
f3170b6b4b
commit
a61b799c72
|
@ -264,7 +264,7 @@ pub fn get_sprites( tilemap: &TiledTilemap, sprite_ids: &HashMap<String, u16> )
|
|||
let mut result: Vec<u8> = Vec::new();
|
||||
|
||||
let tiles_before = {
|
||||
let mut total_tiles = 0;
|
||||
let mut total_tiles = 1;
|
||||
|
||||
for tileset in &tilemap.tileset {
|
||||
// do not include the sprite metadata
|
||||
|
@ -285,7 +285,7 @@ pub fn get_sprites( tilemap: &TiledTilemap, sprite_ids: &HashMap<String, u16> )
|
|||
let sprite_id = sprite_ids.get( &sprite_metadata.id ).ok_or( format!( "invalid file: undefined sprite id \"{}\"", sprite_metadata.id ) )?;
|
||||
result.extend( sprite_id.to_be_bytes() );
|
||||
|
||||
let tile_index_location = tiles_before + tiles_after + 1;
|
||||
let tile_index_location = tiles_before + tiles_after;
|
||||
result.extend( ( tile_index_location as u16 ).to_be_bytes() );
|
||||
tiles_after += ( sprite_metadata.width * sprite_metadata.height ) as u32;
|
||||
|
||||
|
@ -319,7 +319,7 @@ pub fn get_code( tilemap: &TiledTilemap, level_name: &str, path_prefix: &str ) -
|
|||
let level_label = symbol_to_pascal( level_name );
|
||||
let ( width, height ) = ( tilemap.width, tilemap.height );
|
||||
let num_tiles = {
|
||||
let mut total_tiles = 0;
|
||||
let mut total_tiles = 1;
|
||||
|
||||
for tileset in &tilemap.tileset {
|
||||
total_tiles += ( tileset.image.width() / 8 ) * ( tileset.image.height() / 8 ); // --system md
|
||||
|
|
Loading…
Reference in New Issue