Background Animation System

BlitzPlus Forums/BlitzPlus Programming/Background Animation System

Yeshu777(Posted 2007) [#1]
This is a quick system for having randomly occuring animations on a static background in your game using image strips.

Thought it may be of use to some and hopefully improved.

Here's how it works.

First create a text file (using wordpad or similar) with the following information:

Path to Anim Strip Image
Id No.
No. of Frames
Frame Width
Frame Height
x_position on background
y_position on background
Animation Speed
Occurance Chance

If you set "Occurance Chance" as 0 it will not animate randomly - instead you can use the function ForceAnimation(id) to start off the animation.

Useful if you want to trigger an animation as a player moves past a certain part of the background.

So your config file would look like this:

gfx\back\tile1.bmp
1
28
124
76
59
376
60
5

gfx\back\tile2.bmp
2
22
115
117
96
252
50
20


And so on, for how many different entities are to be animated. Be sure to leave a blank line between each entity.

Save this as test_cfg.txt

Here is the code that processes the text file and contains the functions that will sit in your main game code.

Save this as bg_anim.bb



Here is how it is implemented in the main game:



If you want to add more animated entities then you can just add to the config file leaving the game code untouched.