Blitter and Bob Game Objects

Published on 18th November 2016

image

This week's newsletter almost never happened. I spent most the week unable to code or do much work, and returned back to normality just today, Friday, the day the newsletter is sent. Before I fell ill the week started out really well, and I managed to complete two things ...

Phaser 2.7 Special Release

Last issue I ran a survey asking if I should release Phaser 2.7, or just carry on development of Phaser 3. Over 130 of you completed the survey and 74% said to ignore 2.7, and carry on with Phaser 3.

Also, 94% of you said you didn't have a game on hold due to a bug in Phaser 2.6, which was quite reassuring to be honest :) Taking both of these facts in to consideration my first thought was to ignore 2.7 totally. As the overwhelming majority of you didn't need it. However, I guess you could also look at the stats the other way, which shows that 26% of you did want 2.7, which is over a quarter. So I came to the decision to release it into its own git branch.

You can download Phaser 2.7 from GitHub.

There won't be an "official" release of it, nor will it get pushed out to the CDNs or npm. Consider it an interim build for those of you who needed it, and can't wait for Phaser 3. As it stands though, it has a bunch of fixes in, and some new features. The README has all the details as usual.

Phaser 3.0 Blitter

At the start of the week I created a new Game Object called a Blitter. The concept behind it is painfully simple: it's a single Game Object which has one sole task: to render texture frames as fast as it can. You can add as many different items to it as you want (internally they are called BOBs, or Blitter Objects, and yes I'm fully aware of the Amiga connotations here), and each one can be positioned and transformed, but that is it. Here are a bunch of them in action:

image

Think of a Bob as being a texture frame you can render, and nothing more. They don't have update loops, they don't even live on the core display list, they don't have Data components, or pretty much anything at all really.

The whole idea behind them is that they aren't Game Objects, in the sense that they take up none of the same resources a Game Object does, or have the same properties. They're ultra-light weight. In lots of frameworks they're called Particles, but I didn't want to confuse things as Phaser devs are used to Particles belonging to a Particle Emitter.

In practise you create a single Blitter object, which itself has an entry on the display list (and can be rotated, scaled, and so on). You then use a handful of helper methods to create Bobs within it, and they render away happily. It uses a custom batch and shader, with minimal vertex data being sent. In short, they're fast little buggers. Out of sheer interest I tried creating a Tilemap renderer using them, and with 1900 of them on-screen (each an 8x8 tile), and scrolling around a huge map, it was still blissfully fast and completed in a single draw call. I probably won't use them for the Tilemap system, as we've got a custom shader written for that, but it was a great stress test all the same :)

I really wanted to make a new video this week. I also wanted to test multiple WebGL renderers on the same page, and do some mobile performance tests, but sadly illness put paid to that. Next week however there will be lots of things to show, so make sure you're here :)

image

This week's newsletter almost never happened. I spent most the week unable to code or do much work, and returned back to normality just today, Friday, the day the newsletter is sent. Before I fell ill the week started out really well, and I managed to complete two things ...

Phaser 2.7 Special Release

Last issue I ran a survey asking if I should release Phaser 2.7, or just carry on development of Phaser 3. Over 130 of you completed the survey and 74% said to ignore 2.7, and carry on with Phaser 3.

Also, 94% of you said you didn't have a game on hold due to a bug in Phaser 2.6, which was quite reassuring to be honest :) Taking both of these facts in to consideration my first thought was to ignore 2.7 totally. As the overwhelming majority of you didn't need it. However, I guess you could also look at the stats the other way, which shows that 26% of you did want 2.7, which is over a quarter. So I came to the decision to release it into its own git branch.

You can download Phaser 2.7 from GitHub.

There won't be an "official" release of it, nor will it get pushed out to the CDNs or npm. Consider it an interim build for those of you who needed it, and can't wait for Phaser 3. As it stands though, it has a bunch of fixes in, and some new features. The README has all the details as usual.

Phaser 3.0 Blitter

At the start of the week I created a new Game Object called a Blitter. The concept behind it is painfully simple: it's a single Game Object which has one sole task: to render texture frames as fast as it can. You can add as many different items to it as you want (internally they are called BOBs, or Blitter Objects, and yes I'm fully aware of the Amiga connotations here), and each one can be positioned and transformed, but that is it. Here are a bunch of them in action:

image

Think of a Bob as being a texture frame you can render, and nothing more. They don't have update loops, they don't even live on the core display list, they don't have Data components, or pretty much anything at all really.

The whole idea behind them is that they aren't Game Objects, in the sense that they take up none of the same resources a Game Object does, or have the same properties. They're ultra-light weight. In lots of frameworks they're called Particles, but I didn't want to confuse things as Phaser devs are used to Particles belonging to a Particle Emitter.

In practise you create a single Blitter object, which itself has an entry on the display list (and can be rotated, scaled, and so on). You then use a handful of helper methods to create Bobs within it, and they render away happily. It uses a custom batch and shader, with minimal vertex data being sent. In short, they're fast little buggers. Out of sheer interest I tried creating a Tilemap renderer using them, and with 1900 of them on-screen (each an 8x8 tile), and scrolling around a huge map, it was still blissfully fast and completed in a single draw call. I probably won't use them for the Tilemap system, as we've got a custom shader written for that, but it was a great stress test all the same :)

I really wanted to make a new video this week. I also wanted to test multiple WebGL renderers on the same page, and do some mobile performance tests, but sadly illness put paid to that. Next week however there will be lots of things to show, so make sure you're here :)