Compare commits

..

No commits in common. "47972f0f6c7baa52fd6f9b37d70e734abc4a4c8d" and "0d5b18f45866ed890adff742a78a1686c5ef4a7f" have entirely different histories.

4 changed files with 8 additions and 67 deletions

View file

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

View file

@ -1,29 +0,0 @@
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,43 +1,18 @@
use bevy::prelude::*;
#[derive(Resource)]
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 LofparaAtlas(TextureAtlasLayout);
pub struct LofparaAtlasPlugin;
impl Plugin for LofparaAtlasPlugin {
fn build(&self, app: &mut App) {
app.add_systems(Startup, startup_image);
}
}
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));
let mut atlas = TextureAtlasLayout::new_empty(UVec2::new(1920, 1080));
//Card, index = 0
atlas_layout.add_texture(URect::new(0, 0, 258, 363));
atlas.add_texture(URect::new(0, 0, 258, 363));
//Cardholder, index = 1
atlas_layout.add_texture(URect::new(259, 0, 166, 166));
atlas.add_texture(URect::new(259, 0, 166, 166));
commands.insert_resource(LofparaAtlasLayout(atlas_layouts.add(atlas_layout)));
app.insert_resource(LofparaAtlas(atlas));
}
}

View file

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