Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Micro Game Macros
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Microhacks
Micro Game Macros
Commits
8e125fdd
Verified
Commit
8e125fdd
authored
1 year ago
by
Louis
Browse files
Options
Downloads
Patches
Plain Diff
Add README.md
parent
32fb2516
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
README.md
+81
-0
81 additions, 0 deletions
README.md
with
81 additions
and
0 deletions
README.md
0 → 100644
+
81
−
0
View file @
8e125fdd
# Micro Game Macros


A collection of utility macros for building games
## Macros
For executable examples, visit the rustdoc and/or read the doctests in
`src/lib.rs`
### JSON Loader
Generate a Bevy asset loader for a given asset, supporting JSON files that define a single instance of that asset type, or a
list of that asset type. Instances of an asset need to be identifiable, though the property that is used to identify a particular
asset is customisable
```
rust
#[derive(JsonLoader,
TypePath,
TypeUuid,
Serialize,
Deserialize)]
#[loader(
extension
=
"asset.json"
,
uuid
=
"00000000-0000-0000-0000-000000000000"
,
storage
=
inner_module::SimpleAssetLocator,
asset_name
=
some_asset_prop,
index_name
=
set_of_assets
)]
#[uuid
=
"00000000-0000-0000-0000-000000000001"
]
pub
struct
MyAsset
{
/// The asset identifier needs to implement [std::fmt::Display]
#[asset_id]
uniq_ident
:
usize
,
}
```
### Asset System
Generate a set of structs and systems for managed loading in a Bevy game
```
rust
use
bevy
::
prelude
::{
Image
,
Res
,
Resource
};
use
micro_games_macros
::
asset_system
;
#[asset_system]
pub
struct
AssetHandles
{
my_asset
:
Image
,
}
pub
fn
loading_system
(
mut
loader
:
AssetHandlesLoader
)
{
loader
.load_my_asset
(
"path/to/asset.png"
,
"Asset"
);
}
pub
fn
use_asset_system
(
assets
:
Res
<
AssetHandles
>
)
{
let
handle
=
assets
.my_asset
(
"Asset"
);
}
```
### From Inner
Derive an impl of
`From<T>`
for structs that wrap a single inner type (Tuple and Named Property structs are supported)
```
rust
use
micro_game_macros
::
FromInner
;
#[derive(FromInner)]
struct
MyType
(
usize
);
fn
example
()
{
let
value
=
MyType
::
from
(
123usize
);
}
```
### Kayak Widget
A simple derive for Kayak UI's "Widget" trait
```
rust
use
micro_game_macros
::
Widget
;
#[derive(Widget)]
struct
MyComponent
;
// ... Other Kayak Setup ...
```
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment