Skip to content

Commit 51521e8

Browse files
committed
Fix various bugs
1 parent 779ed34 commit 51521e8

File tree

6 files changed

+40
-22
lines changed

6 files changed

+40
-22
lines changed

assets/config/actor.ron

+12-12
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
),
1212
sprite_animation: SpriteAnimation(
1313
frames: [
14-
SpriteAnimationFrame(index: 0, beats: 1),
15-
SpriteAnimationFrame(index: 1, beats: 1),
14+
SpriteAnimationFrame(index: 0, beats: 16),
15+
SpriteAnimationFrame(index: 1, beats: 16),
1616
],
1717
),
1818

@@ -48,8 +48,8 @@
4848
),
4949
sprite_animation: SpriteAnimation(
5050
frames: [
51-
SpriteAnimationFrame(index: 0, beats: 1),
52-
SpriteAnimationFrame(index: 1, beats: 1),
51+
SpriteAnimationFrame(index: 0, beats: 16),
52+
SpriteAnimationFrame(index: 1, beats: 16),
5353
],
5454
),
5555

@@ -72,8 +72,8 @@
7272
),
7373
sprite_animation: SpriteAnimation(
7474
frames: [
75-
SpriteAnimationFrame(index: 0, beats: 1),
76-
SpriteAnimationFrame(index: 1, beats: 1),
75+
SpriteAnimationFrame(index: 0, beats: 16),
76+
SpriteAnimationFrame(index: 1, beats: 16),
7777
],
7878
),
7979

@@ -96,8 +96,8 @@
9696
),
9797
sprite_animation: SpriteAnimation(
9898
frames: [
99-
SpriteAnimationFrame(index: 0, beats: 1),
100-
SpriteAnimationFrame(index: 1, beats: 1),
99+
SpriteAnimationFrame(index: 0, beats: 16),
100+
SpriteAnimationFrame(index: 1, beats: 16),
101101
],
102102
),
103103

@@ -120,8 +120,8 @@
120120
),
121121
sprite_animation: SpriteAnimation(
122122
frames: [
123-
SpriteAnimationFrame(index: 0, beats: 1),
124-
SpriteAnimationFrame(index: 1, beats: 1),
123+
SpriteAnimationFrame(index: 0, beats: 16),
124+
SpriteAnimationFrame(index: 1, beats: 16),
125125
],
126126
),
127127

@@ -144,8 +144,8 @@
144144
),
145145
sprite_animation: SpriteAnimation(
146146
frames: [
147-
SpriteAnimationFrame(index: 0, beats: 1),
148-
SpriteAnimationFrame(index: 1, beats: 1),
147+
SpriteAnimationFrame(index: 0, beats: 16),
148+
SpriteAnimationFrame(index: 1, beats: 16),
149149
],
150150
),
151151

src/game/actor/level/xp.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use crate::core::UpdateSet;
66
use crate::game::actor::faction::Faction;
77
use crate::game::actor::level::Level;
88
use crate::game::actor::level::LevelConfig;
9+
use crate::game::actor::player::IsPlayer;
910
use crate::game::combat::death::OnDeath;
1011
use crate::ui::prelude::*;
1112
use crate::util::prelude::*;
@@ -47,15 +48,16 @@ impl Configure for OnXpReward {
4748
}
4849
}
4950

50-
fn receive_xp(trigger: Trigger<OnXpReward>, mut xp_query: Query<&mut Xp>) {
51-
let entity = r!(trigger.get_entity());
52-
let mut xp = r!(xp_query.get_mut(entity));
53-
xp.gain(trigger.event().0);
51+
// TODO: Not needed for this jam game, but it would be "more correct" to track
52+
// the owner of the projectile that killed the actor with the `XpReward`,
53+
// and only trigger `OnXpReward` for that entity.
54+
fn receive_xp(trigger: Trigger<OnXpReward>, mut xp_query: Query<&mut Xp, With<IsPlayer>>) {
55+
for mut xp in &mut xp_query {
56+
xp.gain(trigger.event().0);
57+
}
5458
}
5559

56-
// TODO: Not needed for this jam game, but it would be "more correct" to track
57-
// the owner of the projectile that killed the actor with the `XpReward`.
58-
/// Experience rewarded to player entities on death.
60+
/// Experience points rewarded to the killer on death.
5961
#[derive(Component, Reflect, Serialize, Deserialize, Copy, Clone)]
6062
#[reflect(Component)]
6163
#[serde(transparent)]

src/game/spotlight.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ impl Config for SpotlightConfig {
6464
impl SpotlightConfig {
6565
fn color(&self, t: f32) -> Color {
6666
let n = self.color_loop.len();
67-
let t = t * n as f32;
68-
let lo = (t as usize).rem_euclid(n);
67+
let t = (t * n as f32).rem_euclid(n as f32);
68+
let lo = t as usize;
6969
let hi = if lo + 1 < n { lo + 1 } else { 0 };
7070
let t = t.fract().quadratic_in_out();
7171

src/game/sprite.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl Configure for SpriteAnimation {
3232
Update,
3333
update_sprite_animation
3434
.in_set(UpdateSet::Update)
35-
.run_if(on_beat(4)),
35+
.run_if(on_beat(1)),
3636
);
3737
}
3838
}

src/game/wave.rs

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use bevy::ecs::system::EntityCommand;
12
use bevy::prelude::*;
23
use bevy::utils::HashMap;
34
use pyri_state::prelude::*;
@@ -122,3 +123,9 @@ fn any_condition_met(conditions: &[SpawnCondition], current_level: &usize) -> bo
122123
SpawnCondition::LessThan(value) => current_level < value,
123124
})
124125
}
126+
127+
pub fn wave(player: Entity) -> impl EntityCommand<World> {
128+
move |mut entity: EntityWorldMut| {
129+
entity.insert((Name::new("Wave"), Wave::default(), Selection(player)));
130+
}
131+
}

src/screen/playing.rs

+9
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use pyri_state::schedule::ResolveStateSet;
1212
use crate::core::pause::Pause;
1313
use crate::game::actor::player::player;
1414
use crate::game::spotlight::spotlight_lamp_spawner;
15+
use crate::game::wave::wave;
1516
use crate::game::GameRoot;
1617
use crate::screen::fade_in;
1718
use crate::screen::playing::hud::playing_hud;
@@ -31,12 +32,20 @@ fn enter_playing(mut commands: Commands, game_root: Res<GameRoot>, ui_root: Res<
3132
commands.spawn_with(fade_in);
3233

3334
// TODO: Character select screen.
35+
// Spawn player.
3436
let player = commands.spawn_with(player("pink")).id();
3537

38+
// Spawn enemies.
39+
commands
40+
.spawn_with(wave(player))
41+
.set_parent(game_root.enemies);
42+
43+
// Spawn VFX.
3644
commands
3745
.spawn_with(spotlight_lamp_spawner)
3846
.set_parent(game_root.vfx);
3947

48+
// Spawn UI.
4049
commands
4150
.spawn_with(playing_hud(player))
4251
.set_parent(ui_root.body);

0 commit comments

Comments
 (0)