The movie analogy

June 4, 2018

Here in Stockholm it's been unusually hot and dry for this season of the year and I'm quite convinced that the pharmacies have broken a new record in anti-histamine sales. Last night we were finally blessed with thunder and rain and today the air is cool and nice and the pollen gone. 


I've sneezed quite a lot the last couple of weeks but I've also done some coding. My primary focus has been building an animation framework for use in intro, cutscenes and background movements and coding an editor for animating sprites. Ester (Eraserhead animation editor) will be the subject of an upcoming dev log and this dev log will be about the animation framework.


This is an animation demo and not part of the game


Animation framework

The purpose of the animation framework is to ease setting up and running sequences of multiple animations. The need for this arose with my desire to create an animated intro with objects moving in different patterns. But I will also use this framework for pre- and post-fight-animations as well as background animations.


When finished the animation framework will contain:

  • Support for spritesheet-based animations

  • Builders for setting up animations by code

  • Simple script-language for setting up scenes

  • Loader and parser for script-files

In addition to this, I will probably build an editor to use with the script-language for trying out and previewing animations.

The movie analogy

When designing and naming the building blocks of the framework I've taken a "movie scene"-approach and used a nomenclature found in movie scripts. That gave me following main classes:

  • Scene

  • Actor

  • Action

  • Animation

"Animation" might not be a name known from movie scripts, but I kept the name to encourage its use outside of the "animated scene" context. As long as you keep track of calling the update- and draw-methods both actors and animations can be used without a scene.


This is a simplified diagram describing the relationships between the classes:




Think of a scene just the like a scene in a movie or a theater. It's a "room" where something takes place. A scene can have a name, background image and any number of actors. You draw it on the screen by calling its Draw-method.


 Background for our demo



Unlike in a movie or theater, an actor is not only characters but all things living or dead that has it's own image and is separate from the background e.g. character, bullets flying, rising sun. 


An actor has a location, it can be visible or hidden, and has a collection of actions to perform that can be looped when done. An actor also has an animation as it's current "gesture".

Just like in the movies, an action is something an actor does, i.e. an actor will act according to its actions.


Some of the available actions are:

  • Show - draw animation 

  • Hide - don't draw animation

  • SetPosition - set position of actor

  • BasicMove - move actor to destination with given velocity and acceleration

  • ChangeGesture - change animation


An anima