From 32fe7580f3587fc6fa90dad636d1ae83b73cc4c0 Mon Sep 17 00:00:00 2001 From: Joshua Coles Date: Wed, 15 Mar 2023 19:21:33 +0000 Subject: [PATCH] Reset example --- src/ui.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/ui.rs b/src/ui.rs index e73bd94..3afb991 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -4,7 +4,6 @@ use bevy::{ prelude::*, sprite::collide_aabb::{collide, Collision}, sprite::MaterialMesh2dBundle, - app::CoreSchedule, }; // Defines the amount of time that should elapse between each physics step. @@ -54,7 +53,7 @@ const SCORE_COLOR: Color = Color::rgb(1.0, 0.5, 0.5); fn main() { App::new() .add_plugins(DefaultPlugins) - .insert_resource(StatusCounter { size: 0, fd: 0.0 }) + .insert_resource(Scoreboard { score: 0 }) .insert_resource(ClearColor(BACKGROUND_COLOR)) .add_startup_system(setup) .add_event::() @@ -172,9 +171,8 @@ impl WallBundle { // This resource tracks the game's score #[derive(Resource)] -struct StatusCounter { - size: usize, - fd: f32, +struct Scoreboard { + score: usize, } // Add the game's entities to our world @@ -350,14 +348,14 @@ fn apply_velocity(mut query: Query<(&mut Transform, &Velocity)>) { } } -fn update_scoreboard(scoreboard: Res, mut query: Query<&mut Text>) { +fn update_scoreboard(scoreboard: Res, mut query: Query<&mut Text>) { let mut text = query.single_mut(); - text.sections[1].value = scoreboard.size.to_string(); + text.sections[1].value = scoreboard.score.to_string(); } fn check_for_collisions( mut commands: Commands, - mut scoreboard: ResMut, + mut scoreboard: ResMut, mut ball_query: Query<(&mut Velocity, &Transform), With>, collider_query: Query<(Entity, &Transform, Option<&Brick>), With>, mut collision_events: EventWriter, @@ -379,7 +377,7 @@ fn check_for_collisions( // Bricks should be despawned and increment the scoreboard on collision if maybe_brick.is_some() { - scoreboard.size += 1; + scoreboard.score += 1; commands.entity(collider_entity).despawn(); }