Gaming Your Way

May contain nuts.

Let's have some UI in there

The past couple of days I've been working on some of the UI aspects of the game, the level complete sequence in this case.

I thought adding a star rating would be a nice touch, adds a bit of replay ability and enables me to add a simple achievement or two. Little did I know what a complete ball ache it was going to be.

I wanted to use Away3D to display it as I wanted perspective on the panel. In the main game the camera is constantly rotating around, so I thought I'd just figure out where the camera is looking and position the panel relative to that, updating it's position every frame so it appeared static.
Simple in theory, but totally beyond me. I just couldn't figure a way out to work out where the camera was looking ( There's camera.projec()t, which I guess is the way, here's the docs for that ). After dicking around for hours, I cracked and binned that approach, the maths is beyond me.

So let's just add another view and another camera and treat it as a separate entity from the main background. Sweet, all done. Now let's add some love to our texture, a specular map and some nice lighting. Sweet, that looks awesome, I'm really pleased with it, and I dropped some lens flares and moisture effects on top using Starling, looks great. I guess I should test it on the iPad now...

...ah, it runs at less than 30fps. Bollocks.

I've just spent the last hour or so removing all the sexy love I'd added in there, it still looks pretty good ( The grab above is from the cut right back down version ) but it was painful to do.
In my other recent iPad project I found that scaling images seems to cause a real hit on the first time, I don't know why, mipmaps being created on the fly ? Which means that you have to display your meshes scaled up but hide the textures with alpha=0, wait one frame, hide the meshes and restore the textures, that makes it skip that initial performance spike.

All in all a lot more painful than it should have been, but it does look good in motion, those stars fly into it and have a little impact shudder and as you can see a shower of particles. When I get some sound in there the impact should feel nice and weighty.

And that's what my last two days have been.

Squize. 

They explode and everything! Oh and linked lists in AS3

Did some work on the game Saturday and Sunday, which wasn't the plan as I had the html5 game to amend, but I got in the zone and really enjoyed it.

I altered the equaliser effect to the colour you see there, and after taking this grab I added another fainter layer on top to fake some HDR light bleeding.

The main push then was finally adding the explosions / particles / points. This was my big worry with the whole 60fps thing, and I managed to get there with some sly tinkering.

