diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e93bd3..6a3fbb8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,10 +9,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- Animated star and planet exported as spritesheets from Deep-Fold's Pixel Planet Generator +- Basic orbital system moving planet in circlular orbit around star +- Pausable GameTime resource and tick system to prevent dynamic systems jumping forwards after unpause +- Attribution for Deep-Fold in Credits for Pixel Planets - WorldInspectorPlugin from bevy-inspector-egui for development/debugging ### Changed +- Adjusted scale of ship smaller by default +- Moved background handling to plugin +- Adjusted movement scale of background for parallax effect - Moved assets to reusable resources plugin in assets.rs - Moved controls to table in README diff --git a/README.md b/README.md index a27dedc..7f8ad40 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,10 @@ Built on [Rust](https://www.rust-lang.org/) with [Bevy](https://bevyengine.org/) From [Kenney.nl](https://www.kenney.nl/), [CC0](https://creativecommons.org/publicdomain/zero/1.0/) +- [Pixel Planet Generator](https://deep-fold.itch.io/pixel-planet-generator) by [Deep-Fold](https://deep-fold.itch.io/) + + From [itch.io](https://itch.io/) + ### Music - [Lightspeed](https://freemusicarchive.org/music/beat-mekanik/single/lightspeed/) by [Beat Mekanik](https://freemusicarchive.org/music/beat-mekanik/) diff --git a/assets/space/celestials/planet-pixelplanet.png b/assets/space/celestials/planet-pixelplanet.png new file mode 100644 index 0000000..741d5ac --- /dev/null +++ b/assets/space/celestials/planet-pixelplanet.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0f5c7270a338ac22d7b0c8c5e7a2d13e1c483f2fc6181e28e1c9e8aac4ae2dd3 +size 395597 diff --git a/assets/space/celestials/star-pixelplanet.png b/assets/space/celestials/star-pixelplanet.png new file mode 100644 index 0000000..99b76be --- /dev/null +++ b/assets/space/celestials/star-pixelplanet.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:835c35afd40af356acdcea598df2066a1fd5f6573d2d5f54c725045ea91eacfb +size 2023456 diff --git a/src/assets.rs b/src/assets.rs index 3789ff9..a655ef0 100644 --- a/src/assets.rs +++ b/src/assets.rs @@ -3,6 +3,8 @@ use bevy::prelude::*; #[derive(Debug, Resource)] pub struct SpriteAssets { pub player_ship: Handle, + pub star: Handle, + pub planet: Handle, pub background: Handle, } #[derive(Debug, Resource)] @@ -30,9 +32,29 @@ impl Plugin for AssetsPlugin { // See: asset_server.free_unused_assets() // We can then remove the use of PreStartup above, which // doesn't feel idiomatic. -fn setup(mut commands: Commands, asset_server: Res) { +fn setup( + mut commands: Commands, + asset_server: Res, + mut texture_atlases: ResMut>, +) { commands.insert_resource(SpriteAssets { player_ship: asset_server.load("space/ships/playerShip2_blue.png"), + star: texture_atlases.add(TextureAtlas::from_grid( + asset_server.load("space/celestials/star-pixelplanet.png"), + Vec2::new(500.0, 500.0), + 25, + 5, + None, + None, + )), + planet: texture_atlases.add(TextureAtlas::from_grid( + asset_server.load("space/celestials/planet-pixelplanet.png"), + Vec2::new(125.0, 125.0), + 25, + 5, + None, + None, + )), background: asset_server.load("space/backgrounds/custom.png"), }); commands.insert_resource(AudioAssets { diff --git a/src/background.rs b/src/background.rs new file mode 100644 index 0000000..ab2f535 --- /dev/null +++ b/src/background.rs @@ -0,0 +1,34 @@ +use bevy::{prelude::*, render::view::NoFrustumCulling}; +use bevy_tiling_background::{ + BackgroundImageBundle, BackgroundMaterial, SetImageRepeatingExt, TilingBackgroundPlugin, +}; + +use crate::assets::SpriteAssets; + +pub struct BackgroundPlugin; +impl Plugin for BackgroundPlugin { + fn build(&self, app: &mut App) { + app.add_plugins(TilingBackgroundPlugin::::default()); + + app.add_systems(Startup, setup); + } +} + +/// The setup function +fn setup( + mut commands: Commands, + sprites: Res, + mut materials: ResMut>, +) { + let image = sprites.background.clone(); + // Queue a command to set the image to be repeating once the image is loaded. + commands.set_image_repeating(image.clone()); + + commands.spawn(( + BackgroundImageBundle::from_image(image, materials.as_mut()) + .at_z_layer(-0.1) + .with_movement_scale(0.1), + NoFrustumCulling, + Name::new("Background"), + )); +} diff --git a/src/credits.rs b/src/credits.rs index 60663ee..9d897e6 100644 --- a/src/credits.rs +++ b/src/credits.rs @@ -118,6 +118,21 @@ fn setup(mut commands: Commands, ui: Res) { ), ..default() },)); + parent.spawn((TextBundle { + style: Style { + margin: UiRect::top(Val::Px(25.)), + ..default() + }, + text: Text::from_section( + "Pixel Planets by Deep-Fold", + TextStyle { + font: ui.font.clone(), + font_size: 20.0, + color: Color::rgb_u8(0xCC, 0xCC, 0xCC), + }, + ), + ..default() + },)); parent.spawn((TextBundle { style: Style { margin: UiRect::top(Val::Px(50.)), diff --git a/src/game_time.rs b/src/game_time.rs new file mode 100644 index 0000000..2e027d9 --- /dev/null +++ b/src/game_time.rs @@ -0,0 +1,18 @@ +use bevy::{prelude::*, time::Stopwatch}; + +use crate::state::AppState; + +#[derive(Resource, Deref)] +pub struct GameTime(Stopwatch); + +pub struct GameTimePlugin; +impl Plugin for GameTimePlugin { + fn build(&self, app: &mut App) { + app.insert_resource(GameTime(Stopwatch::new())) + .add_systems(Update, tick_game_time.run_if(in_state(AppState::Active))); + } +} + +fn tick_game_time(time: Res