Compare commits
2 commits
0d5b18f458
...
47972f0f6c
| Author | SHA1 | Date | |
|---|---|---|---|
| 47972f0f6c | |||
| d091b6474b |
4 changed files with 67 additions and 8 deletions
4
src/cards/hand.rs
Normal file
4
src/cards/hand.rs
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
use bevy::prelude::*;
|
||||
|
||||
#[derive(Component)]
|
||||
pub struct Hand;
|
||||
29
src/cards/mod.rs
Normal file
29
src/cards/mod.rs
Normal 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: () })
|
||||
},*/
|
||||
));
|
||||
}
|
||||
|
|
@ -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)));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ use bevy::prelude::*;
|
|||
|
||||
use crate::lofpara_atlas::LofparaAtlasPlugin;
|
||||
|
||||
mod cards;
|
||||
mod lofpara_atlas;
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue