pub fn create_blocks(world: &mut World, kinds: Vec<i32>) -> Vec<Entity> {
        world.register::<Block>();
        let mut block_entities: Vec<Entity> = Vec::new();

        for i in 0..BLOCKS {
            let mut trans = Transform::default();
            trans.scale = Vector3::new(4.0, 4.0, 4.0);

            // set position instantly so no weird spawn flash happens
            let (x, y) = Stack::i2xy(i);
            let mut b = Block::new(i as u32, kinds[i], x as i32, y as i32);

            let sprite_render_block = SpriteRender {
                sprite_sheet: SpriteSheetLoader::load_blocks_sprite_sheet(world),
                sprite_number: 0,
                flip_horizontal: false,
                flip_vertical: false,
            };

            block_entities.push(world.create_entity()
                .with(sprite_render_block)
                .with(b)
                .with(GlobalTransform::default())
                .with(trans)
                .build());
        }

        block_entities
    }
// creates all entities with block components attached, spritesheet data with sprite_number
creates all entities with block components attached, spritesheet data with sprite_number
creates all entities with block components attached spritesheet data with sprite_number
pub fn create_blocks(world: &mut World, kinds: Vec<i32>) -> Vec<Entity> {
        world.register::<Block>();
        let mut block_entities: Vec<Entity> = Vec::new();
        for i in 0..BLOCKS {
            let mut trans = Transform::default();
            trans.scale = Vector3::new(4.0, 4.0, 4.0);
            // set position instantly so no weird spawn flash happens
            let (x, y) = Stack::i2xy(i);
            let mut b = Block::new(i as u32, kinds[i], x as i32, y as i32);
            let sprite_render_block = SpriteRender {
                sprite_sheet: SpriteSheetLoader::load_blocks_sprite_sheet(world),
                sprite_number: 0,
                flip_horizontal: false,
                flip_vertical: false,
            };
            block_entities.push(world.create_entity()
                .with(sprite_render_block)
                .with(b)
                .with(GlobalTransform::default())
                .with(trans)
                .build());
        }
        block_entities
    }
pub fn create_blocks ( world : & mut World , kinds : Vec < i32 > ) -> Vec < Entity > { world . register :: < Block > ( ) ; let mut block_entities : Vec < Entity > = Vec :: new ( ) ; for i in 0 .. BLOCKS { let mut trans = Transform :: default ( ) ; trans . scale = Vector3 :: new ( 4.0 , 4.0 , 4.0 ) ; // set position instantly so no weird spawn flash happens let ( x , y ) = Stack :: i2xy ( i ) ; let mut b = Block :: new ( i as u32 , kinds [ i ] , x as i32 , y as i32 ) ; let sprite_render_block = SpriteRender { sprite_sheet : SpriteSheetLoader :: load_blocks_sprite_sheet ( world ) , sprite_number : 0 , flip_horizontal : false , flip_vertical : false , } ; block_entities . push ( world . create_entity ( ) . with ( sprite_render_block ) . with ( b ) . with ( GlobalTransform :: default ( ) ) . with ( trans ) . build ( ) ) ; } block_entities }
creates all entities with block components attached, spritesheet data with sprite_number
creates all entities with block components attached spritesheet data with sprite_number
world
&mut World
kinds
Vec<i32>
world
&mut World
kinds
Vec<i32>