diff --git a/game/src/combat.rs b/game/src/combat.rs index 6b39729561d5ce11238fd3c4ac2ab30a0175239f..4f0fec517b16bd35cb1422fc11053ca1d2e3fd04 100644 --- a/game/src/combat.rs +++ b/game/src/combat.rs @@ -26,7 +26,7 @@ impl Plugin for CombatPlugin { app.add_systems(OnEnter(CombatState::PTurn), player_attack); app.add_systems(OnExit(CombatState::PTurn), setup_ui); app.add_systems(Update, combat_outcome); - app.add_systems(Update, (text_update_system, text_color_system)); + } } @@ -257,7 +257,24 @@ fn setup_ui( // Display Player's HP for (mut player, _) in &mut player_query { commands.spawn(TextBundle { + transform: Transform { + + translation: Vec3{ + x:250.0, + y:-200.0, + z:4.0, + + + }, + ..default() + }, style: Style { + margin: UiRect { + left: Val::Percent(10.), + right: Val::Percent(90.), + top: Val::Percent(20.), + ..default() + }, position_type: PositionType::Absolute, ..Default::default() }, @@ -283,8 +300,18 @@ fn setup_ui( // Display Enemy's HP for (mut enemy, _) in &mut enemy_query { commands.spawn(TextBundle { + transform: Transform { + + translation: Vec3{ + x:250.0, + y:-200.0, + ..default() + + }, + ..default() + }, style: Style { - position_type: PositionType::Absolute, + ..Default::default() }, text: Text { @@ -322,33 +349,6 @@ struct TextEntities { } -fn text_color_system(time: Res<Time>, mut query: Query<&mut Text, With<ColorText>>) { - for mut text in &mut query { - let seconds = time.elapsed_seconds(); - - // Update the color of the first and only section. - text.sections[0].style.color = Color::Rgba { - red: (1.25 * seconds).sin() / 2.0 + 0.5, - green: (0.75 * seconds).sin() / 2.0 + 0.5, - blue: (0.50 * seconds).sin() / 2.0 + 0.5, - alpha: 1.0, - }; - } -} - -fn text_update_system( - diagnostics: Res<DiagnosticsStore>, - mut query: Query<&mut Text, With<FpsText>>, -) { - for mut text in &mut query { - if let Some(fps) = diagnostics.get(FrameTimeDiagnosticsPlugin::FPS) { - if let Some(value) = fps.smoothed() { - // Update the value of the second section - text.sections[1].value = format!("{value:.2}"); - } - } - } -} fn combat_outcome( mut enemy_query: Query<(Entity, &Transform, &Enemy)>,