diff --git a/src/entities/aliens.rs b/src/entities/aliens.rs new file mode 100644 index 0000000000000000000000000000000000000000..bfa64789d684c1e6bc05ac4cdc930dac7365c017 --- /dev/null +++ b/src/entities/aliens.rs @@ -0,0 +1,8 @@ +use crate::entities::EntitySpawner; +use crate::system::window_bounds; +use bevy::math::Vec2; + +pub fn spawn_static_aliens(mut spawner: EntitySpawner) { + let bounds = window_bounds(); + spawner.spawn_alien_at(Vec2::new(bounds.max.x - 150.0, bounds.half_size().y)); +} diff --git a/src/entities/mod.rs b/src/entities/mod.rs index e6d173921e26700ed01befc619bb864447db4354..f604191ddf9abad6a95d780d9c365f8cdd772374 100644 --- a/src/entities/mod.rs +++ b/src/entities/mod.rs @@ -1,3 +1,4 @@ +mod aliens; mod collision; mod motion; mod player; @@ -10,11 +11,14 @@ mod _plugin { pub struct EntityPlugin; impl Plugin for EntityPlugin { fn build(&self, app: &mut App) { - app.add_startup_system(super::player::spawn_player) - .add_systems(( - super::player::process_player_input, - super::motion::apply_velocity, - )); + app.add_startup_systems(( + super::player::spawn_player, + super::aliens::spawn_static_aliens, + )) + .add_systems(( + super::player::process_player_input, + super::motion::apply_velocity, + )); } } } diff --git a/src/entities/spawning.rs b/src/entities/spawning.rs index 92174c666386293d2c8fdb72d4481e063c7e50ae..7dc9980ada4b6f5bb974a4169636579441832668 100644 --- a/src/entities/spawning.rs +++ b/src/entities/spawning.rs @@ -1,8 +1,8 @@ use crate::entities::motion::Velocity; -use crate::entities::{BoxSize, Player}; +use crate::entities::{BoxSize, CollisionGroup, Player}; use crate::system::{Background, BACKGROUND_HEIGHT, BACKGROUND_WIDTH}; use bevy::ecs::system::SystemParam; -use bevy::prelude::{AssetServer, Commands, Entity, Res, SpriteBundle, Transform, Vec2}; +use bevy::prelude::{AssetServer, Commands, Entity, Res, Sprite, SpriteBundle, Transform, Vec2}; static Z_PLAYER: f32 = 300.0; static Z_ITEMS: f32 = 200.0; @@ -44,4 +44,22 @@ impl<'w, 's> EntitySpawner<'w, 's> { )) .id() } + + pub fn spawn_alien_at(&mut self, position: Vec2) -> Entity { + self.commands + .spawn(( + SpriteBundle { + texture: self.assets.load("sprites/alien_ship.png"), + transform: Transform::from_translation(position.extend(Z_ENEMY)), + sprite: Sprite { + flip_x: true, + ..Default::default() + }, + ..Default::default() + }, + BoxSize::from(Vec2::new(50.0, 25.0)), + CollisionGroup::Enemy, + )) + .id() + } } diff --git a/src/system/colours.rs b/src/system/colours.rs new file mode 100644 index 0000000000000000000000000000000000000000..36551b7820628b1fbc0dd97203661ca7391a1fa7 --- /dev/null +++ b/src/system/colours.rs @@ -0,0 +1,37 @@ +use bevy::prelude::Color; + +pub struct DawnBringerPalette; +impl DawnBringerPalette { + /// <div style="background-color:rgb(20, 12, 28); width: 10px; padding: 10px; border: 1px solid;"></div> + pub const MURKY_BLACK: Color = Color::rgb(0.078, 0.047, 0.110); + /// <div style="background-color:rgb(68, 36, 52); width: 10px; padding: 10px; border: 1px solid;"></div> + pub const DARK_PURPLE: Color = Color::rgb(0.267, 0.141, 0.204); + /// <div style="background-color:rgb(48, 52, 109); width: 10px; padding: 10px; border: 1px solid;"></div> + pub const MIDNIGHT_BLUE: Color = Color::rgb(0.188, 0.204, 0.427); + /// <div style="background-color:rgb(78, 74, 78); width: 10px; padding: 10px; border: 1px solid;"></div> + pub const DARK_GREY: Color = Color::rgb(0.306, 0.290, 0.306); + /// <div style="background-color: rgb(133, 76, 48); width: 10px; padding: 10px; border :1px solid;"></div> + pub const BROWN: Color = Color::rgb(0.522, 0.298, 0.188); + /// <div style="background-color: rgb(52, 101, 36); width: 10px; padding: 10px; border :1px solid;"></div> + pub const FOREST_GREEN: Color = Color::rgb(0.204, 0.396, 0.141); + /// <div style="background-color: rgb(208, 70, 72); width: 10px; padding: 10px; border :1px solid;"></div> + pub const RED: Color = Color::rgb(0.816, 0.275, 0.282); + /// <div style="background-color: rgb(117, 113, 97); width: 10px; padding: 10px; border :1px solid;"></div> + pub const OLIVE_GREY: Color = Color::rgb(0.459, 0.443, 0.380); + /// <div style="background-color: rgb(89, 125, 206); width: 10px; padding: 10px; border :1px solid;"></div> + pub const MID_BLUE: Color = Color::rgb(0.349, 0.490, 0.808); + /// <div style="background-color: rgb(210, 125, 44); width: 10px; padding: 10px; border :1px solid;"></div> + pub const ORANGE: Color = Color::rgb(0.824, 0.490, 0.173); + /// <div style="background-color: rgb(133, 149, 161); width: 10px; padding: 10px; border :1px solid;"></div> + pub const STEEL_GREY: Color = Color::rgb(0.522, 0.584, 0.631); + /// <div style="background-color: rgb(109, 170, 44); width: 10px; padding: 10px; border :1px solid;"></div> + pub const GRASS_GREEN: Color = Color::rgb(0.427, 0.667, 0.173); + /// <div style="background-color: rgb(210, 170, 153); width: 10px; padding: 10px; border :1px solid;"></div> + pub const CHICKEN_SKIN: Color = Color::rgb(0.824, 0.667, 0.600); + /// <div style="background-color: rgb(109, 194, 202); width: 10px; padding: 10px; border :1px solid;"></div> + pub const ICE_BLUE: Color = Color::rgb(0.427, 0.761, 0.792); + /// <div style="background-color: rgb(218, 212, 94); width: 10px; padding: 10px; border :1px solid;"></div> + pub const YELLOW: Color = Color::rgb(0.855, 0.831, 0.369); + /// <div style="background-color: rgb(222, 238, 214); width: 10px; padding: 10px; border :1px solid;"></div> + pub const OFF_WHITE: Color = Color::rgb(0.871, 0.933, 0.839); +} diff --git a/src/system/mod.rs b/src/system/mod.rs index d70e6311bf4eaa7796f38de7b525d6fc119ea649..77616b8966d88095c8b40c8e5b8497c2bec8aad1 100644 --- a/src/system/mod.rs +++ b/src/system/mod.rs @@ -1,4 +1,5 @@ mod camera; +mod colours; mod parallax; mod window; @@ -22,6 +23,7 @@ mod _plugin { } pub use camera::default_projection; +pub use colours::DawnBringerPalette; pub use parallax::{Background, BACKGROUND_HEIGHT, BACKGROUND_WIDTH}; pub use window::{window_bounds, VIEWPORT_HEIGHT, VIEWPORT_WIDTH};