summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs50
1 files changed, 28 insertions, 22 deletions
diff --git a/src/main.rs b/src/main.rs
index 0c7f92e..e958c16 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,6 +1,5 @@
use bevy::math::Vec3;
use bevy::prelude::*;
-use bevy::render::texture::ImageSettings;
use gems::cell::{self, AnimationTimer, Cell, Occupant};
use gems::constants;
use rand::{thread_rng, Rng};
@@ -18,7 +17,7 @@ fn star_spawning(
timer.set_duration(Duration::new(thread_rng().gen_range(2..5), 0));
timer.reset();
commands
- .spawn_bundle(SpriteSheetBundle {
+ .spawn(SpriteSheetBundle {
sprite: TextureAtlasSprite::new(constants::TILESHEET_STAR1),
texture_atlas: texture_atlas_handle.clone(),
transform: Transform {
@@ -32,7 +31,7 @@ fn star_spawning(
},
..Default::default()
})
- .insert(AnimationTimer::from_seconds(0.15, true));
+ .insert(AnimationTimer::from_seconds(0.15, TimerMode::Once));
}
}
}
@@ -52,11 +51,13 @@ pub fn setup(
Vec2::new(constants::TILE_SIZE, constants::TILE_SIZE),
5,
5,
+ None,
+ None,
);
let atlas_handle = texture_atlases.add(atlas);
- commands.spawn_bundle(Camera2dBundle::default());
- commands.spawn_bundle(SpriteBundle {
+ commands.spawn(Camera2dBundle::default());
+ commands.spawn(SpriteBundle {
texture: background,
transform: Transform {
translation: Vec3::new(50.0, 0.0, 0.0),
@@ -65,7 +66,7 @@ pub fn setup(
},
..Default::default()
});
- commands.spawn_bundle(SpriteBundle {
+ commands.spawn(SpriteBundle {
texture: title,
transform: Transform {
translation: Vec3::new(240.0, 200.0, 0.2),
@@ -74,7 +75,7 @@ pub fn setup(
},
..Default::default()
});
- commands.spawn_bundle(SpriteSheetBundle {
+ commands.spawn(SpriteSheetBundle {
sprite: TextureAtlasSprite::new(constants::TILESHEET_COSMONAUT1),
texture_atlas: atlas_handle.clone(),
transform: Transform {
@@ -84,11 +85,11 @@ pub fn setup(
},
..Default::default()
});
- commands.spawn_bundle((
- AnimationTimer::from_seconds(1.0, false),
+ commands.spawn((
+ AnimationTimer::from_seconds(1.0, TimerMode::Once),
atlas_handle.clone(),
));
- commands.spawn_bundle(SpriteSheetBundle {
+ commands.spawn(SpriteSheetBundle {
sprite: TextureAtlasSprite::new(constants::TILESHEET_COSMONAUT2),
texture_atlas: atlas_handle.clone(),
transform: Transform {
@@ -106,7 +107,7 @@ pub fn setup(
for i in 0..constants::GRID_SIZE {
for j in 0..constants::GRID_SIZE {
commands
- .spawn_bundle(SpriteSheetBundle {
+ .spawn(SpriteSheetBundle {
texture_atlas: atlas_handle.clone(),
visibility: Visibility { is_visible: false },
transform: Transform {
@@ -190,13 +191,13 @@ fn cosmonaut_detect(
&& sprite.index == constants::TILESHEET_COSMONAUT1
{
commands
- .spawn_bundle(SpriteSheetBundle {
+ .spawn(SpriteSheetBundle {
sprite: TextureAtlasSprite::new(constants::TILESHEET_VISOR1),
texture_atlas: texture_atlas_handle.clone(),
transform: *transform,
..Default::default()
})
- .insert(AnimationTimer::from_seconds(0.1, true));
+ .insert(AnimationTimer::from_seconds(0.1, TimerMode::Repeating));
}
}
}
@@ -279,15 +280,20 @@ fn mouse(
pub fn main() {
App::new()
- .insert_resource(ImageSettings::default_nearest())
- .insert_resource(WindowDescriptor {
- title: "gems".to_string(),
- width: constants::WINDOW_WIDTH,
- height: constants::WINDOW_HEIGHT,
- resizable: false,
- ..Default::default()
- })
- .add_plugins(DefaultPlugins)
+ .add_plugins(
+ DefaultPlugins
+ .set(ImagePlugin::default_nearest())
+ .set(WindowPlugin {
+ window: WindowDescriptor {
+ title: "gems".to_string(),
+ width: constants::WINDOW_WIDTH,
+ height: constants::WINDOW_HEIGHT,
+ resizable: false,
+ ..default()
+ },
+ ..default()
+ }),
+ )
.add_startup_system(setup)
.add_system(cell::insert)
.add_system(cell::falling)