chore(deps): upgrade Bevy 0.13 → 0.18
Three major versions of breaking changes: - Bundles → Required Components (SpriteBundle, NodeBundle, ButtonBundle, TextBundle, Camera2dBundle removed; spawn tuples of components instead) - Style merged into Node; TextStyle split into TextFont + TextColor - Color API: rgb/rgba → srgb/srgba; Color::Rgba pattern matching replaced with .alpha()/.set_alpha(); .r()/.g()/.b() → .to_srgba().red/green/blue - Time: delta_seconds() → delta_secs(); elapsed_seconds() → elapsed_secs() - Query: get_single()/get_single_mut() → single()/single_mut() (now Result) - Timer::finished() → Timer::is_finished() - despawn_recursive() removed (despawn() is now recursive); despawn_descendants() removed — replaced with Children query iteration - BorderColor(c) → BorderColor::all(c) - WindowResolution: From<(f32,f32)> removed → cast to (u32,u32) - flake.nix: added wayland to runtime libs (default-on in 0.18) Tests pass (8/8), clippy clean, headless render verified showing start menu, button, starfield, and player ship. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
7a4305677b
commit
b2b564f690
11 changed files with 2746 additions and 1028 deletions
|
|
@ -16,39 +16,35 @@ pub enum AppState {
|
|||
pub fn setup_game_over_ui(mut commands: Commands) {
|
||||
println!("Entering GameOver state. Setting up UI.");
|
||||
commands.spawn((
|
||||
TextBundle::from_section(
|
||||
"GAME OVER",
|
||||
TextStyle {
|
||||
font_size: 100.0,
|
||||
color: Color::WHITE,
|
||||
..default()
|
||||
},
|
||||
)
|
||||
.with_style(Style {
|
||||
Text::new("GAME OVER"),
|
||||
TextFont {
|
||||
font_size: 100.0,
|
||||
..default()
|
||||
},
|
||||
TextColor(Color::WHITE),
|
||||
Node {
|
||||
position_type: PositionType::Absolute,
|
||||
align_self: AlignSelf::Center,
|
||||
justify_self: JustifySelf::Center,
|
||||
top: Val::Percent(40.0),
|
||||
..default()
|
||||
}),
|
||||
},
|
||||
GameOverUI,
|
||||
));
|
||||
commands.spawn((
|
||||
TextBundle::from_section(
|
||||
"Press R to Restart",
|
||||
TextStyle {
|
||||
font_size: 32.0,
|
||||
color: Color::WHITE,
|
||||
..default()
|
||||
},
|
||||
)
|
||||
.with_style(Style {
|
||||
Text::new("Press R to Restart"),
|
||||
TextFont {
|
||||
font_size: 32.0,
|
||||
..default()
|
||||
},
|
||||
TextColor(Color::WHITE),
|
||||
Node {
|
||||
position_type: PositionType::Absolute,
|
||||
align_self: AlignSelf::Center,
|
||||
justify_self: JustifySelf::Center,
|
||||
top: Val::Percent(55.0),
|
||||
..default()
|
||||
}),
|
||||
},
|
||||
RestartMessage,
|
||||
));
|
||||
}
|
||||
|
|
@ -60,10 +56,10 @@ pub fn cleanup_game_over_ui(
|
|||
) {
|
||||
println!("Exiting GameOver state. Cleaning up UI.");
|
||||
for entity in query.iter() {
|
||||
commands.entity(entity).despawn_recursive();
|
||||
commands.entity(entity).despawn();
|
||||
}
|
||||
for entity in restart_query.iter() {
|
||||
commands.entity(entity).despawn_recursive();
|
||||
commands.entity(entity).despawn();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -76,8 +72,6 @@ pub fn cleanup_game_entities(
|
|||
enemy_bullet_query: Query<Entity, With<crate::components::EnemyBullet>>,
|
||||
enemy_query: Query<Entity, With<Enemy>>,
|
||||
restart_message_query: Query<Entity, With<crate::components::RestartMessage>>,
|
||||
// Optionally despawn player too, or handle separately if needed for restart
|
||||
// player_query: Query<Entity, With<Player>>,
|
||||
) {
|
||||
println!("Exiting Playing state. Cleaning up game entities.");
|
||||
for entity in bullet_query.iter() {
|
||||
|
|
@ -92,9 +86,6 @@ pub fn cleanup_game_entities(
|
|||
for entity in restart_message_query.iter() {
|
||||
commands.entity(entity).despawn();
|
||||
}
|
||||
// for entity in player_query.iter() {
|
||||
// commands.entity(entity).despawn();
|
||||
// }
|
||||
}
|
||||
|
||||
// --- Start Menu UI ---
|
||||
|
|
@ -102,65 +93,57 @@ pub fn cleanup_game_entities(
|
|||
pub fn setup_start_menu_ui(mut commands: Commands) {
|
||||
println!("Entering StartMenu state. Setting up UI.");
|
||||
|
||||
// Root UI container
|
||||
commands
|
||||
.spawn((
|
||||
NodeBundle {
|
||||
style: Style {
|
||||
width: Val::Percent(100.0),
|
||||
height: Val::Percent(100.0),
|
||||
align_items: AlignItems::Center,
|
||||
justify_content: JustifyContent::Center,
|
||||
flex_direction: FlexDirection::Column,
|
||||
..default()
|
||||
},
|
||||
Node {
|
||||
width: Val::Percent(100.0),
|
||||
height: Val::Percent(100.0),
|
||||
align_items: AlignItems::Center,
|
||||
justify_content: JustifyContent::Center,
|
||||
flex_direction: FlexDirection::Column,
|
||||
..default()
|
||||
},
|
||||
StartMenuUI,
|
||||
))
|
||||
.with_children(|parent| {
|
||||
// Title
|
||||
parent.spawn(
|
||||
TextBundle::from_section(
|
||||
"BGLGA",
|
||||
TextStyle {
|
||||
font_size: 120.0,
|
||||
color: Color::WHITE,
|
||||
..default()
|
||||
},
|
||||
)
|
||||
.with_style(Style {
|
||||
parent.spawn((
|
||||
Text::new("BGLGA"),
|
||||
TextFont {
|
||||
font_size: 120.0,
|
||||
..default()
|
||||
},
|
||||
TextColor(Color::WHITE),
|
||||
Node {
|
||||
margin: UiRect::bottom(Val::Px(50.0)),
|
||||
..default()
|
||||
}),
|
||||
);
|
||||
},
|
||||
));
|
||||
|
||||
// Start Game Button
|
||||
parent
|
||||
.spawn((
|
||||
ButtonBundle {
|
||||
style: Style {
|
||||
width: Val::Px(250.0),
|
||||
height: Val::Px(80.0),
|
||||
border: UiRect::all(Val::Px(2.0)),
|
||||
justify_content: JustifyContent::Center,
|
||||
align_items: AlignItems::Center,
|
||||
..default()
|
||||
},
|
||||
border_color: BorderColor(Color::WHITE),
|
||||
background_color: BackgroundColor(Color::rgb(0.1, 0.1, 0.5)),
|
||||
Button,
|
||||
Node {
|
||||
width: Val::Px(250.0),
|
||||
height: Val::Px(80.0),
|
||||
border: UiRect::all(Val::Px(2.0)),
|
||||
justify_content: JustifyContent::Center,
|
||||
align_items: AlignItems::Center,
|
||||
..default()
|
||||
},
|
||||
BorderColor::all(Color::WHITE),
|
||||
BackgroundColor(Color::srgb(0.1, 0.1, 0.5)),
|
||||
StartButton,
|
||||
))
|
||||
.with_children(|parent| {
|
||||
parent.spawn(TextBundle::from_section(
|
||||
"Start Game",
|
||||
TextStyle {
|
||||
parent.spawn((
|
||||
Text::new("Start Game"),
|
||||
TextFont {
|
||||
font_size: 40.0,
|
||||
color: Color::WHITE,
|
||||
..default()
|
||||
},
|
||||
TextColor(Color::WHITE),
|
||||
));
|
||||
});
|
||||
});
|
||||
|
|
@ -169,7 +152,7 @@ pub fn setup_start_menu_ui(mut commands: Commands) {
|
|||
pub fn cleanup_start_menu_ui(mut commands: Commands, query: Query<Entity, With<StartMenuUI>>) {
|
||||
println!("Exiting StartMenu state. Cleaning up UI.");
|
||||
for entity in query.iter() {
|
||||
commands.entity(entity).despawn_recursive();
|
||||
commands.entity(entity).despawn();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -187,10 +170,10 @@ pub fn start_menu_button_system(
|
|||
app_state.set(AppState::Playing);
|
||||
}
|
||||
Interaction::Hovered => {
|
||||
color.0 = Color::rgb(0.2, 0.2, 0.7);
|
||||
color.0 = Color::srgb(0.2, 0.2, 0.7);
|
||||
}
|
||||
Interaction::None => {
|
||||
color.0 = Color::rgb(0.1, 0.1, 0.5);
|
||||
color.0 = Color::srgb(0.1, 0.1, 0.5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue