Skip to content

Commit

Permalink
Add text and remove text in main menu
Browse files Browse the repository at this point in the history
  • Loading branch information
PurityLake committed Dec 11, 2023
1 parent 65bdb08 commit 6167de2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
Empty file removed assets/.gitkeep
Empty file.
Binary file added assets/fonts/plop.ttf
Binary file not shown.
21 changes: 21 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ fn main() {
Update,
(main_menu_input).run_if(in_state(GameState::MainMenu)),
)
.add_systems(OnExit(GameState::MainMenu), remove_text)
.add_systems(
Update,
transition_to_gameplay.run_if(in_state(GameState::TransitionToGamePlay)),
Expand All @@ -80,11 +81,31 @@ fn main() {
.run();
}

fn remove_text(mut commands: Commands, query: Query<Entity, With<Text>>) {
for entity in query.iter() {
commands.entity(entity).despawn_recursive();
}
}

fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
commands.spawn(Camera2dBundle {
transform: Transform::from_translation(Vec3::new(-500.0, 0.0, 100.0)),
..default()
});

commands.spawn(Text2dBundle {
text: Text::from_section(
"Hold The Line",
TextStyle {
font: asset_server.load("fonts/plop.ttf"),
font_size: 99.0,
color: Color::rgb(1.0, 1.0, 0.0),
},
)
.with_alignment(TextAlignment::Center),
transform: Transform::from_translation(Vec3::new(-500.0, 200.0, 0.0)),
..default()
});
commands.spawn(SpriteBundle {
texture: asset_server.load("sprites/map/map.png"),
transform: Transform::from_scale(Vec3::new(1.25, 1.25, 1.0))
Expand Down

0 comments on commit 6167de2

Please sign in to comment.