diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 5119436..1d2d273 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -26,35 +26,6 @@ jobs: command: fmt args: --all -- --check - # Run test check on Linux, macOS, and Windows - test: - name: Test - runs-on: ${{ matrix.os }} - strategy: - fail-fast: true - matrix: - os: [ubuntu-latest, macOS-latest, windows-latest] - steps: - # Checkout the branch being tested - - uses: actions/checkout@v4 - - # Install rust stable - - uses: dtolnay/rust-toolchain@master - with: - toolchain: stable - - # Cache the built dependencies - - uses: Swatinem/rust-cache@v2.7.1 - with: - save-if: ${{ github.event_name == 'push' }} - - # Install cargo-hack - - uses: taiki-e/install-action@cargo-hack - - # Test all feature combinations on the target platform - - name: Test - run: cargo hack --feature-powerset test - # Build the WASM target & push it to GitHub pages wasm: name: WASM test & build diff --git a/Cargo.toml b/Cargo.toml index 3422414..6ce4ed7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ categories = ["games"] [dependencies] log = "0.4" -chuot = "0.3" +chuot = { path = "../chuot" } glamour = "0.15" puffin = "0.19" nanoserde = "0.1" diff --git a/assets/level/grass-1.png b/assets/level/grass-1.png index 0bafeae..236bf13 100644 Binary files a/assets/level/grass-1.png and b/assets/level/grass-1.png differ diff --git a/assets/settings.ron b/assets/settings.ron index 6336521..2e7191c 100644 --- a/assets/settings.ron +++ b/assets/settings.ron @@ -2,7 +2,7 @@ // Distance from the edge at which the camera will pan pan_edge_offset: 80, // How many pixels per second the camera will pan - pan_speed: 100, + pan_speed: 300, // Interval in seconds for when a unit spawns unit_spawn_interval: 3, diff --git a/assets/unit/enemy-spear.ron b/assets/unit/enemy-spear.ron index 7ba0748..9eb6247 100644 --- a/assets/unit/enemy-spear.ron +++ b/assets/unit/enemy-spear.ron @@ -13,26 +13,17 @@ // Interval in seconds for when a new projectile is thrown projectile_spawn_interval: 10, // Don't let the projectile spawn in the ground - projectile_spawn_offset: (0, -20), + projectile_spawn_offset: (-10, -20), // How fast a projectile is thrown projectile_velocity: Static(70), // How long the hands are hidden after launching a projectile in seconds hide_hands_delay: 2, + // Where the hands are placed + hands_offset: (13, 1), + // Size of the healthbar healthbar_size: (20, 3), // Where above the unit it floats healthbar_offset: (-1, -8), - - // physics: ( - // // Handle all collisions manually - // is_kinematic: true, - // ), - - // // Collider shape for collisions with projectile - // collider: ( - // shape: "rectangle", - // width: 10, - // height: 30, - // ), ) diff --git a/assets/unit/spear.ron b/assets/unit/spear.ron index f7bd76c..a455b6f 100644 --- a/assets/unit/spear.ron +++ b/assets/unit/spear.ron @@ -19,6 +19,9 @@ // How long the hands are hidden after launching a projectile in seconds hide_hands_delay: 2, + // Where the hands are placed + hands_offset: (-1, -1), + // Size of the healthbar healthbar_size: (20, 3), // Where above the unit it floats diff --git a/src/unit.rs b/src/unit.rs index 818bbb4..5502dc1 100644 --- a/src/unit.rs +++ b/src/unit.rs @@ -15,7 +15,7 @@ use crate::{ }; /// All unit types. -#[derive(Debug, Clone, Copy)] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum UnitType { PlayerSpear, EnemySpear, @@ -116,23 +116,18 @@ impl Unit { Some(Projectile::new( self.pos + Vector2::from_tuple(projectile_spawn_offset), - Vector2::new(velocity, -velocity), + Vector2::new( + if self.r#type == UnitType::PlayerSpear { + velocity + } else { + -velocity + }, + -velocity, + ), )) } else { None } - - /* - // Draw the healthbar - crate::graphics::healthbar::healthbar( - self.health, - settings.health, - self.pos + settings.healthbar_offset, - settings.healthbar_size, - canvas, - camera, - ); - */ } /// Draw the unit. @@ -157,7 +152,12 @@ impl Unit { if let Some(hands_asset_path) = &settings.hands_asset_path { if self.hide_hands_delay <= 0.0 { ctx.sprite(hands_asset_path) - .translate(draw_pos - Vector2::splat(1.0)) + .translate(draw_pos + Vector2::from_tuple(settings.hands_offset)) + .scale_x(if self.r#type == UnitType::PlayerSpear { + 1.0 + } else { + -1.0 + }) .draw(); } } @@ -199,6 +199,8 @@ pub struct Settings { pub projectile_velocity: RandomRange, /// How long the hands are hidden after launching a projectile. pub hide_hands_delay: f32, + /// Position offset of the hands. + pub hands_offset: (f32, f32), /// Size of the healthbar. pub healthbar_size: (f32, f32), /// Position offset of the healthbar.