This commit is contained in:
Rendo 2025-11-19 21:32:37 +05:00
commit d091b6474b

View file

@ -1,18 +1,32 @@
use bevy::prelude::*; use bevy::prelude::*;
#[derive(Resource)] #[derive(Resource)]
pub struct LofparaAtlas(TextureAtlasLayout); pub struct LofparaAtlasLayout(pub TextureAtlasLayout);
#[derive(Resource)]
pub struct LofparaAtlasImage(Handle<Image>);
impl LofparaAtlasImage {
pub fn get(&self) -> Handle<Image> {
return self.0.clone();
}
}
pub struct LofparaAtlasPlugin; pub struct LofparaAtlasPlugin;
impl Plugin for LofparaAtlasPlugin { impl Plugin for LofparaAtlasPlugin {
fn build(&self, app: &mut App) { 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 //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 //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<AssetServer>) {
commands.insert_resource(LofparaAtlasImage(asset_server.load("atlas.png")));
}