diff --git a/src/main.rs b/src/main.rs index 1752751..62c8d6d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -65,6 +65,8 @@ fn main() { .insert_resource(Sky::default()) .add_systems(Startup, star_setup) .add_systems(Startup, cons_setup) + .add_systems(Startup, ui_setup) + //.add_systems(Update, button_interaction) .add_systems(Update, player_rotate) .run(); } @@ -201,7 +203,7 @@ fn player_rotate( keys: Res>, mut query: Query<(&mut Player, &mut Transform)>, // Query to get Player and Transform sky: Res, // Res to access the Sky resource - mut commands: Commands, + //mut commands: Commands, ) { for (mut player, mut transform) in query.iter_mut() { // If the space key was just pressed @@ -226,8 +228,6 @@ fn player_rotate( // Slerp between the current rotation and the target rotation transform.rotation = current_rotation.slerp(target_rotation, 0.1); // 0.1 is the interpolation factor - info!("rotating player"); - // Optionally, you could clear the target rotation when close enough if transform.rotation.angle_between(target_rotation) < 0.01 { player.target_rotation = None; // Clear once the rotation is close enough @@ -235,3 +235,52 @@ fn player_rotate( } } } + +fn ui_setup( + mut commands: Commands, + //asset_server: Res, + //mut materials: ResMut> +) { + let text = "Hello world!"; + + commands.spawn( + TextBundle::from_section( + text, + TextStyle { + font_size: 100.0, + color: Color::WHITE, + ..default() + }, + ) // Set the alignment of the Text + .with_text_justify(JustifyText::Center) + // Set the style of the TextBundle itself. + .with_style(Style { + position_type: PositionType::Absolute, + bottom: Val::Px(5.0), + right: Val::Px(5.0), + ..default() + }) + ); +} + +// System to handle button interaction +// fn button_interaction( +// mut interaction_query: Query<(&Interaction, &mut BackgroundColor), (Changed, With