diff --git a/src/lofpara_atlas.rs b/src/lofpara_atlas.rs index 542b35f..7746282 100644 --- a/src/lofpara_atlas.rs +++ b/src/lofpara_atlas.rs @@ -1,18 +1,32 @@ use bevy::prelude::*; #[derive(Resource)] -pub struct LofparaAtlas(TextureAtlasLayout); +pub struct LofparaAtlasLayout(pub TextureAtlasLayout); + +#[derive(Resource)] +pub struct LofparaAtlasImage(Handle); + +impl LofparaAtlasImage { + pub fn get(&self) -> Handle { + return self.0.clone(); + } +} pub struct LofparaAtlasPlugin; impl Plugin for LofparaAtlasPlugin { fn build(&self, app: &mut App) { - let mut atlas = TextureAtlasLayout::new_empty(UVec2::new(1920, 1080)); + let mut atlas_layout = TextureAtlasLayout::new_empty(UVec2::new(1920, 1080)); //Card, index = 0 - atlas.add_texture(URect::new(0, 0, 258, 363)); + atlas_layout.add_texture(URect::new(0, 0, 258, 363)); //Cardholder, index = 1 - atlas.add_texture(URect::new(259, 0, 166, 166)); + atlas_layout.add_texture(URect::new(259, 0, 166, 166)); - app.insert_resource(LofparaAtlas(atlas)); + app.insert_resource(LofparaAtlasLayout(atlas_layout)) + .add_systems(Startup, startup_image); } } + +fn startup_image(mut commands: Commands, asset_server: Res) { + commands.insert_resource(LofparaAtlasImage(asset_server.load("atlas.png"))); +}