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
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 {
fn build(&self, app: &mut App) {
info!("Building rps Plugin");
let timer = Greeter {
timer: Timer::from_seconds(2.0, TimerMode::Repeating),
};
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 {
width: Val::Px(150.0),
height: Val::Px(65.0),
align_items: AlignItems::Center,
..default()
},
background_color: BackgroundColor::from(Color::rgb(1.0, 0.0, 0.0)),

Loading…
Cancel
Save