-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
1,117 additions
and
892 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
( | ||
path: "textures/enemies/crab.png", | ||
tile_size: Vec2(32., 32.), | ||
columns: 8, | ||
rows: 10, | ||
padding: None, | ||
offset: None | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
( | ||
path: "textures/enemies/deathknight.png", | ||
tile_size: Vec2(42., 42.), | ||
columns: 5, | ||
rows: 9, | ||
padding: None, | ||
offset: None | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
( | ||
path: "textures/enemies/skeleton.png", | ||
tile_size: Vec2(48., 48.), | ||
columns: 4, | ||
rows: 9, | ||
padding: None, | ||
offset: None | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
( | ||
path: "textures/enemies/skeleton2.png", | ||
tile_size: Vec2(48., 48.), | ||
columns: 4, | ||
rows: 9, | ||
padding: None, | ||
offset: None | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
( | ||
path: "textures/enemies/snake.png", | ||
tile_size: Vec2(28., 28.), | ||
columns: 6, | ||
rows: 9, | ||
padding: None, | ||
offset: None | ||
) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
use bevy::{ | ||
asset::{io::Reader, AssetLoader, AsyncReadExt, LoadContext}, | ||
prelude::*, | ||
utils::BoxedFuture, | ||
}; | ||
use serde::Deserialize; | ||
|
||
#[derive(Asset, TypePath, Deserialize)] | ||
struct AtlasImageDescriptor { | ||
path: String, | ||
tile_size: Vec2, | ||
columns: usize, | ||
rows: usize, | ||
padding: Option<Vec2>, | ||
offset: Option<Vec2>, | ||
} | ||
|
||
#[derive(Asset, TypePath)] | ||
pub struct AtlasImage { | ||
pub image: Handle<Image>, | ||
pub layout: Handle<TextureAtlasLayout>, | ||
} | ||
|
||
pub struct AtlasImageLoader; | ||
|
||
impl AssetLoader for AtlasImageLoader { | ||
type Asset = AtlasImage; | ||
type Settings = (); | ||
type Error = anyhow::Error; | ||
fn load<'a>( | ||
&'a self, | ||
reader: &'a mut Reader, | ||
_settings: &'a (), | ||
load_context: &'a mut LoadContext, | ||
) -> BoxedFuture<'a, Result<Self::Asset, Self::Error>> { | ||
Box::pin(async move { | ||
let mut bytes = Vec::new(); | ||
reader.read_to_end(&mut bytes).await?; | ||
let desc = ron::de::from_bytes::<AtlasImageDescriptor>(&bytes)?; | ||
|
||
let layout = TextureAtlasLayout::from_grid( | ||
desc.tile_size, | ||
desc.columns, | ||
desc.rows, | ||
desc.padding, | ||
desc.offset, | ||
); | ||
|
||
let layout_handle = load_context.add_labeled_asset("layout".to_string(), layout); | ||
|
||
Ok(AtlasImage { | ||
image: load_context.load(desc.path), | ||
layout: layout_handle, | ||
}) | ||
}) | ||
} | ||
|
||
fn extensions(&self) -> &[&str] { | ||
&["atlas.ron"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.