Coding demos is all about having fun. It’s a hobby and therefor it should be as pleasant as possible.
Demo is a combination of frameworks, effects, graphics and sound. Handling all of that data isn’t an easy task. It can turn into a very neglectful pile of code and in worst scenario list of foolish performance costly if-statements.
When coding a demo the main focus is always on effects. That’s what you wanna do. When the right moment comes you want to get straight to the business. This often leads to situation where you just create a class, setup assets and run things on your EnterFrame event. You’ll end up with pile of classes that have a lot of similarities and it’s a pain in to ass to construct a demo from them. You’ll end up coding everything twice or you just realize that it’s not worth it and play the “no demo this year”-card.
My opensource demo engine evoTinyEngine is designed to serve two goals:
Maximum performance and effect creation efficiency.
It has three elements: Assets, Engine and Modifiers.
Idea is that you create Modifiers that use stuff from Assets to draw into a shared bitmapdata. The engine manages the Modifiers by initializing, calling their render method, providing essential data like time and dispose Modifiers when they are no longer needed. All this happens in a periods of 16th note beats.
This way you separate sequencing from effect creation. You just create effects(=Modifiers) and when the time comes for building them all together it’s easy and another fun phase of demo creation. You can run multiple Modifiers at the same time and they can have four roles:
1. preprocessing // first render
2. effect // second render
3. postprocessing // third
4. overlay // last
I rarely use the preprocessing. It’s there for to give possibility to stack two main effects together in desired order. Effect is an effect and postprocessing comes after that. Those can be radial blurs, blooms or some distortion effects, what ever. Overlay is for overlay graphics or texts that you don’t want to be affected by postprocessing.
Read this pdf to get more detailed information.
Here’s the hello world code:
assets = new
engine = new TinyEngine(assets);
engine.addModifier(new ModifierPixels(assets), 0, 64);
engine.addModifier(new ModifierMandel(assets), 64, 256);
engine.addModifier(new ModifierBloom(assets), 256, 512);
It has been used in Severity of Grey and Blockparty 2010 invtro. Happy coding.