Open pyweeker opened 2 years ago
Hi, I am not sure I understand, correct me if I am wrong, but you have tried to change the
#[derive(Default)]
struct SpriteImages {
empty_cell: Handle<Image>,
alive_cell: Handle<Image>,
dead_cell: Handle<Image>,
}
with
#[derive(Default)]
struct SpriteImages {
empty_cell: SpriteBundle,
alive_cell: SpriteBundle,
dead_cell: SpriteBundle,
}
Regarding trait implementation for types and traits that are not "yours", you can always create a wrapper type and then implement a trait for it.
But the above problem requires a simpler solution and I think you could use something from this:
#[derive(Default)]
struct SpriteImages {
empty_cell: Handle<ColorMaterial>,
alive_cell: Handle<ColorMaterial>,
dead_cell: Handle<ColorMaterial>,
}
..... // some arbitrary code
commands
.insert_resource(SpriteImages {
empty_cell: materials.add(ColorMaterial {
color: Color::rgba(0.1, 0.1, 0.1, 0.1),
texture: Some(asset_server.load("sprites/alive_cell.png"))
}).clone(),
..... // rest of the fields
});
I haven't tested it yet, but I think you need ColorMaterial, where you can specify the color and the texture. Then you can always reference this resource from the code, whenever you need to access the "original colours". I haven't had the time to actually fully implement this and tested it though, so keep that in mind :)
Hi, have a look :
Hello, one question, is there a way to make a multi colored species without matrix ? because i tried to change in simulation.rs in struct SpriteImages the fields of type handle < Image > by bevy::prelude::SpriteBundle with color rgba, instead of png. But Component trait is not implemented for SpriteBundle and it is not allowed to add traits on crate.
We can imagine that if a blue cell meet a red cell each with alpha 0.4 , they can give birth of a pink alpha 0.8 by adding their rgba and cycle colors over > 1.0
https://i.pinimg.com/736x/d3/7e/dd/d37edd6d271a59492ee3aebfddd8d765--game-of-life-glass.jpg
https://www.native-instruments.com/fileadmin/processed/csm_1107441_3824.Langton__39_s_Ant_v1.0_a3e28c6d5b.png