Category Archives: Game development

Space background generator

Lately I have been spending time on my Meteor Loop concept game. A big part of what I have been doing is the procedurally generated backgrounds. I really like what I have come up with, and some of the screenshots look great.

The actual game is in no state to show at the moment, but I really wanted to show how the background is coming along. So I decided to split it out into a stand alone project, so you can see it. Take a look here:

Click the “Generate new” button in the upper left settings panel to generate a new background with a new random seed. Have a go at changing the colour to see what it looks like.

Meteor Loop procedurally generated backgrounds

Meteor Loop is an Asteroids style space game that I am working on in my spare time. I know, doesn’t sound very original. It seems like everyone has to make an Asteroids clone at some stage. Personally I have made at least 4 different versions now. I always use Asteroids as a project to really try out a new language or library.

But this post is not really about Meteor Loop. I will do that post later. This is just an update to specifically show the dynamically generated backgrounds that I will use in the game.

Every level will have a different randomly generated background. Here are just a few screenshots of my favorites:

The game is being built using Flash, with ActionScript 3. I am using Away3d for the planets, and perlin noise for the cloud background and star distribution.

To generate the background, I start with a random seed. I use the seed to grab a random colour from a selection of predefined colours. Then I randomly choose the size, number of subdivisions, position, and rotation speed of the planet. I create the sphere using Away3d 3.6, with just a colour material. I also duplicate the sphere, but with a wireframe material, and scale it up a little, so it creates sort of an atmosphere.

For the clouds and star I create some perlin noise data using the BitmapData’s perlinNoise function, and tint it with the same colour as before. I create a second perlinNoise bitmap with a smaller numOctaves and use it to calculate where the stars should be. I simply did “the higher red channel value a pixel has, the higher chance I draw a star there”.

To add a bit more variation and interest, I then created a gradient overlay with its blend mode set to OVERLAY. This gives the background clouds a nice range of punchy colour, and some nice empty black areas for the stars to shine through a bit more.

I spent quite some time tweaking numbers of the algorithms, and I think I could easy find some more numbers to play with. Let me know what you think of these screenshots so far.

UPDATE: Check out the live version of my Space background generator.

LD 24 theme voting game ideas

As I anxiously await the start of Ludum Dare #24, I find my brain firing off in all directions with game ideas, art styles, programming techniques, and mechanics etc. So thought I would give my brain something to do, and jot down some game ideas based some of the interesting themes from each voting round.

Round 1:

All the themes I voted on this round seem related: Dim LightsGhostsNightSurvive, and Trapped in Another World.

Light the maze

Place a limited number of lights throughout a maze to light the way. You must light the entire path continuously from the start to the end. You could be a player running around the maze with a small lantern, placing torches on the walls. You can pick the torches up again if you like. Maybe you are lighting the maze for someone else to get through, who will start walking after a time limit. If they walk through the dark, they might get lost and attacked by ghosts.

Round 2:

AbstractCompanionCreation and Destruction, Secret World, Self Destruction, and Symmetry.

Split identity

Start by controlling a character through a level, then when you get to a point, the screen splits into two. Now you control both characters, but with exactly the same controls, but each is in a different level. It could then split into four and maybe more. You would have to get all characters to the ends of there levels.

Round 3:

Antique, Colony, Confined, Explosion, and Parallel Worlds.


You pilot a steampunk helicopter that must use a dangling rope to hookup parts to assemble something. You can then equip the thing you just built, and use its ability.


You can phase between two different worlds that share similar structures of the level. Enemies can only exist in one of the worlds. Your gun teleports them into the other world. You must solve puzzles in both worlds, so make sure you don’t teleport too many enemies to either of the worlds. The gun could actually just stun the enemy, but also make a copy of it in the other world, so the more you use the gun, the more enemies that will be waiting for you in the other world.

Round 4

Break the Rules, HopelessInevitability, Plague, and Wilderness.

Possum control

There is a virus outbreak in the possum population, that can also spread to humans. Use any means necessary to wipe out all the possums. The most effective way is to dump 1080 poison in the bush, but after the backlash of using it in the wild, it is in short supply. You must also balance other methods, such as controlled bush fires, hunting squads, traps, and releasing predators. You goal is to destroy every last possum, without causing too much damage to the environment.

I will continue updating this post as more voting rounds happen.

On-screen joystick with Gamepad-haxe

Only a few days after I tweeted about porting Gamepad over to haXe, I see a tweet from Philippe Elsass saying he has added an on-screen joystick to the library. This is great, because it was the next thing on my list after sorting out some issues with getting accelerometer data from my Android device with NME. Open-source is fantastic btw!

I just merged this update with my main branch on GitHub and had a good play, so thought I would give a quick run down on how to use it. Philippe has done a great job, so it’s pretty simple, but even looking at his code has taught me quite a bit about haxe.

First thing you need a Gamepad instance

[actionscript3]var gamePad:Gamepad = new Gamepad(stage, false, 0.4);[/actionscript3]

Then you need something to control with the joystick, a Car possibly:

[actionscript3]var car:Sprite = new Sprite();, 1);, -50, 50, 100);;
car.x = 300;
car.y = 200;

Before we can create the on-screen joypad, we need to get some graphics ready to use for the controls. We need a background and a thumb to touch or click on and drag around.

[actionscript3]var thumb:Sprite = new Sprite();;,25,25);
var bg:Sprite = new Shape();, 0.3);, 50, 50);[/actionscript3]

Now we can add the on-screen joypad and pass the gamepad, and the two graphic assets to it.

[actionscript3]var gamePadView:OnScreenJoystick = new OnScreenJoystick();
gamePadView.init(gamePad, 50, thumb, bg);
gamePadView.x = 440;
gamePadView.y = 330;

So now we have everything set up that we need. All we need to do is handle the update tick. The OnScreenJoystick needs its update method called to keep it in sync with the Gamepad. The OnScreenJoystick will automatically update the Gamepads properties, so we can use the Gamepad the same way we always do from this point.

[actionscript3]private function onTick():Void

car.rotation += gamePad.x * -gamePad.y * 2;

var carAngle:Float = -car.rotation * (Math.PI / 180);
car.x += Math.sin(carAngle) * gamePad.y * 5;
car.y += Math.cos(carAngle) * gamePad.y * 5;

Now when you run the app you should have a car that you can drive around with your on-screen joystick. Easy!

All this example code is either from Iain Lobb’s original Gamepad testers or from Philippe Elsass’ modifications for the on-screen joystick. You can have a play for yourself with the Gamepad example tests, or get the source, which comes with the tests.