Despawn black characters
This commit is contained in:
parent
160e881ba7
commit
14eb48dcf8
2 changed files with 23 additions and 5 deletions
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
[Play in browser](https://txmn.tk/projects/lux-synthese/)
|
[Play in browser](https://txmn.tk/projects/lux-synthese/)
|
||||||
|
|
||||||
|
In latin, _lux synthesĕ_ means "light by the means of synthesia".
|
||||||
|
|
||||||
## Controls
|
## Controls
|
||||||
|
|
||||||
* **Move**: arrows
|
* **Move**: arrows
|
||||||
|
@ -14,12 +16,10 @@
|
||||||
## TODO
|
## TODO
|
||||||
|
|
||||||
* more filters
|
* more filters
|
||||||
* despawn black characters
|
|
||||||
* despawn character when too far
|
|
||||||
* more levels
|
* more levels
|
||||||
* (?) multiplayer
|
* (?) multiplayer
|
||||||
* more audio
|
* more audio
|
||||||
* bug: in level2, move the blue character to win, then reset. The characters are lighter than expected. (also level 4)
|
* bug: when reset after win, character colors are wrong
|
||||||
* redshift warning
|
* redshift warning
|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
|
@ -54,6 +54,8 @@ Skip to level `N: u32` with the command `bevyjam <N>`.
|
||||||
|
|
||||||
Edit the level `N: u32` with the command `bevyjam <N> e`.
|
Edit the level `N: u32` with the command `bevyjam <N> e`.
|
||||||
|
|
||||||
|
Editor is not available in the WASM build.
|
||||||
|
|
||||||
### Editor controls
|
### Editor controls
|
||||||
|
|
||||||
* **Select**: left click to select, click in void to deselect, CTRL+click to select many, CTRL+A to select all
|
* **Select**: left click to select, click in void to deselect, CTRL+click to select many, CTRL+A to select all
|
||||||
|
|
20
src/game.rs
20
src/game.rs
|
@ -398,6 +398,8 @@ fn collision_event_system(
|
||||||
)>,
|
)>,
|
||||||
pass_through_filter_query: Query<&PassThroughFilter>,
|
pass_through_filter_query: Query<&PassThroughFilter>,
|
||||||
melty_query: Query<&Melty>,
|
melty_query: Query<&Melty>,
|
||||||
|
mut character_list: ResMut<CharacterList>,
|
||||||
|
mut change_character_event: EventWriter<ChangeCharacterEvent>,
|
||||||
) {
|
) {
|
||||||
for collision_event in collision_events.iter() {
|
for collision_event in collision_events.iter() {
|
||||||
if let CollisionEvent::Started(e1, e2, flags) = collision_event {
|
if let CollisionEvent::Started(e1, e2, flags) = collision_event {
|
||||||
|
@ -416,20 +418,34 @@ fn collision_event_system(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if *flags == CollisionEventFlags::SENSOR {
|
} else if *flags == CollisionEventFlags::SENSOR {
|
||||||
if let (Ok((mut c_color, _c_transform, mut c_material, _c_player)), Ok(filter)) = (
|
if let (Ok((mut c_color, _c_transform, mut c_material, c_player)), Ok(filter)) = (
|
||||||
character_query.get_mut(*e1),
|
character_query.get_mut(*e1),
|
||||||
pass_through_filter_query.get(*e2),
|
pass_through_filter_query.get(*e2),
|
||||||
) {
|
) {
|
||||||
c_color.0 = filter.apply(c_color.0);
|
c_color.0 = filter.apply(c_color.0);
|
||||||
|
if c_color.0.as_hsla_f32()[2] < 0.1 {
|
||||||
|
commands.entity(*e1).despawn_recursive();
|
||||||
|
character_list.0.remove(e1);
|
||||||
|
if c_player.is_some() {
|
||||||
|
change_character_event.send(ChangeCharacterEvent);
|
||||||
|
}
|
||||||
|
}
|
||||||
*c_material = materials.add(ColorMaterial::from(c_color.0));
|
*c_material = materials.add(ColorMaterial::from(c_color.0));
|
||||||
} else if let (
|
} else if let (
|
||||||
Ok((mut c_color, _c_transform, mut c_material, _c_player)),
|
Ok((mut c_color, _c_transform, mut c_material, c_player)),
|
||||||
Ok(filter),
|
Ok(filter),
|
||||||
) = (
|
) = (
|
||||||
character_query.get_mut(*e2),
|
character_query.get_mut(*e2),
|
||||||
pass_through_filter_query.get(*e1),
|
pass_through_filter_query.get(*e1),
|
||||||
) {
|
) {
|
||||||
c_color.0 = filter.apply(c_color.0);
|
c_color.0 = filter.apply(c_color.0);
|
||||||
|
if c_color.0.as_hsla_f32()[2] < 0.1 {
|
||||||
|
commands.entity(*e2).despawn_recursive();
|
||||||
|
character_list.0.remove(e2);
|
||||||
|
if c_player.is_some() {
|
||||||
|
change_character_event.send(ChangeCharacterEvent);
|
||||||
|
}
|
||||||
|
}
|
||||||
*c_material = materials.add(ColorMaterial::from(c_color.0));
|
*c_material = materials.add(ColorMaterial::from(c_color.0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue