Skip to content

Commit

Permalink
added animation, tuned
Browse files Browse the repository at this point in the history
  • Loading branch information
odecay committed Nov 26, 2022
1 parent b870260 commit e22613c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
6 changes: 4 additions & 2 deletions assets/fighters/dev/dev.fighter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ spritesheet:
attacking:
frames: [85, 90]
chaining:
frames: [112, 116]
followup:
frames: [126, 131]

# attacks need longer recovery vs startup
Expand All @@ -56,8 +58,8 @@ attacks:
- name: "flop"
damage: 50
frames:
startup: 1
active: 2
startup: 0
active: 1
recovery: 4
hitbox:
size: [32, 32]
Expand Down
16 changes: 9 additions & 7 deletions src/fighter_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ pub struct Chaining {
impl Chaining {
pub const PRIORITY: i32 = 30;
pub const ANIMATION: &'static str = "chaining";
pub const FOLLOWUP_ANIMATION: &'static str = "followup";
pub const LENGTH: u32 = 2;
}

Expand Down Expand Up @@ -923,33 +924,35 @@ fn chaining(
if let Some(attack) = available_attacks
.attacks
.iter()
.filter(|a| a.name == "chain".to_string())
.filter(|a| a.name == *"chain")
.last()
{
if let Some(fighter) = fighter_assets.get(meta_handle) {
//if we havent started the chain yet or if we have input during chain window
if !chaining.has_started || chaining.continue_chain && chaining.can_extend {
chaining.has_started = true;
chaining.can_extend = false;
if !chaining.has_started {
chaining.has_started = true;
animation.play(Chaining::ANIMATION, false);
}
// Start the attack from the beginning

animation.play(Chaining::ANIMATION, false);
//if we are on chain followup, skip the first frame of the animation
if chaining.continue_chain {
animation.play(Chaining::FOLLOWUP_ANIMATION, false);
animation.current_frame = 2;
chaining.continue_chain = false;
chaining.link += 1;
if chaining.link >= Chaining::LENGTH {
chaining.transition_to_final = true;
}
}
chaining.can_extend = false;

let mut offset = attack.hitbox.offset;
if facing.is_left() {
offset.x *= -1.0
}
offset.y += fighter.collision_offset;
// let attack_frames = attack.frames;
// Spawn the attack entity
let attack_entity = commands
.spawn_bundle(TransformBundle::from_transform(
Expand Down Expand Up @@ -990,8 +993,7 @@ fn chaining(
// Reset velocity
**velocity = Vec2::ZERO;

// Do a forward jump thing
//TODO: Fix hacky way to get a forward jump
//move forward a bit during active frames
if animation.current_frame > attack.frames.startup
&& animation.current_frame < attack.frames.recovery
{
Expand Down
4 changes: 0 additions & 4 deletions src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,6 @@ pub struct AttackMeta {
pub item_handle: Handle<ItemMeta>,
}

// pub struct AttackChainMeta {
// pub attacks: AttackMeta
// }

#[derive(TypeUuid, Deserialize, Clone, Debug, Component)]
#[serde(deny_unknown_fields)]
#[uuid = "5e2db270-ec2e-013a-92a8-2cf05d71216b"]
Expand Down

0 comments on commit e22613c

Please sign in to comment.