mirror of
https://github.com/italicsjenga/agb.git
synced 2025-01-22 23:26:33 +11:00
Graphics
This commit is contained in:
parent
6f064b0d99
commit
8f7e7748e2
1 changed files with 21 additions and 2 deletions
|
@ -67,15 +67,32 @@ pub enum Size {
|
|||
#[macro_export]
|
||||
macro_rules! include_aseprite {
|
||||
($($aseprite_path: expr),*) => {{
|
||||
use $crate::display::object::{Size, Sprite, Tag, TagMap};
|
||||
use $crate::display::object::{Size, Sprite, Tag, TagMap, Graphics};
|
||||
use $crate::display::palette16::Palette16;
|
||||
|
||||
$crate::include_aseprite_inner!($($aseprite_path),*);
|
||||
|
||||
(SPRITES, TAGS)
|
||||
&Graphics::new(SPRITES, TAGS)
|
||||
}};
|
||||
}
|
||||
|
||||
pub struct Graphics {
|
||||
sprites: &'static [Sprite],
|
||||
tag_map: &'static TagMap,
|
||||
}
|
||||
|
||||
impl Graphics {
|
||||
pub const fn new(sprites: &'static [Sprite], tag_map: &'static TagMap) -> Self {
|
||||
Self { sprites, tag_map }
|
||||
}
|
||||
pub const fn tags(&self) -> &TagMap {
|
||||
self.tag_map
|
||||
}
|
||||
pub const fn sprites(&self) -> &[Sprite] {
|
||||
self.sprites
|
||||
}
|
||||
}
|
||||
|
||||
pub struct TagMap {
|
||||
tags: &'static [(&'static str, Tag)],
|
||||
}
|
||||
|
@ -170,8 +187,10 @@ impl Tag {
|
|||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub const fn new(sprites: &'static [Sprite], from: usize, to: usize, direction: usize) -> Self {
|
||||
assert!(from <= to);
|
||||
assert!(to < sprites.len());
|
||||
Self {
|
||||
sprites: &sprites[from] as *const Sprite,
|
||||
len: to - from + 1,
|
||||
|
|
Loading…
Add table
Reference in a new issue