Lofpara atlas complete
This commit is contained in:
parent
d091b6474b
commit
47972f0f6c
4 changed files with 55 additions and 10 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,7 +1,13 @@
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
|
|
||||||
#[derive(Resource)]
|
#[derive(Resource)]
|
||||||
pub struct LofparaAtlasLayout(pub TextureAtlasLayout);
|
pub struct LofparaAtlasLayout(Handle<TextureAtlasLayout>);
|
||||||
|
|
||||||
|
impl LofparaAtlasLayout {
|
||||||
|
pub fn get(&self) -> Handle<TextureAtlasLayout> {
|
||||||
|
return self.0.clone();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Resource)]
|
#[derive(Resource)]
|
||||||
pub struct LofparaAtlasImage(Handle<Image>);
|
pub struct LofparaAtlasImage(Handle<Image>);
|
||||||
|
|
@ -16,17 +22,22 @@ 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_layout = TextureAtlasLayout::new_empty(UVec2::new(1920, 1080));
|
app.add_systems(Startup, startup_image);
|
||||||
//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));
|
|
||||||
|
|
||||||
app.insert_resource(LofparaAtlasLayout(atlas_layout))
|
|
||||||
.add_systems(Startup, startup_image);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn startup_image(mut commands: Commands, asset_server: Res<AssetServer>) {
|
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")));
|
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;
|
use crate::lofpara_atlas::LofparaAtlasPlugin;
|
||||||
|
|
||||||
|
mod cards;
|
||||||
mod lofpara_atlas;
|
mod lofpara_atlas;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue