Category Archives: The BackfirE Games

Headers have become BLOATware

Headers. This finely tuned instrument – this Stradivarius of programming – this final frontier against the total apocalypse of Java – is starting to fall apart.

Let us face it. No one reads the manual first, but dorks – and those of us who occasionally gets in doubt. That does not mean a manual is not a good idea. It just means, that the manual should not be at the top of the package, or glued to our foreheads. You should not be forced to read the manual on the program selector, each time you want to change the channel on your TV, or read the manual on how to operate Safari, each time you want to read the news. That would quickly get pretty annoying.

None the less, this is that what is happening to one of the most powerful tools of C programming. The headers.

A good header is invaluable, and alone for that reason, I will always despise Java. A good header tells you at a glance what a class contains, and what it can do. Naming conventions. Order of appearance, and even subtle things like spacing or spacers, will guide the reader through the class, and present him with – the essence of it all – right there at his fingertips.

Unfortunately somebody got the idea, that if we inserted the documentation into the header file, he could write a small script, and the documentation would be “for free”. What a load of … Not only are you without any kind of formatting when writing the documentation, you also ruin your header, and will have to spend countless hours, trying to figure out, why the auto generated piece of cr.. does in no way look like what you had pictured in your head. The idea ranks amongst the worst ideas in human history. It is that bad.

So do humanity a favor, and start writing the documentation as it is supposed to be. In a separate file.

Parallax and defomable terrain

I am working on some serious stuff, including a lot of parallax layers, and a deformable terrain. Screenies below.

Right now, I apply brute force fragment shaders, rendering a total of 8 textures in one pass. This sound efficient, but it really isn’t. While it runs 60fps on ipad2 and 3 ( retina ), and somewhat slower on ipad1, the problem is, that I render way to many transparent pixels. Even if parallax 2 only is 5% visible at the bottom, I render a nearly entire blank screen of parallax 2, because I am forced to render only one piece of geometry. While mix( ) is insanely fast, with 8 full screens of textures, things will eventually start to slow down.

And then it struck me.

The parallax should be split into 5 quads, each being a band of overlapping parallax layers. First quad will be pure skybox. Second quad will be skybox and far most parallax. Third quad will be etc etc etc etc. If you adjust you parallax textures to include fewest possible transparent pixels, this will render it all, with an absolute minimum of pixel operation.

You of course have to write 5 shaders, in stead of one shader, but that is a small price to pay.

All the images below, is rendered in a single quad.

Enjoy the landscapes.

The earth crust is made with inspiration from a demo I watched, and is fully deformable, meaning that if I dig a hole into the ground, the grass will disappear. Not by magic, but by the insane power of the shader.
I did some math, and calculated that I could save 35-80% of all texture look-ups ( currently the shader does 25.2M look-ups pr frame )
The final picture shows how I plan to implement it. The picture is a bit fuzzy, but so is my ideas on how to implement this also.

Deformable terrain

No one would have believed in the first years of the twenty-first century, that this world was being simulated keenly and closely by intelligences greater than man’s and yet as mortal as his own – chipmunks.

In this project, I am trying to simulate a flexible and deformable terrain, using the outstanding physics engine Chipmunk Pro. That thing is a mighty powerful piece of software.

The basic idea is to do deformations to a bitmap image, and then scan the outline to make terrain.

The image is made with a CGBitmapContext, which allows very fast read and write access, while still having resonable render performance. The stuff we will be rendering to deform the terrain, are pretty simple anyways. First the context is filled with an image from file, represented the undistorted terrain. This image is then used by a ChipmunkContextSampler, to return he outline of the terrain for physics simulation. Various attributes can be applied  to the terrain, including smoothing. The sampler also supports sampling on blurred terrain, for real nice and smooth outputs.

Finally, a tile cache is added. It basically breaks the terrain down into smaller pieces, so that only parts of the terrain needs to be updated, when changes happen. Deformation is then made to the terrain, simply by drawing filled circles directly into the CGBitmapContext.

A demo project can be grabbed at Github.

The demo is provided as-is, but if you have questions, you can often find me in the cocos2D forum.


For two new projects, I am working with simulating water.

Basically, the water is simulated by tesselating an image into smaller fragments, and then adjusting texture coordinates accordingly. A ripple is created with a center, and texture coordinates are then adjusted in an expanding radius around this center.

How the formula is implemented, makes the ripple simulate various materials. If the center continues to bounce undampened up and down, the material will look like a rubber sheet. The quicker the center is dampened, the lower the viscosity will seem.

A demo project for iPhone, featuring the basics of this, can be found here. If you find it useful, let me know, and I will provide updates.


This is of course very basic, so there is plenty of room for improvements.

The demo project scans the entire surface for each ripple. Only vertices inside an ongoing ripple should be scanned. This reduces the number of calculations dramatically. Next, I have added vertex lighting to make the ripples easier to see, and to emphasize multiple ripples. This makes vortexes when swirling a finger, much more distinct.

Finally, I added caustics also using vertex lighting, and subtle vertex distortion. Both caustics and distortions are dynamic, and it is easy to see how the water settles, after having been stirred.

It still needs some tweaking, and final touches will be reflection highlights, and impurities in water ( small air bubbles etc )

It has been a while

I am getting close to finishing the free version of NightFlight.

The original 14 missions has been upped to 27, and split into 4 campaigns.


Attack of the Xercs

8 missions taking place over earth


Earth strikes back

8 missions taking place over their mothership



3 mixed missions ( the free version )


Battle on the moon

8 missions taking place on the moon

Apart from that, the interface has been completely revamped.

In stead of menus, everything is now controlled from inside the ESA88 spacecraft. Check out these interfaces.

And now for something completely different

To losen up my shoulders in between NightFlight work, I toyed with some of the technologies I want to implement in future games. First of all 2D physics.

For that I chose Objective Chipmunk. It integrates nicely into cocos2D, and is insanely easy to use. On top of that, it is fast.


The mermaid demo below, simulates 400 snowflakes in a low gravity water environment. The idea was to make a fairly accurate simulation, and not just let the snowflakes magically enter at the top, and magically disappear at the bottom.

The mermaid is a small script file, with image data, and information on where the snowflakes can land, so making new scripts is very very easy.


Runs between 20 and 30 FPS on a plain vanilla 3G.




Welcome to The BackfirE Games.

BackfirE is a newly formed company, developing applications for smartphones, and located in Svendborg, Denmark.

Currently we are completing our first title for the iPhone, an arcade shooter called Nightflight.


This blog will be that main portal for news about our games, support, FAQ’s and playguides. Because we are working hard on finishing Nightflight, the updates will probably be fewer in the start.