Skip to content

Adds 3 new animations sprite sheets replaces sword swing.#133

Merged
LiquidityC merged 2 commits into
devfrom
new_animations
Oct 10, 2025
Merged

Adds 3 new animations sprite sheets replaces sword swing.#133
LiquidityC merged 2 commits into
devfrom
new_animations

Conversation

@LiquidityC

@LiquidityC LiquidityC commented Oct 10, 2025

Copy link
Copy Markdown
Member

The Explosion and tripple swing animations still need to be implemented.

Summary by CodeRabbit

  • New Features

    • Skills now display dedicated animations during use (including the FLURRY skill), and these animations render and update per frame for smoother, coordinated effects.
    • Sword attack visuals upgraded with larger, higher-resolution frames for a clearer, more detailed swing.
  • Chores

    • Under-the-hood support added to manage per-player skill animations and resource cleanup.

@coderabbitai

coderabbitai Bot commented Oct 10, 2025

Copy link
Copy Markdown

Walkthrough

Adds per-player skill animation lifecycle management, a new Animation *animation field on Skill, and updates skill creation/use and player code to create, copy, render, update, and destroy skill-specific animations; also adjusts sword sprite frames from 16×16 to 32×32.

Changes

Cohort / File(s) Summary
Player: skill animation lifecycle & sprite sizing
src/player.c, src/player.h
Added LinkedList *skillAnimations to Player; introduced update_skill_animations(Player*), render_skill_animations(Player*, Camera*), and destroy_skill_animations(LinkedList*); use_skill signature changed to use_skill(Player*, Skill*, SkillData*) and call sites updated; when a skill with an animation is used, sword animation position/flip/angle are copied into a new skill animation which is started and appended to player->skillAnimations; player_create initializes skillAnimations = NULL; sword animation frame clips changed from 16×16 to 32×32; rendering now calls render_skill_animations; destruction cleans up the list.
Skill: animation field, flurry wiring, and destruction
src/skill.h, src/skill.c
struct Skill now includes Animation *animation and animation.h is included; create_default initializes animation = NULL; destroy frees skill->animation if present; create_flurry signature changed to create_flurry(Camera *cam) and now creates/attaches an Animation to the FLURRY skill and wires tooltip creation there; removed direct runs of data->player->swordAnimation from skill_use_flurry in favor of the skill's animation.
API call-site updates
src/**/*.c (player skill use call sites)
All internal call sites were updated to the new use_skill(Player *player, Skill *skill, SkillData *skillData) signature and now pass the player context where skills are invoked.

Sequence Diagram(s)

sequenceDiagram
    participant Player
    participant Skill
    participant Animation
    participant SkillList as Player.skillAnimations
    Note over Player,Skill: Skill is used with Player context
    Player->>Skill: use_skill(Player, Skill, SkillData)
    activate Skill
    alt Skill has Skill->animation
        Skill->>Animation: clone/copy transform (pos/flip/angle)
        activate Animation
        Animation-->>Skill: started animation instance
        Skill->>SkillList: append(animation instance)
    else no animation
        Skill-->>Player: perform non-animated effect
    end
    deactivate Skill

    Note over Player,SkillList: Per-frame loops
    Player->>SkillList: update_skill_animations()
    Player->>SkillList: render_skill_animations(Camera)
    Note over Player,SkillList: On player destroy
    Player->>SkillList: destroy_skill_animations()
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

I twitch my nose, a new trick spun,
A blade that dances, doubled-on.
Skills now carry their own bright spark,
I stash the frames, then watch the mark.
Thump-thump—commit, the rabbit’s arc. 🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Title Check ⚠️ Warning The pull request title claims to add three new animations and replace the sword swing, but the diff primarily introduces a skill animation management framework and only resizes the existing sword animation without implementing the additional explosion and triple-swing assets mentioned. Please revise the title to reflect the main changes by highlighting the new skill animation lifecycle functions and the sword swing animation resize, for example “Add skill animation management and update sword swing clip to 32×32.”
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch new_animations

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

