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/assets/game.levels.json b/assets/game.levels.json index ee4dc60..9751f71 100644 --- a/assets/game.levels.json +++ b/assets/game.levels.json @@ -306,7 +306,7 @@ ] }, { - "comment": "Melting platform tutorial", + "comment": "Melty platform tutorial", "characters": [ { "pos": [ @@ -384,6 +384,389 @@ }, { "comment": "First puzzle", + "characters": [ + { + "pos": [ + -96.0, + 472.0 + ], + "color": [ + 1.0, + 0.0, + 0.0, + 1.0 + ] + }, + { + "pos": [ + -264.0, + 472.0 + ], + "color": [ + 0.0, + 1.0, + 0.0, + 1.0 + ] + }, + { + "pos": [ + 648.0, + 600.0 + ], + "color": [ + 1.0, + 0.0, + 0.7, + 1.0 + ] + }, + { + "pos": [ + 648.0, + -8.0 + ], + "color": [ + 0.0, + 1.0, + 0.3, + 1.0 + ] + } + ], + "platforms": [ + { + "pos": [ + -168.0, + 424.0 + ], + "size": [ + 464.0, + 16.0 + ] + }, + { + "pos": [ + 432.0, + 424.0 + ], + "size": [ + 352.0, + 16.0 + ] + }, + { + "pos": [ + 156.0, + 152.0 + ], + "size": [ + 312.0, + 16.0 + ] + }, + { + "pos": [ + 352.0, + -208.0 + ], + "size": [ + 176.0, + 16.0 + ] + }, + { + "pos": [ + 484.0, + -56.0 + ], + "size": [ + 104.0, + 16.0 + ] + }, + { + "pos": [ + 360.0, + 64.0 + ], + "size": [ + 96.0, + 16.0 + ] + }, + { + "pos": [ + 64.0, + -272.0 + ], + "size": [ + 320.0, + 16.0 + ] + }, + { + "pos": [ + 600.0, + 716.0 + ], + "size": [ + 16.0, + 312.0 + ] + }, + { + "pos": [ + 696.0, + 412.0 + ], + "size": [ + 16.0, + 920.0 + ] + }, + { + "pos": [ + 600.0, + 232.0 + ], + "size": [ + 16.0, + 368.0 + ] + }, + { + "pos": [ + 600.0, + -8.0 + ], + "size": [ + 16.0, + 80.0 + ] + }, + { + "pos": [ + 576.0, + 56.0 + ], + "size": [ + 32.0, + 16.0 + ] + }, + { + "pos": [ + 564.0, + 40.0 + ], + "size": [ + 8.0, + 16.0 + ] + } + ], + "absorbing_filters": [ + { + "pos": [ + 56.0, + 492.0 + ], + "size": [ + 16.0, + 120.0 + ], + "color": [ + 1.0, + 0.0, + 0.0, + 1.0 + ] + }, + { + "pos": [ + 56.0, + 628.0 + ], + "size": [ + 16.0, + 152.0 + ], + "color": [ + 0.0, + 1.0, + 0.0, + 1.0 + ] + }, + { + "pos": [ + 264.0, + 492.0 + ], + "size": [ + 16.0, + 120.0 + ], + "color": [ + 0.0, + 1.0, + 0.0, + 1.0 + ] + }, + { + "pos": [ + 264.0, + 628.0 + ], + "size": [ + 16.0, + 152.0 + ], + "color": [ + 1.0, + 0.0, + 0.0, + 1.0 + ] + }, + { + "pos": [ + -48.0, + 152.0 + ], + "size": [ + 96.0, + 16.0 + ], + "color": [ + 0.0, + 0.0, + 1.0, + 1.0 + ] + }, + { + "pos": [ + 600.0, + 488.0 + ], + "size": [ + 16.0, + 112.0 + ], + "color": [ + 0.0, + 1.0, + 1.0, + 1.0 + ] + }, + { + "pos": [ + 524.0, + 556.0 + ], + "size": [ + 56.0, + 8.0 + ], + "color": [ + 0.0, + 1.0, + 1.0, + 1.0 + ] + } + ], + "rotating_filters": [ + { + "pos": [ + -48.0, + 40.0 + ], + "angle": -120.0 + } + ], + "melty_platforms": [ + { + "pos": [ + 112.0, + 424.0 + ], + "color": [ + 1.0, + 0.0, + 0.0, + 1.0 + ] + }, + { + "pos": [ + 208.0, + 424.0 + ], + "color": [ + 1.0, + 0.0, + 0.0, + 1.0 + ] + }, + { + "pos": [ + 208.0, + 288.0 + ], + "color": [ + 1.0, + 0.0, + 0.0, + 1.0 + ] + }, + { + "pos": [ + 600.0, + 552.0 + ], + "color": [ + 0.0, + 1.0, + 1.0, + 1.0 + ] + }, + { + "pos": [ + 616.0, + 40.0 + ], + "color": [ + 1.0, + 0.0, + 0.0, + 1.0 + ] + }, + { + "pos": [ + 584.0, + -56.0 + ], + "color": [ + 1.0, + 0.0, + 0.0, + 1.0 + ] + } + ], + "texts": [] + }, + { + "comment": "Second puzzle", "characters": [ { "pos": [ 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)); } }