0
\$\begingroup\$

I stumbled into a weird situation during development of my game prototype. It's about turn-based battle, and I want battle animations to finish before the next command is issued.

The first approach to register some effect:

  • Character notes his HP <= 0 and sends OnCharacterDidDie event
  • The BattlefieldView shows a DeathEffectAnimation (for simplicity, think: explosion) that takes 2 seconds, for example

Before the animation is finished, the battle would end if the last character dies. While playing animations in a non-blocking way sounds neat at first, that result is not desirable. Taking damage may still be non-blocking, but character death should be blocking. (I think it feels more impactful if everyone pauses for a second, too.)

My revised approach is to split the perceived game event into multiple notifications:

  • Character notes his HP <= 0 and sends OnCharacterDying event
  • The BattlefieldView shows a DeathEffectAnimation that takes 2 seconds, for example
  • DeathEffectAnimation sends OnAnimationDidComplete when it's done doing its thing
  • Something waits for this and sends a OnCharacterDidDie effect

I can imagine the character to initiate a DeathSequence object that encapsulates the event sequence and its progression.

But all that feels weird because now the OnCharacterDidDie events depends not on the effect to the model object, but on an animation. This is not a very "clean" separation.

Is the only way out to increase the complexity now and go with something like Entity--Component so the Character object doesn't know everything it needs to do directly?

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.