The Explosion and tripple swing animations still need to be implemented.
@LiquidityC LiquidityC changed the title Adds 3 new animations and replaces sword swing. Adds 3 new animations sprite sheets replaces sword swing. Oct 10, 2025
Also implements the flurry animation

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
src/player.h (1)

104-105: Clarify ownership of Animation pointers stored here

Add a short comment noting nodes hold borrowed Animation* owned by Skill; list frees nodes only.

src/player.c (1)

480-490: List cleanup is adequate

Nodes-only free is correct since Animation* is owned by Skill. Consider nulling caller’s head if reused, but not required here.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 09f821c and d7e6722.

⛔ Files ignored due to path filters (1)
  • assets/Extras/TrippleSwing.png is excluded by !**/*.png
📒 Files selected for processing (3)
  • src/player.c (8 hunks)
  • src/player.h (1 hunks)
  • src/skill.c (6 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
src/player.h (2)
src/skill.h (4)
  • struct Player (29-29)
  • struct Skill_t { (51-63)
  • struct SkillData_t { (45-49)
  • struct Skill_t (61-61)
src/animation.h (1)
  • struct Animation (38-47)
src/player.c (3)
src/animation.c (3)
  • animation_update (45-76)
  • animation_render (78-86)
  • animation_run (96-100)
src/linkedlist.c (1)
  • linkedlist_append (61-77)
src/skill.h (1)
  • struct Skill_t { (51-63)
src/skill.c (2)
src/tooltip.c (1)
  • tooltip_create (122-129)
src/animation.c (4)
  • animation_create (25-37)
  • animation_load_texture (39-43)
  • animation_set_frames (88-94)
  • animation_destroy (110-116)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: Mac (GCC)
  • GitHub Check: Analyze (c-cpp)
  • GitHub Check: Ubuntu (Clang)
  • GitHub Check: Mac (Clang)
  • GitHub Check: Ubuntu (GCC)
  • GitHub Check: Ubuntu (mingw)
  • GitHub Check: Windows (MSVC)
🔇 Additional comments (11)
src/skill.c (4)

310-312: Good: initialize new animation member

Setting skill->animation = NULL avoids UB.

Confirm struct Skill in src/skill.h contains Animation *animation; otherwise this won’t compile.


1039-1040: Good: delegate FLURRY to cam-aware factory

Keeps tooltip/animation encapsulated.


1098-1100: Good: free animation on skill destruction

Prevents leaks.


437-467: Flurry animation wiring verified: the texture file assets/Extras/TrippleSwing.png exists and matches the code.

src/player.c (7)

445-467: Animation list updater is fine

Removes finished nodes; no double-free of Animation*. LGTM.


469-478: Render hook looks good

Iterates and renders active skill animations. LGTM.


589-593: Sword swing frames updated to 32×32: LGTM

Clip sizes, loop=false, dim and rotation point match new asset.

Also applies to: 598-599


689-690: Init skillAnimations

Explicit NULL init is fine.


802-803: Top-layer render integration

Renders sword then per-skill animations. LGTM.


856-856: Update hook added

Advances skill animations each tick. LGTM.


889-891: Cleanup on destroy

Frees list nodes after skills/animations are destroyed. LGTM.

Ensure no code after this dereferences player->skillAnimations; if reused, set to NULL post-destroy.

Comment thread src/player.c
Comment on lines +492 to 513
static void
use_skill(Player *player, Skill *skill, SkillData *skillData)
{
skill->active = false;
skill->use(skill, skillData);
if (skill->actionRequired)
action_spent(skillData->player);
skill->resetCountdown = skill->resetTime;

if (skill->animation) {
Animation *a = skill->animation;

// Copy the orientation and position of the sword animation for the skill animation
// \see player_turn
a->sprite->pos = player->swordAnimation->sprite->pos;
a->sprite->flip = player->swordAnimation->sprite->flip;
a->sprite->angle = player->swordAnimation->sprite->angle;

animation_run(a);
linkedlist_append(&player->skillAnimations, skill->animation);
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Fix: don’t spend action/cooldown or start animation on failed skill use; also dedupe animation entries

Respect the boolean return from skill->use. Only on success: set active=false, spend action, set cooldown, and start/append animation. Also avoid appending the same Animation* multiple times (causes double update/render).

Apply:

 static void
 use_skill(Player *player, Skill *skill, SkillData *skillData)
 {
-    skill->active = false;
-    skill->use(skill, skillData);
-    if (skill->actionRequired)
-        action_spent(skillData->player);
-    skill->resetCountdown = skill->resetTime;
+    bool used = skill->use(skill, skillData);
+    if (!used) {
+        // Keep skill active on failure so the player can retry (esp. directional skills)
+        return;
+    }
+    skill->active = false;
+    if (skill->actionRequired)
+        action_spent(skillData->player);
+    skill->resetCountdown = skill->resetTime;
 
-    if (skill->animation) {
+    if (skill->animation) {
         Animation *a = skill->animation;
 
         // Copy the orientation and position of the sword animation for the skill animation
         // \see player_turn
         a->sprite->pos = player->swordAnimation->sprite->pos;
         a->sprite->flip = player->swordAnimation->sprite->flip;
         a->sprite->angle = player->swordAnimation->sprite->angle;
 
         animation_run(a);
-        linkedlist_append(&player->skillAnimations, skill->animation);
+        // Avoid duplicate entries for the same animation instance
+        bool present = false;
+        for (LinkedList *it = player->skillAnimations; it; it = it->next) {
+            if (it->data == a) { present = true; break; }
+        }
+        if (!present) {
+            linkedlist_append(&player->skillAnimations, a);
+        }
     }
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
static void
use_skill(Player *player, Skill *skill, SkillData *skillData)
{
skill->active = false;
skill->use(skill, skillData);
if (skill->actionRequired)
action_spent(skillData->player);
skill->resetCountdown = skill->resetTime;
if (skill->animation) {
Animation *a = skill->animation;
// Copy the orientation and position of the sword animation for the skill animation
// \see player_turn
a->sprite->pos = player->swordAnimation->sprite->pos;
a->sprite->flip = player->swordAnimation->sprite->flip;
a->sprite->angle = player->swordAnimation->sprite->angle;
animation_run(a);
linkedlist_append(&player->skillAnimations, skill->animation);
}
}
static void
use_skill(Player *player, Skill *skill, SkillData *skillData)
{
bool used = skill->use(skill, skillData);
if (!used) {
// Keep skill active on failure so the player can retry (esp. directional skills)
return;
}
skill->active = false;
if (skill->actionRequired)
action_spent(skillData->player);
skill->resetCountdown = skill->resetTime;
if (skill->animation) {
Animation *a = skill->animation;
// Copy the orientation and position of the sword animation for the skill animation
// \see player_turn
a->sprite->pos = player->swordAnimation->sprite->pos;
a->sprite->flip = player->swordAnimation->sprite->flip;
a->sprite->angle = player->swordAnimation->sprite->angle;
animation_run(a);
// Avoid duplicate entries for the same animation instance
bool present = false;
for (LinkedList *it = player->skillAnimations; it; it = it->next) {
if (it->data == a) {
present = true;
break;
}
}
if (!present) {
linkedlist_append(&player->skillAnimations, a);
}
}
}
🤖 Prompt for AI Agents
In src/player.c around lines 492 to 513, the code ignores the boolean return
from skill->use and always spends action, sets cooldown, and starts/appends the
animation (which can be appended multiple times). Change the flow to call
skill->use(skill, skillData) and store its bool result; only if true: set
skill->active = false, call action_spent(... ) when actionRequired, set
resetCountdown, run the animation and append it. When appending, first check the
player's skillAnimations list to avoid adding the same Animation* twice (skip
append if already present). If skill->use returns false, do none of those side
effects.

@LiquidityC LiquidityC merged commit a3b19d2 into dev Oct 10, 2025
10 checks passed
@LiquidityC LiquidityC deleted the new_animations branch October 10, 2025 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant