Programming animation

Besides some artistic advantages, the sprite animation is not ideal: it is hard to readjust or rearrange quickly, it can take some memory resource, and it is not flexible enough. Therefore, in some situations, it is much more efficient to program some animations by code. The most obvious example is the wheels of a vehicle used in a game: nobody uses special frame-by-frame animation to rotate them, a simple code is used instead. Even characters can be animated using such methods; of course it is pretty hard, but it is possible (recall the description of a Spine animation editor from Chapter 1, Starting the Game). By using code, you control the general properties of an image: coordinates, scale, rotation angle, opacity, and even hue. So many things can be created.

Usually, most of the special effects in games are programmed. The most visual example is, of course, the simulation of smoke. To develop good smoke, only one small sprite is needed, containing an image of one smoke curl. A game should take such a curl, display it, and begin to move up constantly, rotating and increasing its dimension while its opacity value is decreasing. The life cycle of the curl looks simple: appear, fly up, and disappear. There should be dozens of such elements, each of them born with some random properties as the initial size, the direction of rotation, and opacity. By tuning the behavior of the curls and playing with their graphic look (a sufficiently blurred image is considered good), a convincing simulation can be created. You also need to have passion to make it look good.

Other type of effects based on particles should be programmed as well. Among popular examples are dynamical clouds, fire, lens flare, sparkles, fireworks, flinders of objects after a hit, caustics (a pattern made on the surface of water), snow, rain, and foot prints. There are special particle engines for popular SDKs; nevertheless, in most cases, they can be developed manually. It looks like an interesting creative challenge. It is worth mentioning that the effect should not look super realistic. It all depends on the game's mood and graphic style; in most cases, it only needs to express an essential idea such as as open fire or falling snow.

In 3robopainter, there are several programmed animations:

  • Dust clouds at the moment of landing on a platform. Some sort of smoke algorithm with a very short life cycle can be used.
  • Bubble rotation after the protagonist has made a shot.
  • The effect of fallen water from a pipe. A seamless texture with a zig-zag pattern can be used. It is good to bake an image with a distorted background (sky with some clouds) in the texture to simulate the deflection of light in a waterfall
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.142.166