demoth / jake2

Quake 2 java port
GNU General Public License v2.0
59 stars 9 forks source link

Rework monster animation code #73

Open demoth opened 2 years ago

demoth commented 2 years ago

Move the enormous descriptions of the animation from the source code (for example in M_Soldier.java) into a resource file. For example json?

Upd. 2024: After reviewing of what is done and what is still achievable, it makes sense now to settle on what is already implemented in the scope of the animation rework and if necessary improve later.

The biggest understanding now is that the decision making solution (which was previously tied to the animation and monster logic) can be done outside of the initial scope of this task (moved to Rework monster decision code #109).

New approach: Animation is controlled with the state machine. Each state is an animation sequence which can either loop or transition to another state. The transition rules govern which transitions are allowed. The character can interact with the game world (or with itself) via events, which are emitted in certain frames (for example sounds and firing projectiles). An excerpt from the new animation definition:

        AnimationSequence(
            name = "fidget",
            type = StateType.IDLE,
            frames = (1..49).toList(),
            events = mapOf(0 to "sound-fidget"),
            loop = false,
            nextState = "stand"
        ),
        AnimationSequence(
            name="pain",
            type = StateType.PAIN,
            frames = (100..109).toList(),
            events = mapOf(1 to "sound-pain"),
            loop = false,
            nextState = "stand"
        ),
demoth commented 11 months ago

Actively working on it, merged a preview for animation and states (merged at 6bd10334d758da9b691f327356cd2206a3b34bee)

demoth commented 11 months ago

At first, let's refactor to a readable solution in code, then we can think of a non-code way for animation description