Crates.io | yuxii |
lib.rs | yuxii |
version | 0.0.3 |
source | src |
created_at | 2023-03-16 18:24:43.063434 |
updated_at | 2023-03-16 19:02:15.878293 |
description | ECS-based 3D game engine |
homepage | https://github.com/ggaast/Yuxii |
repository | https://github.com/ggaast/Yuxii |
max_upload_size | |
id | 811961 |
size | 40,950 |
Yuxii is an ECS-based 3D game engine.
Main purpose is to be very simple to use and learn.
Warning! Nothing is done yet.
In Yuxii Node is a logic and a scene at once.
Lets see an Example:
/* file: src/my_node/mod.rs */
#[node]
pub struct MyNode;
#[node]
impl MyNode{
fn init(&self){ }
fn frame(&self) { }
fn scene() -> Scene { }
}
Alright, we just created a node.
init
is called when we start the program
frame
is called each frame asynchronically . You can put there systems to execute.
scene
is for spawning entities and their modifiers
But without connecting this node to main program it cant do any logic
So lets fix it and plug our node logic in the world:
/* file: src/main.rs */
fn main(){
MyNode.plug();
// We can also spawn this node content:
MyNode::spawn();
// Run
Yuxii::run();
}
NodeName (Folder)
mod.rs
resources.rs
scene.ron
systems.rs
You can easily add system from any part of your project, but after Yuxii::run()
#[system]
fn my_system(){ /* do something */ }
and add it:
fn frame(&self){
my_system();
}
Queries are very powerfull in this engine (should be, not yet) Lets get into example:
#[system]
fn my_system(){
// This query will be removed by macro and will not appear in docs
/// *GetMut, &GetRef, Added+, &OptionRef?
{
get_mut.field = "oh, hey";
}
// And we have even better parenting
/// Parent:: *GetMut
{
parent_get_mut.field = "looks easy";
}
// Custom naming
/// *[my_vel]Velocity
{
my_vel;
}
}
#[derive(Component)]
pub struct MyComponent{
/// def 9
pub field: i32,
/// def "Hello World"
pub private: String
}
It will automatically implement Default according to docs attributes.
Add component:
let entity = World::spawn();
entity << MyComponent{ field: 65, ..default() };
#[derive(Global)]
pub struct MyGlobal{
/// def "It is global"
pub info: String
}
globals instances are automatically adding to the world at their definition. It means, you can access it after its definition.
fn system(){
let lock = MyGlobal::read();
log << "MyGlobal info: " << lock.info;
}
todo!();