Skip to content

feat(animation): Animation System — sprite state machine, frame events (RF4.9)#63

Merged
LyeZinho merged 1 commit intomainfrom
30-animation-system
May 8, 2026
Merged

feat(animation): Animation System — sprite state machine, frame events (RF4.9)#63
LyeZinho merged 1 commit intomainfrom
30-animation-system

Conversation

@LyeZinho
Copy link
Copy Markdown
Member

@LyeZinho LyeZinho commented May 8, 2026

Summary

  • Implements RF4.9: Animation System with sprite-based state machine and frame events
  • Adds AnimationComponents.hpp (always compiled) and AnimationSystem.hpp (ECS ISystem)
  • 22 tests in test_animation.cpp covering defaults, transitions, frame math, imperative API

Files

File Change
src/animation/AnimationComponents.hpp New — FrameRect, AnimationClip, AnimationTransition, AnimationState, Animator
src/animation/AnimationSystem.hpp New — AnimationSystem : ECS::ISystem
tests/test_animation.cpp New — 22 tests, always compiled (no SDL3 dep)
src/Caffeine.hpp Animation includes added
tests/CMakeLists.txt test_animation.cpp added to base sources
docs/fase4/animation.md Status → ✅, API rewritten to match implementation
docs/fase4/README.md Animation row → ✅

Design Notes

  • onUpdate(World&, f32) matches actual ISystem interface (not update(World&, f64) from spec)
  • Sprite::frameIndex updated per frame (engine has no srcRect on Sprite)
  • HashMap<FixedString<32>, AnimationState> — works via operator== linear search
  • hasExitTime on transitions: waits for clip to finish before checking condition
  • Frame events fire every time the current frame index matches — lightweight, no allocation
  • Imperative API (play/pause/resume/setSpeed/isPlaying) takes World& + Entity — consistent with PhysicsSystem2D pattern

…(RF4.9)

- Add AnimationComponents.hpp: FrameRect, AnimationClip, AnimationTransition,
  AnimationState, Animator component (HashMap state machine, frame events)
- Add AnimationSystem.hpp: ECS::ISystem impl with onUpdate() iterating
  Animator+Sprite, state machine evaluation, frame advance, frame events
- Add test_animation.cpp: 22 tests covering defaults, state transitions,
  frame clamping/looping, pause/resume/setSpeed/play/isPlaying
- Update Caffeine.hpp with animation includes
- Update tests/CMakeLists.txt to always compile test_animation.cpp
- Update docs/fase4/animation.md (status ✅, API rewrite) and README.md
@LyeZinho LyeZinho linked an issue May 8, 2026 that may be closed by this pull request
4 tasks
@LyeZinho LyeZinho merged commit 1e2e05d into main May 8, 2026
1 check passed
@LyeZinho LyeZinho deleted the 30-animation-system branch May 8, 2026 15:48
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.

Animation System

1 participant