Skip to content

Commit

Permalink
More stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
benfrankel committed Jul 29, 2024
1 parent 4df0f87 commit d153a4c
Show file tree
Hide file tree
Showing 14 changed files with 114 additions and 27 deletions.
Binary file added assets/audio/sfx/UI Click_1.ogg
Binary file not shown.
Binary file added assets/audio/sfx/UI Click_1.wav
Binary file not shown.
Binary file added assets/audio/sfx/UI Hover_1.ogg
Binary file not shown.
Binary file added assets/audio/sfx/UI Hover_1.wav
Binary file not shown.
86 changes: 66 additions & 20 deletions assets/config/card.ron
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@
"half_note": CardIcon(texture: "image/card/icon/half_note.png"),
"whole_note": CardIcon(texture: "image/card/icon/whole_note.png"),
"pair": CardIcon(texture: "image/card/icon/pair.png"),
//"triplet": CardIcon(texture: "image/card/icon/triplet.png"),
"triplet": CardIcon(texture: "image/card/icon/triplet.png"),
"chord": CardIcon(texture: "image/card/icon/chord.png"),
"cluster": CardIcon(texture: "image/card/icon/cluster.png"),
"cacophony": CardIcon(texture: "image/card/icon/cacophony.png"),

"eighth_rest": CardIcon(texture: "image/card/icon/eighth_rest.png"),
"quarter_rest": CardIcon(texture: "image/card/icon/quarter_rest.png"),
Expand Down Expand Up @@ -97,9 +98,9 @@
action_modifier: CardActionModifier(
remove_on_beat: 16,
movement: Movement(speed: 0),
contact_damage: 30,
contact_damage: 45,
contact_beats: 16,
immunity: 1.0,
immunity: 0.9,
),
),
"ballet": Card(
Expand Down Expand Up @@ -133,8 +134,8 @@
action_modifier: CardActionModifier(
remove_on_beat: 4,
movement: Movement(speed: 160.0, direction: 0.25),
contact_damage: 20,
contact_beats: 6,
contact_damage: 40,
contact_beats: 7,
immunity: 0.4,
),
),
Expand All @@ -150,9 +151,9 @@
action_modifier: CardActionModifier(
remove_on_beat: 12,
movement: Movement(speed: 50.0, direction: 0.5),
contact_damage: 50,
contact_damage: 60,
contact_beats: 12,
immunity: 0.8,
immunity: 0.9,
),
),

Expand Down Expand Up @@ -223,28 +224,73 @@
attack: Attack(projectile: Some("eighth_note")),
),
),
/*"major_chord": Card(
"triplet": Card(
name: "Triplet",
description: "... Three beats, rapid fire!",
background: "pink",
icon: "triplet",
max_level: 4,
weight: 0.1,

action: Attack,
action_modifier: CardActionModifier(
remove_on_beat: 8,
attack: Attack(projectile: Some("eighth_note")),
attack_on_beat: 3,
),
),
"cacophony": Card(
name: "Cacophony",
description: "How's my volume?",
background: "pink",
icon: "cacophony",
min_level: 4,
max_level: 7,
weight: 0.1,

action: Attack,
action_modifier: CardActionModifier(
remove_on_beat: 6,
attack: Attack(
projectile: Some("eighth_note"),
multi_shot: Some(MultiShot([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9])),
),
attack_on_beat: 2,
),
),
"major_chord": Card(
name: "Major Chord",
description: "",
background: "pink",
icon: "chord",
min_level: 6,

action: Attack,
action_modifier: CardActionModifier(
remove_on_beat: 16,
attack: Attack(projectile: Some("eighth_note")),
remove_on_beat: 0,
attack: Attack(
projectile: Some("whole_note"),
multi_shot: Some(MultiShot([0.05, -0.05])),
),
),
),
"cluster_chord": Card(
name: "Cluster Chord",
description: "",
background: "pink",
icon: "chord",
icon: "cluster",
min_level: 8,
weight: 0.7,

action: Attack,
action_modifier: CardActionModifier(
remove_on_beat: 16,
attack: Attack(projectile: Some("whole_note")),
remove_on_beat: 0,
attack: Attack(
projectile: Some("whole_note"),
multi_shot: Some(MultiShot([0.25, 0.375, 0.75])),
),
),
),*/
),

