diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cell.rs | 5 | ||||
-rw-r--r-- | src/constants.rs | 45 | ||||
-rw-r--r-- | src/main.rs | 14 |
3 files changed, 41 insertions, 23 deletions
diff --git a/src/cell.rs b/src/cell.rs index b697076..10c11f0 100644 --- a/src/cell.rs +++ b/src/cell.rs @@ -12,6 +12,7 @@ pub enum Occupant { Yellow, Red, Blue, + Purple, Explosion, } @@ -28,6 +29,7 @@ impl Occupant { Occupant::Yellow => constants::TILESHEET_YELLOW, Occupant::Red => constants::TILESHEET_RED, Occupant::Blue => constants::TILESHEET_BLUE, + Occupant::Purple => constants::TILESHEET_PURPLE, Occupant::Explosion => constants::TILESHEET_EXPLOSION1, Occupant::None => constants::TILESHEET_NONE1, } @@ -36,11 +38,12 @@ impl Occupant { impl Distribution<Occupant> for Standard { fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Occupant { - match rng.gen_range(0..=3) { + match rng.gen_range(0..=4) { 0 => Occupant::Green, 1 => Occupant::Yellow, 2 => Occupant::Blue, 3 => Occupant::Red, + 4 => Occupant::Purple, _ => Occupant::None, } } diff --git a/src/constants.rs b/src/constants.rs index d8effa8..7eed139 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -4,27 +4,32 @@ pub const WINDOW_HEIGHT: f32 = 600.0; pub const WINDOW_WIDTH: f32 = 800.0; pub const GRID_SIZE: usize = 8; -pub const TILESHEET_GREEN: u32 = 0; -pub const TILESHEET_YELLOW: u32 = 1; -pub const TILESHEET_BLUE: u32 = 2; -pub const TILESHEET_RED: u32 = 3; +pub const TILESHEET_EXPLOSION1: u32 = 0; +pub const TILESHEET_EXPLOSION2: u32 = 1; +pub const TILESHEET_EXPLOSION3: u32 = 2; +pub const TILESHEET_EXPLOSION4: u32 = 3; +pub const TILESHEET_EXPLOSION5: u32 = 4; -pub const TILESHEET_EXPLOSION1: u32 = 4; -pub const TILESHEET_EXPLOSION2: u32 = 5; -pub const TILESHEET_EXPLOSION3: u32 = 6; -pub const TILESHEET_EXPLOSION4: u32 = 7; +pub const TILESHEET_GREEN: u32 = 5; +pub const TILESHEET_YELLOW: u32 = 6; +pub const TILESHEET_BLUE: u32 = 7; +pub const TILESHEET_RED: u32 = 8; +pub const TILESHEET_PURPLE: u32 = 9; -pub const TILESHEET_COSMONAUT1: u32 = 8; -pub const TILESHEET_VISOR1: u32 = 9; -pub const TILESHEET_VISOR2: u32 = 10; -pub const TILESHEET_NONE1: u32 = 11; +pub const TILESHEET_STAR1: u32 = 10; +pub const TILESHEET_STAR2: u32 = 11; +pub const TILESHEET_STAR3: u32 = 12; +pub const TILESHEET_NONE1: u32 = 13; +pub const TILESHEET_NONE2: u32 = 14; -pub const TILESHEET_COSMONAUT2: u32 = 12; -pub const TILESHEET_VISOR3: u32 = 13; -pub const TILESHEET_VISOR4: u32 = 14; -pub const TILESHEET_NONE2: u32 = 15; +pub const TILESHEET_COSMONAUT1: u32 = 15; +pub const TILESHEET_VISOR1: u32 = 16; +pub const TILESHEET_VISOR2: u32 = 17; +pub const TILESHEET_NONE3: u32 = 18; +pub const TILESHEET_NONE4: u32 = 19; -pub const TILESHEET_STAR1: u32 = 16; -pub const TILESHEET_STAR2: u32 = 17; -pub const TILESHEET_STAR3: u32 = 18; -pub const TILESHEET_NONE3: u32 = 19; +pub const TILESHEET_COSMONAUT2: u32 = 20; +pub const TILESHEET_VISOR3: u32 = 21; +pub const TILESHEET_VISOR4: u32 = 22; +pub const TILESHEET_NONE6: u32 = 23; +pub const TILESHEET_NONE7: u32 = 24; diff --git a/src/main.rs b/src/main.rs index b73c54a..8a59000 100644 --- a/src/main.rs +++ b/src/main.rs @@ -40,11 +40,12 @@ pub fn setup( ) { let background = asset_server.load("background.png"); let tileset = asset_server.load("tileset.png"); + let title = asset_server.load("title.png"); let atlas = TextureAtlas::from_grid( tileset, Vec2::new(constants::TILE_SIZE, constants::TILE_SIZE), - 4, + 5, 5, ); let atlas_handle = texture_atlases.add(atlas); @@ -59,6 +60,15 @@ pub fn setup( }, ..Default::default() }); + commands.spawn_bundle(SpriteBundle { + material: materials.add(title.into()), + transform: Transform { + translation: Vec3::new(240.0, 200.0, 0.0), + scale: Vec3::splat(2.0), + ..Default::default() + }, + ..Default::default() + }); commands.spawn_bundle(SpriteSheetBundle { sprite: TextureAtlasSprite::new(constants::TILESHEET_COSMONAUT1), texture_atlas: atlas_handle.clone(), @@ -93,7 +103,7 @@ pub fn setup( sprite: TextureAtlasSprite::new(constants::TILESHEET_NONE1), transform: Transform { translation: Vec3::new( - ((i as f32) * constants::TILE_SIZE * constants::TILE_SCALE) - 320.0, + ((i as f32) * constants::TILE_SIZE * constants::TILE_SCALE) - 330.0, ((j as f32) * constants::TILE_SIZE * constants::TILE_SCALE) - 160.0, 1.0, ), |