Compare commits

...

2 commits

Author SHA1 Message Date
47972f0f6c Lofpara atlas complete 2025-11-19 22:25:00 +05:00
d091b6474b Image 2025-11-19 21:32:37 +05:00
4 changed files with 67 additions and 8 deletions

4
src/cards/hand.rs Normal file
View file

@ -0,0 +1,4 @@
use bevy::prelude::*;
#[derive(Component)]
pub struct Hand;

29
src/cards/mod.rs Normal file
View file

@ -0,0 +1,29 @@
use crate::lofpara_atlas::*;
use bevy::prelude::*;
pub mod hand;
#[derive(Component)]
pub struct Card;
#[derive(Event)]
pub struct CreateCard {
parent: Option<Entity>,
}
pub fn on_create_card(
event: On<CreateCard>,
mut commands: Commands,
atlas_layout: Res<LofparaAtlasLayout>,
atlas_sprite: Res<LofparaAtlasImage>,
) {
commands.spawn((
Card,
Transform::from_xyz(0., 0., 0.),
/*Sprite {
image: atlas_sprite.get(),
image_mode: SpriteImageMode::Auto,
texture_atlas: Some(TextureAtlas { layout: , index: () })
},*/
));
}

View file

@ -1,18 +1,43 @@
use bevy::prelude::*;
#[derive(Resource)]
pub struct LofparaAtlas(TextureAtlasLayout);
pub struct LofparaAtlasLayout(Handle<TextureAtlasLayout>);
impl LofparaAtlasLayout {
pub fn get(&self) -> Handle<TextureAtlasLayout> {
return self.0.clone();
}
}
#[derive(Resource)]
pub struct LofparaAtlasImage(Handle<Image>);
impl LofparaAtlasImage {
pub fn get(&self) -> Handle<Image> {
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));
//Card, index = 0
atlas.add_texture(URect::new(0, 0, 258, 363));
//Cardholder, index = 1
atlas.add_texture(URect::new(259, 0, 166, 166));
app.add_systems(Startup, startup_image);
}
}
app.insert_resource(LofparaAtlas(atlas));
}
fn startup_image(
mut commands: Commands,
asset_server: Res<AssetServer>,
mut atlas_layouts: ResMut<Assets<TextureAtlasLayout>>,
) {
commands.insert_resource(LofparaAtlasImage(asset_server.load("atlas.png")));
let mut atlas_layout = TextureAtlasLayout::new_empty(UVec2::new(1920, 1080));
//Card, index = 0
atlas_layout.add_texture(URect::new(0, 0, 258, 363));
//Cardholder, index = 1
atlas_layout.add_texture(URect::new(259, 0, 166, 166));
commands.insert_resource(LofparaAtlasLayout(atlas_layouts.add(atlas_layout)));
}

View file

@ -2,6 +2,7 @@ use bevy::prelude::*;
use crate::lofpara_atlas::LofparaAtlasPlugin;
mod cards;
mod lofpara_atlas;
fn main() {