"eighth_rest": Card(
name: "Eighth Rest",
Expand All @@ -258,38 +304,38 @@
),
"quarter_rest": Card(
name: "Quarter Rest",
description: "Heal 25% health",
description: "Heal a decent amount",
background: "green",
icon: "quarter_rest",
min_level: 4,
max_level: 8,
weight: 0.7,

action: Heal,
action_modifier: CardActionModifier(heal_percent: 25, immunity: 0.8),
action_modifier: CardActionModifier(heal_flat: 25, immunity: 0.8),
),
"half_rest": Card(
name: "Half Rest",
description: "Heal 50% health",
description: "Heal 25% health",
background: "green",
icon: "half_rest",
min_level: 6,
max_level: 9,
weight: 0.6,

action: Heal,
action_modifier: CardActionModifier(heal_percent: 50, immunity: 0.9),
action_modifier: CardActionModifier(heal_percent: 25, immunity: 0.9),
),
"whole_rest": Card(
name: "Whole Rest",
description: "Heal 100% health",
description: "Heal 50% health",
background: "green",
icon: "whole_rest",
min_level: 8,
weight: 0.5,

action: Heal,
action_modifier: CardActionModifier(heal_percent: 100, immunity: 1.0),
action_modifier: CardActionModifier(heal_percent: 50, immunity: 1.0),
),
}
)
Binary file added assets/image/card/icon/cacophony.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/image/card/icon/icons.aseprite
Binary file not shown.
Binary file added assets/image/card/icon/triplet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 26 additions & 2 deletions src/game/card/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::game::actor::attack::Attack;
use crate::game::actor::health::Health;
use crate::game::actor::movement::Movement;
use crate::game::actor::player::IsPlayer;
use crate::game::audio::music::Beat;
use crate::game::card::attack::AimTowardsFacing;
use crate::game::card::attack::AttackOnBeat;
use crate::game::card::movement::MoveTowardsFacing;
Expand Down Expand Up @@ -71,9 +72,14 @@ impl FromWorld for CardActionMap {
world.register_system(
|In((entity, modifier)): In<(Entity, CardActionModifier)>,
world: &mut World| {
let beat = world.resource::<Beat>().total;
r!(world.get_entity_mut(entity)).insert((
RemoveOnBeat::bundle(
AttackOnBeat(modifier.attack.clone()),
AttackOnBeat(
modifier.attack.clone(),
modifier.attack_on_beat,
beat % modifier.attack_on_beat,
),
modifier.remove_on_beat,
),
RemoveOnBeat::bundle(AimTowardsFacing, modifier.remove_on_beat),
Expand Down Expand Up @@ -136,18 +142,36 @@ impl Default for CardAction {
}
}

#[derive(Default, Reflect, Serialize, Deserialize, Clone)]
#[derive(Reflect, Serialize, Deserialize, Clone)]
#[serde(default)]
pub struct CardActionModifier {
/// Remove component after this many eighth-beats.
remove_on_beat: usize,
/// Remove component when this timer finishes.
remove_on_timer: Timer,
attack: Attack,
attack_on_beat: usize,
movement: Movement,
contact_damage: f32,
contact_beats: usize,
heal_percent: f32,
heal_flat: f32,
immunity: f32,
}

impl Default for CardActionModifier {
fn default() -> Self {
Self {
remove_on_beat: 0,
remove_on_timer: Timer::default(),
attack: Attack::default(),
attack_on_beat: 4,
movement: Movement::default(),
contact_damage: 0.0,
contact_beats: 0,
heal_percent: 0.0,
heal_flat: 0.0,
immunity: 0.0,
}
}
}
14 changes: 11 additions & 3 deletions src/game/card/attack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use crate::game::actor::attack::Attack;
use crate::game::actor::attack::AttackController;
use crate::game::actor::facing::Facing;
use crate::game::audio::music::on_beat;
use crate::game::audio::music::Beat;
use crate::game::cleanup::RemoveOnBeat;
use crate::util::prelude::*;

Expand Down Expand Up @@ -37,7 +38,7 @@ fn apply_aim_towards_facing(

#[derive(Component, Reflect)]
#[reflect(Component)]
pub struct AttackOnBeat(pub Attack);
pub struct AttackOnBeat(pub Attack, pub usize, pub usize);

impl Configure for AttackOnBeat {
fn configure(app: &mut App) {
Expand All @@ -47,13 +48,20 @@ impl Configure for AttackOnBeat {
Update,
attack_on_beat
.in_set(UpdateSet::RecordInput)
.run_if(on_beat(4)),
.run_if(on_beat(1)),
);
}
}

fn attack_on_beat(mut attack_query: Query<(&mut Attack, &mut AttackController, &AttackOnBeat)>) {
fn attack_on_beat(
beat: Res<Beat>,
mut attack_query: Query<(&mut Attack, &mut AttackController, &AttackOnBeat)>,
) {
for (mut attack, mut controller, attack_on_beat) in &mut attack_query {
if beat.total % attack_on_beat.1 != attack_on_beat.2 {
continue;
}

attack.power = attack_on_beat.0.power;
attack.force = attack_on_beat.0.force;
attack.projectile_key = attack_on_beat.0.projectile_key.clone();
Expand Down
2 changes: 1 addition & 1 deletion src/game/combat/projectile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ pub fn projectile(

if let Some((attack, facing)) = child_projectiles {
entity.insert((
AttackOnBeat(attack.clone()),
AttackOnBeat(attack.clone(), 4, 0),
AimTowardsFacing,
AttackController::default(),
facing,
Expand Down
5 changes: 5 additions & 0 deletions src/game/wave.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use crate::game::actor::enemy::IsEnemy;
use crate::game::actor::level::Level;
use crate::game::actor::ActorConfig;
use crate::game::audio::music::on_full_beat;
use crate::screen::playing::victory_menu::EndlessMode;
use crate::screen::Screen;
use crate::util::prelude::*;

Expand Down Expand Up @@ -66,13 +67,17 @@ fn spawn_wave_enemies(
enemy_query: Query<(), With<IsEnemy>>,
mut wave_query: Query<(&mut Wave, &Selection)>,
level_query: Query<&Level>,
endless_mode: Res<EndlessMode>,
) {
let config = r!(config.get());
let actor_config = r!(actor_config.get());
let camera_gt = r!(camera_query.get(camera_root.primary));
let center = camera_gt.translation().xy();

let mut spawn_cap = config.spawn_cap.saturating_sub(enemy_query.iter().count());
if endless_mode.0 {
spawn_cap *= 2;
}

let mut rng = rand::thread_rng();
for (mut wave, selection) in &mut wave_query {
Expand Down
4 changes: 4 additions & 0 deletions src/screen/playing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ pub struct PlayingAssets {
pub sfx_ui_click: Handle<AudioSource>,
#[asset(path = "audio/sfx/UI Click.ogg")]
pub sfx_ui_hover: Handle<AudioSource>,
#[asset(path = "audio/sfx/UI Hover_1.ogg")]
pub sfx_ui_click1: Handle<AudioSource>,
#[asset(path = "audio/sfx/UI Click_1.ogg")]
pub sfx_ui_hover1: Handle<AudioSource>,
#[asset(path = "audio/sfx/Movement.ogg")]
pub sfx_movement: Handle<AudioSource>,

Expand Down
2 changes: 1 addition & 1 deletion src/ui/interaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ fn play_interaction_sfx(
},
Interaction::Pressed => {
audio
.play(assets.sfx_ui_click.clone())
.play(assets.sfx_ui_click1.clone())
.with_volume(0.6)
.with_playback_rate(rand::thread_rng().gen_range(0.7..1.6));
},
Expand Down

0 comments on commit d153a4c

Please sign in to comment.