get rid of old learning code

main
Jordan Orelli 1 year ago
parent 0a3916c7a4
commit 543e4765e9

@ -6,47 +6,10 @@ use crate::start_menu::StartMenu;
/// The top-level structure of our game, which is a bevy plugin /// The top-level structure of our game, which is a bevy plugin
pub struct Game {} pub struct Game {}
#[derive(Component)]
struct Person;
#[derive(Component)]
struct Name(String);
#[derive(Resource)]
struct Greeter {
timer: Timer,
}
fn register_people(mut commands: Commands) {
commands.spawn((Person, Name(String::from("Alice"))));
commands.spawn((Person, Name(String::from("Bob"))));
commands.spawn((Person, Name(String::from("Carol"))));
}
fn greet(time: Res<Time>, mut timer: ResMut<Greeter>, query: Query<&Name, With<Person>>) {
timer.timer.tick(time.delta());
if timer.timer.just_finished() {
for name in &query {
info!(
"Hello, {name}! elapsed: {elapsed:.2?} delta: {delta:.2?}",
name = name.0,
elapsed = time.elapsed(),
delta = time.delta(),
);
}
}
}
impl Plugin for Game { impl Plugin for Game {
fn build(&self, app: &mut App) { fn build(&self, app: &mut App) {
info!("Building rps Plugin"); info!("Building rps Plugin");
let timer = Greeter {
timer: Timer::from_seconds(2.0, TimerMode::Repeating),
};
app.add_plugins(StartMenu {}); app.add_plugins(StartMenu {});
app.insert_resource(timer)
.add_systems(Startup, register_people)
.add_systems(Update, greet);
} }
} }

@ -18,7 +18,6 @@ fn quit_button() -> ButtonBundle {
style: Style { style: Style {
width: Val::Px(150.0), width: Val::Px(150.0),
height: Val::Px(65.0), height: Val::Px(65.0),
align_items: AlignItems::Center,
..default() ..default()
}, },
background_color: BackgroundColor::from(Color::rgb(1.0, 0.0, 0.0)), background_color: BackgroundColor::from(Color::rgb(1.0, 0.0, 0.0)),

Loading…
Cancel
Save