Skip to content

Commit

Permalink
Add movement cards
Browse files Browse the repository at this point in the history
  • Loading branch information
benfrankel committed Jul 29, 2024
1 parent 925cca3 commit 2d44879
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 35 deletions.
1 change: 0 additions & 1 deletion assets/config/actor.ron
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
],
),

movement: Movement(speed: 80.0),
attack: Attack(color: Srgba(Srgba(red: 0.855, green: 0.576, blue: 0.800, alpha: 1.000))),
health: Health(max: 100, current: 100),
deck: Deck(cards: ["step", "pair"]),
Expand Down
90 changes: 73 additions & 17 deletions assets/config/card.ron
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
"step": CardIcon(texture: "image/card/icon/step.png"),
"splits": CardIcon(texture: "image/card/icon/splits.png"),
"ballet": CardIcon(texture: "image/card/icon/ballet.png"),
"moonwalk": CardIcon(texture: "image/card/icon/moonwalk.png"),
"cartwheel": CardIcon(texture: "image/card/icon/cartwheel.png"),
"moonwalk": CardIcon(texture: "image/card/icon/moonwalk.png"),

"eighth_note": CardIcon(texture: "image/card/icon/eighth_note.png"),
"quarter_note": CardIcon(texture: "image/card/icon/quarter_note.png"),
Expand Down Expand Up @@ -72,33 +72,89 @@
description: "A-one and a-two and a-step.",
background: "blue",
icon: "step",
max_level: 4,
weight: 0.8,

//play_sfx: "audio/sfx/Movement.ogg",
play_sfx: "audio/sfx/444407__mootmcnoodles__slap.ogg",
//play_sfx: "audio/sfx/137105__chaosportal__finger-snap-01.ogg",
//play_sfx: "audio/sfx/102130__noirpantalon__hard_subby_kick.ogg",
//play_sfx: "audio/sfx/24787__young_daddy__clap-mix2.ogg",
action: Step,
action: Move,
action_modifier: CardActionModifier(
remove_on_beat: 8,
hitbox_damage: (15.0, 0.5),
remove_on_beat: 5,
movement: Movement(speed: 80.0),
immunity: Some(0.5),
contact_damage: 8,
contact_beats: 5,
immunity: 0.15,
),
),
/*"splits": Card(
"splits": Card(
name: "Splits",
description: "Split in two!",
background: "blue",
icon: "splits",
weight: 0.3,

play_sfx: "audio/sfx/Movement.ogg",
play_sfx: "audio/sfx/444407__mootmcnoodles__slap.ogg",
action: Move,
action_modifier: CardActionModifier(
remove_on_beat: 16,
movement: Movement(speed: 0),
contact_damage: 30,
contact_beats: 16,
immunity: 1.0,
),
),*/
// TODO: Add other movement cards.
),
"ballet": Card(
name: "Pirouette",
description: "",
background: "blue",
icon: "ballet",
min_level: 3,
weight: 0.8,

play_sfx: "audio/sfx/444407__mootmcnoodles__slap.ogg",
action: Move,
action_modifier: CardActionModifier(
remove_on_beat: 6,
movement: Movement(speed: 120.0),
contact_damage: 12,
contact_beats: 6,
immunity: 0.3,
),
),
"cartwheel": Card(
name: "Cartwheel",
description: "Round and round, let the city turn!",
background: "blue",
icon: "cartwheel",
min_level: 5,
weight: 0.8,

play_sfx: "audio/sfx/444407__mootmcnoodles__slap.ogg",
action: Move,
action_modifier: CardActionModifier(
remove_on_beat: 4,
movement: Movement(speed: 160.0, facing_offset: 0.25),
contact_damage: 20,
contact_beats: 6,
immunity: 0.4,
),
),
"moonwalk": Card(
name: "Moonwalk",
description: "",
background: "blue",
icon: "moonwalk",
min_level: 7,

play_sfx: "audio/sfx/444407__mootmcnoodles__slap.ogg",
action: Move,
action_modifier: CardActionModifier(
remove_on_beat: 8,
movement: Movement(speed: 40.0, facing_offset: 0.5),
contact_damage: 50,
contact_beats: 8,
immunity: 0.5,
),
),

