diff --git a/README.md b/README.md index 327f5f2..5785560 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ [Play in browser](https://txmn.tk/projects/lux-synthese/) +In latin, _lux synthesĕ_ means "light by the means of synthesia". + ## Controls * **Move**: arrows @@ -14,12 +16,10 @@ ## TODO * more filters -* despawn black characters -* despawn character when too far * more levels * (?) multiplayer * 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 ## Build @@ -54,6 +54,8 @@ Skip to level `N: u32` with the command `bevyjam `. Edit the level `N: u32` with the command `bevyjam e`. +Editor is not available in the WASM build. + ### Editor controls * **Select**: left click to select, click in void to deselect, CTRL+click to select many, CTRL+A to select all diff --git a/src/game.rs b/src/game.rs index 204858f..3194ff2 100644 --- a/src/game.rs +++ b/src/game.rs @@ -398,6 +398,8 @@ fn collision_event_system( )>, pass_through_filter_query: Query<&PassThroughFilter>, melty_query: Query<&Melty>, + mut character_list: ResMut, + mut change_character_event: EventWriter, ) { for collision_event in collision_events.iter() { if let CollisionEvent::Started(e1, e2, flags) = collision_event { @@ -416,20 +418,34 @@ fn collision_event_system( } } } 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), pass_through_filter_query.get(*e2), ) { 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)); } 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), ) = ( character_query.get_mut(*e2), pass_through_filter_query.get(*e1), ) { 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)); } }