Friday, 30 March 2012

3-channel Game of Life shader

Following on from yesterday's post I decided to act on my own suggestion and make a 3-channel version of the Game of Life shader. The result is here on Wonderfl and embedded below, with the full shader code as a comment at the end of the source on Wonderfl.

Thursday, 29 March 2012

Game of Life shader

This is another simple and quick shader, this time done to see how easy it would be to implement Conway's Game of Life after seeing the same logic implemented using filters. It's an ideal fit for shaders not only as the code that runs on each pixel is identical but also as the 'game' is essentially a graphics algorithm. Turned out to be every straightforward, taking only an hour to write, test and deploy here at Wonderfl.

Wednesday, 28 March 2012

Practical optimisation

While browsing on Wonderfl to see how my cross product shader was doing I came across someone else's code, the evocatively named "forked from: flash on 2012-3-23". Running it I noticed it was slow: it was not doing much but got slower and used more CPU as it ran. So I decided to look into it.

Tuesday, 27 March 2012

Cross product shader

This is something I did to try out the mathematical functions in Pixel Bender's shader language. I also wanted to work out how to upload an image to Wonderfl, and upload another more interesting shader example to there. Seeing how its turned out I can't imagine using in game though with a bit of work it could produce some interesting effects which might be useful.

Monday, 26 March 2012

Radial gradient fill

I first tried using gradient fills (via the beginGradientFill method of the Graphics class) in Bug Tunnel Defense. I wanted to use them for shading along the tunnels but could never get them to work, and eventually did it the long way by drawing a series of differently coloured rectangles. The problem was the createGradientBox Matrix function, which no matter what I passed to it would never return the right matrix for a linear fill.

Friday, 23 March 2012

More shaders

I wrote two new Shaders today. One is for a screen that's not in the game yet, which the Shader will be a fundamental part of. As the Shader is rather complex I wanted to write it first to see if what I wanted to do was possible. It seems to work, so now I need to write the code for that screen.


The second is much simpler. It does edge detection on the layer I added yesterday, to highlight the boundary of the region indicated. The Shader code is very straightforward and it took much less time than either of the other Shaders I've done for this game.

Thursday, 22 March 2012

Screenshots


Catching up today after spending much of yesterday performing my civic duty, and spent some time adding a new graphical layer that slots between existing layers in just the right way. I had to re-work a few things to get it right, but the result not only looks better and helps a lot in the gameplay but is a little more efficient to draw.



Wednesday, 21 March 2012

Review: Triple Town

Triple Town by Spry Fox started out on the Kindle, but I first noticed it on Facebook and subsequently on Google+, one of the first game on that platform. Most recently it has been released for iOS devices. 



Tuesday, 20 March 2012

Linked lists + screenshots

I moved some of my data structures over to linked lists today, in preparation for adding more functionality and gameplay. I was once fairly sceptical of their applicability in Flash but I've been persuaded around by the performance work I was doing a few months ago. In particular the overhead of accessing array (Vector or Array types) members is non-trivial, comparable to other function calls. I may do some performance tests to confirm this but I'm pretty sure this is an optimal solution for what I'm doing.

Monday, 19 March 2012

Ball-ball collisions

In this post I discussed how to handle collisions in general, at least when one of the objects is a ball for collision purposes. My intention was to follow it up with an example but I never got around to it. Well now I have, and it shows how to turn the theory in that post into practice.

Friday, 16 March 2012

Trig performance test

I have asserted that trigonometry is slow in a number of posts. The whole point of a post on Trig-free rotation blending is that trigonometry is so slow that it should be avoided. My reasons for this are my experiences on previous platforms, where trigonometric functions are often tens or hundreds of times slower than arithmetic operations.



But such assumptions often prove false on new platforms. Flash in particular does not have the highly optimised arithmetic operations of modern CPUs, so rather than trigonometry being especially slow it could be that maths in Flash is slow enough that there's no need to avoid Flash. This is certainly worth knowing, as there's no point avoiding particular functions if they are as fast as other ways of doing the same thing.

Thursday, 15 March 2012

New screenshot

A lot more circles in this one, and more colours, or at least it's making much more use of them. The game's not fundamentally different to last time, it's mostly a lot of subtle changes.

Update: another screenshot, below the fold, after another small change

Wednesday, 14 March 2012

More on Flex

Just a short update, but it's on an important point as I discovered something to make my life a whole lot easier.

Tuesday, 13 March 2012

Screenshots

New screenshots; three of them this time so they're below the fold

Monday, 12 March 2012

Shader vs. ActionScript

It was pointed out to me that the shader I used as an example last week did something that could be done with ActionScript, in particular a ColorMatrixFilter. This was something I was aware of, as I described how to use a ColorMatrixFilter in exactly that way a month ago in this post. But it's interesting to compare them to see the difference.

Friday, 9 March 2012

Screenshot and update

Busy today, so so just enough time to do another screenshot. This includes the text I wrote about yesterday (though I've rewritten that code to make it more flexible), the lives indicators, and some more gameplay elements that are too complex to describe.




It's still is missing some major elements before it's really a playable game, though those in a way are the easiest bits to put in. Then lots of tweaking and improving, not least of the graphics which I've been adding to but haven't looks at changing.

Thursday, 8 March 2012

Text revisited

Three months ago I described the class BTDText I created for Bug Tunnel Defense to replace the built-in TextField class. I used it again today to add some progress text to my game, and learned a couple of things in the process.

Wednesday, 7 March 2012

A simple shader

I wrote this shader a few days ago, but didn't want to write about it until I was able to demonstrate it working, which I did in yesterday's post. Now that's done I can describe the shader it used in more detail. It's a very simple shader, that desaturates whatever it's applied to on a scale between 0 (no effect) and 1 (greyscale).


I wrote it for this blog, but it's likely I will use it or one based on it in the future. It could be used at the end of a game or when a game is paused to indicate the game has stopped while still showing gameplay or the game state, or could be used as part of a fade-out between levels.

Tuesday, 6 March 2012

Shader from string

I wanted to write a bit more about Flash shaders, but was constrained by being unable to show my workings: I can post screenshots and could even host a working demonstration but I could not upload a shader to Wonderfl (images can be uploaded but not other data). Nor could I easily load one from elsewhere because of Flash's security model: I would need to load it from a server where I could edit the Crossdomain.xml file.


But a search of Wonderfl and a further web search turned up the solution: the data can be embedded in the source as a Base64 string.

Monday, 5 March 2012

New screenshot, Flex update

Another screenshot, with the newest additions called at the moment 'snakes'. As always none of this is final, with the colours easily changed by changing a single line. It doesn't show any actual gameplay.



Friday, 2 March 2012

Drawing a pie chart

This is something I wrote for the game I'm working on but removed a few days ago as I went in a different direction in the design. As the code is fairly self-contained I thought it might be of interest.

Thursday, 1 March 2012

Another screenshot

This is a screenshot of my latest code with the Shader in effect. It's a bit of a cheat actually as I had to slow it down 10x so I could take a screenshot. Which is a way of saying a static screenshot doesn't really give an idea of how it looks in action, at 60fps with everything moving.




 Also the game now uses no art assets: everything is procedurally generated. I don't rule out using art in the final game but for now it's quicker and easier to work in code where I change a few numbers to completely change the look and feel of things.