diff --git a/assets/config/actor.ron b/assets/config/actor.ron index 0e11d06..b2958f2 100644 --- a/assets/config/actor.ron +++ b/assets/config/actor.ron @@ -11,8 +11,8 @@ ), sprite_animation: SpriteAnimation( frames: [ - SpriteAnimationFrame(index: 0, beats: 1), - SpriteAnimationFrame(index: 1, beats: 1), + SpriteAnimationFrame(index: 0, beats: 16), + SpriteAnimationFrame(index: 1, beats: 16), ], ), @@ -48,8 +48,8 @@ ), sprite_animation: SpriteAnimation( frames: [ - SpriteAnimationFrame(index: 0, beats: 1), - SpriteAnimationFrame(index: 1, beats: 1), + SpriteAnimationFrame(index: 0, beats: 16), + SpriteAnimationFrame(index: 1, beats: 16), ], ), @@ -72,8 +72,8 @@ ), sprite_animation: SpriteAnimation( frames: [ - SpriteAnimationFrame(index: 0, beats: 1), - SpriteAnimationFrame(index: 1, beats: 1), + SpriteAnimationFrame(index: 0, beats: 16), + SpriteAnimationFrame(index: 1, beats: 16), ], ), @@ -96,8 +96,8 @@ ), sprite_animation: SpriteAnimation( frames: [ - SpriteAnimationFrame(index: 0, beats: 1), - SpriteAnimationFrame(index: 1, beats: 1), + SpriteAnimationFrame(index: 0, beats: 16), + SpriteAnimationFrame(index: 1, beats: 16), ], ), @@ -120,8 +120,8 @@ ), sprite_animation: SpriteAnimation( frames: [ - SpriteAnimationFrame(index: 0, beats: 1), - SpriteAnimationFrame(index: 1, beats: 1), + SpriteAnimationFrame(index: 0, beats: 16), + SpriteAnimationFrame(index: 1, beats: 16), ], ), @@ -144,8 +144,8 @@ ), sprite_animation: SpriteAnimation( frames: [ - SpriteAnimationFrame(index: 0, beats: 1), - SpriteAnimationFrame(index: 1, beats: 1), + SpriteAnimationFrame(index: 0, beats: 16), + SpriteAnimationFrame(index: 1, beats: 16), ], ), diff --git a/src/game/actor/level/xp.rs b/src/game/actor/level/xp.rs index 0365baf..5bb0f93 100644 --- a/src/game/actor/level/xp.rs +++ b/src/game/actor/level/xp.rs @@ -6,6 +6,7 @@ use crate::core::UpdateSet; use crate::game::actor::faction::Faction; use crate::game::actor::level::Level; use crate::game::actor::level::LevelConfig; +use crate::game::actor::player::IsPlayer; use crate::game::combat::death::OnDeath; use crate::ui::prelude::*; use crate::util::prelude::*; @@ -47,15 +48,16 @@ impl Configure for OnXpReward { } } -fn receive_xp(trigger: Trigger, mut xp_query: Query<&mut Xp>) { - let entity = r!(trigger.get_entity()); - let mut xp = r!(xp_query.get_mut(entity)); - xp.gain(trigger.event().0); +// TODO: Not needed for this jam game, but it would be "more correct" to track +// the owner of the projectile that killed the actor with the `XpReward`, +// and only trigger `OnXpReward` for that entity. +fn receive_xp(trigger: Trigger, mut xp_query: Query<&mut Xp, With>) { + for mut xp in &mut xp_query { + xp.gain(trigger.event().0); + } } -// TODO: Not needed for this jam game, but it would be "more correct" to track -// the owner of the projectile that killed the actor with the `XpReward`. -/// Experience rewarded to player entities on death. +/// Experience points rewarded to the killer on death. #[derive(Component, Reflect, Serialize, Deserialize, Copy, Clone)] #[reflect(Component)] #[serde(transparent)] diff --git a/src/game/spotlight.rs b/src/game/spotlight.rs index 68f5ba7..45fe5a3 100644 --- a/src/game/spotlight.rs +++ b/src/game/spotlight.rs @@ -64,8 +64,8 @@ impl Config for SpotlightConfig { impl SpotlightConfig { fn color(&self, t: f32) -> Color { let n = self.color_loop.len(); - let t = t * n as f32; - let lo = (t as usize).rem_euclid(n); + let t = (t * n as f32).rem_euclid(n as f32); + let lo = t as usize; let hi = if lo + 1 < n { lo + 1 } else { 0 }; let t = t.fract().quadratic_in_out(); diff --git a/src/game/sprite.rs b/src/game/sprite.rs index 7e54b97..3777e33 100644 --- a/src/game/sprite.rs +++ b/src/game/sprite.rs @@ -32,7 +32,7 @@ impl Configure for SpriteAnimation { Update, update_sprite_animation .in_set(UpdateSet::Update) - .run_if(on_beat(4)), + .run_if(on_beat(1)), ); } } diff --git a/src/game/wave.rs b/src/game/wave.rs index 6a509d7..1a2a6d4 100644 --- a/src/game/wave.rs +++ b/src/game/wave.rs @@ -1,3 +1,4 @@ +use bevy::ecs::system::EntityCommand; use bevy::prelude::*; use bevy::utils::HashMap; use pyri_state::prelude::*; @@ -122,3 +123,9 @@ fn any_condition_met(conditions: &[SpawnCondition], current_level: &usize) -> bo SpawnCondition::LessThan(value) => current_level < value, }) } + +pub fn wave(player: Entity) -> impl EntityCommand { + move |mut entity: EntityWorldMut| { + entity.insert((Name::new("Wave"), Wave::default(), Selection(player))); + } +} diff --git a/src/screen/playing.rs b/src/screen/playing.rs index ea1f657..ceac13a 100644 --- a/src/screen/playing.rs +++ b/src/screen/playing.rs @@ -12,6 +12,7 @@ use pyri_state::schedule::ResolveStateSet; use crate::core::pause::Pause; use crate::game::actor::player::player; use crate::game::spotlight::spotlight_lamp_spawner; +use crate::game::wave::wave; use crate::game::GameRoot; use crate::screen::fade_in; use crate::screen::playing::hud::playing_hud; @@ -31,12 +32,20 @@ fn enter_playing(mut commands: Commands, game_root: Res, ui_root: Res< commands.spawn_with(fade_in); // TODO: Character select screen. + // Spawn player. let player = commands.spawn_with(player("pink")).id(); + // Spawn enemies. + commands + .spawn_with(wave(player)) + .set_parent(game_root.enemies); + + // Spawn VFX. commands .spawn_with(spotlight_lamp_spawner) .set_parent(game_root.vfx); + // Spawn UI. commands .spawn_with(playing_hud(player)) .set_parent(ui_root.body);