"eighth_note": Card(
name: "Eighth Note",
Expand Down Expand Up @@ -200,7 +256,7 @@
weight: 0.5,

action: Heal,
action_modifier: CardActionModifier(heal_flat: 5),
action_modifier: CardActionModifier(heal_flat: 5, immunity: 0.5),
),
"quarter_rest": Card(
name: "Quarter Rest",
Expand All @@ -212,7 +268,7 @@
weight: 0.5,

action: Heal,
action_modifier: CardActionModifier(heal_percent: 25),
action_modifier: CardActionModifier(heal_percent: 25, immunity: 0.5),
),
"half_rest": Card(
name: "Half Rest",
Expand All @@ -224,7 +280,7 @@
weight: 0.5,

action: Heal,
action_modifier: CardActionModifier(heal_percent: 50),
action_modifier: CardActionModifier(heal_percent: 50, immunity: 0.5),
),
"whole_rest": Card(
name: "Whole Rest",
Expand All @@ -235,7 +291,7 @@
weight: 0.5,

action: Heal,
action_modifier: CardActionModifier(heal_percent: 100),
action_modifier: CardActionModifier(heal_percent: 100, immunity: 0.5),
),
}
)
2 changes: 1 addition & 1 deletion assets/config/wave.ron
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
spawn_cadence: 4,
min_distance: 150.0,
max_distance: 180.0,
spawn_count_scale: 1.8,
spawn_count_scale: 0.5,
max_spawn_count: 100,
)
8 changes: 4 additions & 4 deletions src/game/actor/movement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ pub struct Movement {
pub decel: f32,
/// The max "under control" speed (pixels per second).
pub speed: f32,
/// The offset from facing that the movement will head.
pub facing_offset: f32,
/// The direction the movement will travel relative to the target direction (full turns).
pub direction: f32,
}

impl Configure for Movement {
Expand All @@ -54,10 +54,10 @@ impl Configure for Movement {
impl Default for Movement {
fn default() -> Self {
Self {
accel: 1000.0,
accel: 2500.0,
decel: 0.0001,
speed: 80.0,
facing_offset: 0.0,
direction: 0.0,
}
}
}
Expand Down
42 changes: 31 additions & 11 deletions src/game/card/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl FromWorld for CardActionMap {
Self(
[
(
CardActionKey::Step,
CardActionKey::Move,
world.register_system(
|In((entity, modifier)): In<(Entity, CardActionModifier)>,
world: &mut World| {
Expand All @@ -47,17 +47,19 @@ impl FromWorld for CardActionMap {
modifier.remove_on_beat,
));

// Player actor has extra benefits
// Player actor has extra benefits:
if entity.contains::<IsPlayer>() {
entity.insert(RemoveOnTimer::bundle(
HitboxDamage(modifier.hitbox_damage.0),
Timer::from_seconds(modifier.hitbox_damage.1, TimerMode::Once),
));
if modifier.contact_damage > 0.0 {
entity.insert(RemoveOnBeat::bundle(
HitboxDamage(modifier.contact_damage),
modifier.contact_beats,
));
}

if let Some(timer) = modifier.immunity {
if modifier.immunity > 0.0 {
entity.insert(RemoveOnTimer::bundle(
Immune,
Timer::from_seconds(timer, TimerMode::Once),
Timer::from_seconds(modifier.immunity, TimerMode::Once),
));
}
}
Expand Down Expand Up @@ -88,6 +90,23 @@ impl FromWorld for CardActionMap {
let mut health = r!(entity.get_mut::<Health>());
health.current += modifier.heal_flat;
health.current += modifier.heal_percent / 100.0 * health.max;

// Player actor has extra benefits:
if entity.contains::<IsPlayer>() {
if modifier.contact_damage > 0.0 {
entity.insert(RemoveOnBeat::bundle(
HitboxDamage(modifier.contact_damage),
modifier.contact_beats,
));
}

if modifier.immunity > 0.0 {
entity.insert(RemoveOnTimer::bundle(
Immune,
Timer::from_seconds(modifier.immunity, TimerMode::Once),
));
}
}
},
),
),
Expand All @@ -101,7 +120,7 @@ impl FromWorld for CardActionMap {

#[derive(Reflect, Serialize, Deserialize, Eq, PartialEq, Hash, Copy, Clone)]
pub enum CardActionKey {
Step,
Move,
Attack,
Heal,
}
Expand All @@ -126,8 +145,9 @@ pub struct CardActionModifier {
remove_on_timer: Timer,
attack: Attack,
movement: Movement,
immunity: Option<f32>,
hitbox_damage: (f32, f32), // damage, time
contact_damage: f32,
contact_beats: usize,
heal_percent: f32,
heal_flat: f32,
immunity: f32,
}
2 changes: 1 addition & 1 deletion src/game/card/movement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fn apply_move_towards_facing(
for (mut movement, mut controller, facing, move_towards_facing) in &mut movement_query {
*movement = move_towards_facing.0;

let facing_angle = Vec2::from_angle(movement.facing_offset * TAU);
let facing_angle = Vec2::from_angle(movement.direction * TAU);
controller.0 += (*facing.0).rotate(facing_angle);
}
}

0 comments on commit 2d44879

Please sign in to comment.