summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs43
1 files changed, 20 insertions, 23 deletions
diff --git a/src/main.rs b/src/main.rs
index 1c1d49a..b73c54a 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -5,15 +5,15 @@ use gems::constants;
use rand::{thread_rng, Rng};
use std::time::Duration;
-fn star_spawning_system(mut commands: Commands, time: Res<Time>, mut q: Query<&mut Timer>) {
+fn star_spawning(mut commands: Commands, time: Res<Time>, mut q: Query<&mut Timer>) {
for mut timer in q.iter_mut() {
if !timer.repeating() {
timer.tick(time.delta());
if timer.just_finished() {
timer.set_duration(Duration::new(thread_rng().gen_range(2..5), 0));
timer.reset();
- commands.spawn_bundle((
- SpriteSheetBundle {
+ commands
+ .spawn_bundle(SpriteSheetBundle {
sprite: TextureAtlasSprite::new(constants::TILESHEET_STAR1),
transform: Transform {
translation: Vec3::new(
@@ -25,9 +25,8 @@ fn star_spawning_system(mut commands: Commands, time: Res<Time>, mut q: Query<&m
..Default::default()
},
..Default::default()
- },
- Timer::from_seconds(0.25, true),
- ));
+ })
+ .insert(Timer::from_seconds(0.25, true));
}
}
}
@@ -88,8 +87,8 @@ pub fn setup(
for i in 0..constants::GRID_SIZE {
for j in 0..constants::GRID_SIZE {
- commands.spawn_bundle((
- SpriteSheetBundle {
+ commands
+ .spawn_bundle(SpriteSheetBundle {
texture_atlas: atlas_handle.clone(),
sprite: TextureAtlasSprite::new(constants::TILESHEET_NONE1),
transform: Transform {
@@ -102,14 +101,13 @@ pub fn setup(
..Default::default()
},
..Default::default()
- },
- Cell::new(i, j),
- ));
+ })
+ .insert(Cell::new(i, j));
}
}
}
-fn animation_system(
+fn animation(
mut commands: Commands,
time: Res<Time>,
mut q: Query<(
@@ -151,7 +149,7 @@ fn animation_system(
}
}
-fn cosmonaut_detect_system(
+fn cosmonaut_detect(
mut commands: Commands,
windows: Res<Windows>,
mut q: Query<(&Transform, &TextureAtlasSprite)>,
@@ -173,20 +171,19 @@ fn cosmonaut_detect_system(
> cursor_position.y
&& sprite.index == constants::TILESHEET_COSMONAUT1
{
- commands.spawn_bundle((
- SpriteSheetBundle {
+ commands
+ .spawn_bundle(SpriteSheetBundle {
sprite: TextureAtlasSprite::new(constants::TILESHEET_VISOR1),
transform: *transform,
..Default::default()
- },
- Timer::from_seconds(0.1, true),
- ));
+ })
+ .insert(Timer::from_seconds(0.1, true));
}
}
}
}
-fn mouse_system(
+fn mouse(
windows: Res<Windows>,
mut q: Query<(&mut Cell, &mut Transform, &mut TextureAtlasSprite)>,
mouse_button_input: Res<Input<MouseButton>>,
@@ -269,10 +266,10 @@ impl Plugin for GemsPlugin {
app.add_system(cell::falling.system());
app.add_system(cell::check.system());
app.add_system(cell::start_explosion.system());
- app.add_system(mouse_system.system());
- app.add_system(cosmonaut_detect_system.system());
- app.add_system(animation_system.system());
- app.add_system(star_spawning_system.system());
+ app.add_system(mouse.system());
+ app.add_system(cosmonaut_detect.system());
+ app.add_system(animation.system());
+ app.add_system(star_spawning.system());
}
}