diff --git a/src/core/elements/flappy_jellyfish.rs b/src/core/elements/flappy_jellyfish.rs index b5cfaa8f58..06c210bcb2 100644 --- a/src/core/elements/flappy_jellyfish.rs +++ b/src/core/elements/flappy_jellyfish.rs @@ -43,7 +43,7 @@ impl AssetGetFlappyJellyfishMeta for SchemaBox { pub fn session_plugin(session: &mut Session) { session .stages - .add_system_to_stage(CoreStage::PostUpdate, move_flappy_jellyfish) + .add_system_to_stage(CoreStage::PostUpdate, control_flappy_jellyfish) .add_system_to_stage(CoreStage::PostUpdate, explode_flappy_jellyfish); } @@ -53,6 +53,8 @@ pub struct FlappyJellyfish { pub jellyfish: Entity, } +/// A player with a jellyfish is holding shoot. Take control of the flappy if +/// one exists or spawn one. pub fn spawn_or_take_control( owner: Entity, jellyfish_ent: Entity, @@ -78,6 +80,7 @@ pub fn spawn_or_take_control( .system() } +/// Take control of the flappy associated with a jellyfish for a player. fn take_control(owner: Entity, flappy_ent: Entity) -> StaticSystem<(), ()> { (move |mut player_driving: CompMut| { player_driving.insert(owner, PlayerDrivingJellyfish { flappy: flappy_ent }); @@ -85,6 +88,7 @@ fn take_control(owner: Entity, flappy_ent: Entity) -> StaticSystem<(), ()> { .system() } +/// Spawn a flappy jellyfish. fn spawn(owner: Entity, jellyfish_ent: Entity) -> StaticSystem<(), ()> { (move |mut entities: ResMut, element_handles: Comp, @@ -153,6 +157,53 @@ fn spawn(owner: Entity, jellyfish_ent: Entity) -> StaticSystem<(), ()> { .system() } +const SPEED_X: f32 = 324.0; +const SPEED_JUMP: f32 = 3.5; +const GRAVITY: f32 = 0.1; +const MIN_SPEED: Vec2 = vec2(-SPEED_X, -4.0); +const MAX_SPEED: Vec2 = vec2(SPEED_X, 4.0); + +fn control_flappy_jellyfish( + time: Res