My first attempt was to split the particles up into two arrays ( Well Vectors, but that's such a confusing term when talking about Flash ), and run each particle in the two different arrays every other frame, so even though the game is 60fps, the particles actually only run at 30fps. This kind of load balancing really helps.
I'll be honest, I did notice the difference at first, but only because I was really looking for it, in real life they don't look like I'm cheating.

I'm not running a silly amount for each explosion, only around 60 particles, which doesn't sound much but when you've got 3 or 4 explosions at once they really help fill the screen.

After that I cracked and changed the code over to using linked lists to handle the explosions and particles. Normally I have code like this for my mainloop

var cnt:int=0;
var explosion:Explosion;
	
for each (explosion in activeExplosions){
	if(explosion.mainloop()=="dead"){
		activeExplosions.splice(cnt,1);
		explosionsPool.unshift(explosion);
	}
	cnt++;
}

Where we just loop through all the active explosions, any dead ones are removed and pushed back into their pool.

With a linked list ( I think technically I used a "Double linked list" but really who cares about the proper terms ) you store the first and the last object, your Head and Tail, and then each object has a reference to it's next and previous neighbours.

If the Head isn't null you call it's main loop and when it's finished it looks to see if it has a next neighbour, if so it calls it's main loop and so on. It removes the overhead of running a loop and changing the size of the array by inserting and removing from it. It has a slight cost when you want to remove it as it has to tell it's next and previous neighbours it's not longer there and update their next and previous pointers, but it's a handful of conditional statements.

I'm away from the game for another day or two now, but when I get back to it I'll be looking to change the player bullets to a linked list, I'm not sure if that will be possible as the baddies all expect to know about the player bullets so passing them an array is a nice easy way to do that, then I'll add the baddie shooting routines.

Squize.

Work stopped play

A bit of client work has come up this week, so I've not managed to touch DN8 today.

One thing I did mange to do yesterday though was to give the particles some colour, I'm really pleased with them.

They're a lot more colourful than in the original game, they have a nice 8Bit colour wash feel to them. Rather than going the tint route of the original, which is expensive, I just created a 260 frame tween in the Flash IDE and got it to spit all the frames out as pngs, dropped them into Texture Packer and the game just picks the next one in an array every time we need to plot one.

I think unfortunately that's where I'm going to have to leave the game for a couple of days, there's too many other moving parts work wise right now to be able to try and claw some free time back to work on it, which is kind of annoying as next up would be some explosions and all the particles which go with them. Oh well.

Squize.

Thursday I don't care about you...

Quick update today, as it's Friday and I'm sure we've all got places to be.

The first level baddies are in now, and the particles which show their path.

You can shot them to earn points, but no explosions yet ( That's the next big thing ). I noticed the frame rate drops slightly when the path is onscreen, so I'm going to have to look at that as well ( It's not too bad right now, but when we have a silly number of bullets running every little saving helps ).

Basically I'm trying to get all the costly in terms of CPU / GPU stuff in as quickly as possible and then optimise that so we keep as close to the magic 60fps as possible. I'm lucky in a way that I've got an iPad3 to test on, it's the slowest device out there ( iPad 1 doesn't count, that's really not worth targeting ).

Hopefully Mondays update should have more in the way of particles, as they always look good.

Squize.

We have the pow pow pow

Only the 2nd day of trying to update the progress on DN8 iOS and I'm struggling already ( I had fuck all sleep last night and then an early morning, I'm dead on my feet. I always know when I'm working early as everyone I chat to on IM says "Who's that ?" or "Shit the bed ?" or a combination ).

So, basic title screen in place with a play button and rollOver, the majority of the HUD done ( Working scores and everything ) and a player sprite which you can move around and it has the tilt animation in there.

And guess what ? Bullets too.

I don't think I've actually used any of the original code in this yet, which was the plan, but with looking at the baddies I think some copy and pasting is going to happen there as I really can't remember what I did.

Before I go, I got caught out with a couple of Starling things. Adding a blend mode to an image forces a draw call, as does using alpha. I know there's that whole starlingStage.alpha=0.999; work around, but it feels like that will be costly to do it on every child clip, so I've got a few specific container sprites that I add the blend mode to and use that alpha trick, so I've just got to remember not to use alpha in anything outside of those.

That's probably gibberish isn't it, so time to stop.

Squize.

And, back.

It's been ages since I've posted anything, and there are lots of reasons why ( Well, just one reason, work ).

I haven't stopped since Lost Outpost shipped, hence me not being able to go back and fix the bugs on that. I had a large html project to finish around the same time O2 was launching, so I couldn't give it as much attention as usual, and from that straight into an iPad project ( I guess I'll write more about that sometime, hopefully it'll be signed off soon ) and then my planned Christmas break was spent doing a quiz game ( A link as soon as it goes live ).
Then last week I did my first html5 game, which was cool, more on that once it's live. So basically lots of stuff that I can't talk about yet, that makes for a golden blog post.

With the iPad project I had to re-register as an Apple dev, and learn how to use Starling along with Away3D, and that inspired me to look at an old project.

This bad boy is coming to iOS ( And maybe Ouya / Android )

I've only been working on it one day, but I was thinking a blow by blow account of it's development may be interesting ?

Currently there's very little to it, I ripped out the original planet code and got that running ( I had to alter things slightly, the really large planets killed the framerate, I think it was a fill rate issue ) and just today I started on the title screen you can see there, with the graphic equaliser effect I always wanted in the original.

One nice thing I played with yesterday was reading the accelerometer, so as you move the iPad the screen moves ever so slightly, like in iOS7, to create a parallax effect.

I'm really hoping to have this run at 60fps, as it looks so beautiful running at that speed on the iPad. I optimised the crap out of the Starling particle extension the other week, partly for the client iPad project and partly as preparation for this, so I'm hoping we can keep the particle porn we had in the browser version.

I guess that's it for now. I don't really want this slipping into a big project, so we'll have to see what features get kept from the original and if any new ones will be added. I'm not super confident I can make my money back from working on this, so I've got to be a little bit pragmatic in terms of the scope.

Squize.