diff --git a/src/bin/flappy/main.rs b/src/bin/flappy/main.rs index 3b89106..c87b642 100644 --- a/src/bin/flappy/main.rs +++ b/src/bin/flappy/main.rs @@ -187,23 +187,13 @@ fn init_obstacles( ) }; let hitbox = { - let material = MeshMaterial2d(materials.add(ColorMaterial { - color: PINK.into(), - ..default() - })); - let mesh = Mesh2d(meshes.add(Rectangle::new(0.1, 10.0))); - - let physics = (RigidBody::Static, Collider::rectangle(1.0, 10.0)); + let physics = (RigidBody::Static, Collider::rectangle(1.0, 10.0), Sensor, CollisionEventsEnabled); let name = Name::new("hitbox"); ( - material.clone(), - mesh.clone(), name.clone(), physics.clone(), - Sensor, Hitbox, - CollisionEventsEnabled, ) }; @@ -273,7 +263,6 @@ fn init_ui(mut commands: Commands) { ..default() }, ).with_children(|parent| { - parent .spawn(( Node { @@ -295,6 +284,18 @@ fn init_ui(mut commands: Commands) { )) .observe(flap_button); }); + + commands.spawn(( + Node { + align_self: AlignSelf::Start, + justify_self: JustifySelf::Center, + ..default() + }, + BackgroundColor(WHITE.into()), + SyncResource::::default(), + Text::default(), + TextLayout::new_with_justify(JustifyText::Center) + )); } fn start_rewind(_trigger: Trigger>, mut next: ResMut>) { @@ -514,6 +515,7 @@ impl Display for Deaths { } } +// TODO: Scoring is bugged, need to make it correct. fn scoring( mut events: EventReader, state: Res>, @@ -528,7 +530,7 @@ fn scoring( match state.get() { PlayerState::Alive => score.0 = score.0.saturating_add(1), PlayerState::Rewind => score.0 = score.0.saturating_sub(1), - _ => panic!("How are you scoring at a time like this??"), + PlayerState::Pause | PlayerState::Stasis => (), } })