Last week I wrote about wonderfl, a unique resource for Flash developers. But it's not one I use a lot; I've perhaps used it only a few times for experiments and for code I'd like to show working.
By far the most important and useful web site I use is Flash Game License. As it says below its logo it is "The place to buy and sell Flash games.", so it's a marketplace. It's needed because of the structure of the Flash game industry, with many buyers and even more sellers, of games worth so little that they are not worth advertising or heavy promotion.
Friday, 23 December 2011
Thursday, 22 December 2011
Bug Tunnel Defense: Levels
(originally posted 6 June 2011)
The missions in Bug Tunnel Defense started out a lines of code, describing the position and location of every wall, tunnel, entrance and exit. This became unwieldy very fast, and it was clear it would be unusable for the dozens of missions I wanted in the final game.
Wednesday, 21 December 2011
SharedObject file location
One thing that comes up from time to time, that I learned while making Bug Tunnel Defense, is how to control where Flash saves the settings for the game (assuming the game has settings). This is important as the default location depends on the path to the file on the server and the name of the file on the sever. Although this doesn't usually change it can when the file is moved as it's re-uploaded or for security reasons.
Tuesday, 20 December 2011
String to ByteArray
In Bug Tunnel Defense all levels (called missions in-game) are stored as Strings. This includes the built in levels, levels stored on the user's machine that they've created, and levels stored online in GamerSafe's LevelVault and Kongregate's shared content system. Kongregate also uses Strings, so was very straightforward. But LevelVault requires data stored in a ByteArray, so I needed to convert Strings to ByteArray.
Monday, 19 December 2011
More matrices
Last week I wrote about one way to use matrices, passing values to the Matrix constructor to make a transform or scale matrix. Matrices made this way can be passed to functions that need them, minimising the number of lines and temporary variables. This approach is fine for simple uses but breaks down for more complex applications, as the values passed to the constructor require multiple calculation steps, too much to do inline. Fortunately there is another, easier, way.
Saturday, 17 December 2011
wonderfl
As I've used it in two posts I should mention what wonderfl is. It's simply one of the best resources available for Flash developers, in particular ActionScript programmers. It lets developers upload and run ActionScript, for testing or to demonstrate it. Code on the site can be modified, even if you did not write it, by creating a copy (or a 'fork') and working on that. Editing and testing all takes place in the browser, making it often much quicker than setting up a similar project in Adobe Flash CS or a similar environment.
Friday, 16 December 2011
A faster random
Although ActionScript has its own random number function, Math.random(), like most library calls it is not especially fast. But it is easy to replace, to provide a significant speed up, as well as make it easier to do other optimisations.
The basic idea is very simple: instead of calling Math.random()while the game is running call it a number of times at startup to populate a list, then at runtime pull values out of that list. This would not work in all games: it might produce predictable or repetitive outcomes in some cases. But in games where random numbers are used for effect or to provide some variability in a number of ways it is often indistinguishable from Math.random() (which is not truly random anyway).
The basic idea is very simple: instead of calling Math.random()while the game is running call it a number of times at startup to populate a list, then at runtime pull values out of that list. This would not work in all games: it might produce predictable or repetitive outcomes in some cases. But in games where random numbers are used for effect or to provide some variability in a number of ways it is often indistinguishable from Math.random() (which is not truly random anyway).
Thursday, 15 December 2011
One decimal place
This is a small function I wrote to print Numbers to one decimal place. Most user-visible values used in Bug Tunnel Defense were whole numbers and so were stored as int. But a few needed more precision and so were stored as Number. So they did not overflow their TextField they were displayed to one decimal place, using this function.
Wednesday, 14 December 2011
Bug Tunnel Defense release notes
I discussed these in detail on the blog I ran for Bug Tunnel Defense's release. Rather than repost those posts separately I'll summarise them, with links to the originals.
Tuesday, 13 December 2011
Matrices
The Matrix class in Flash is a two-dimensional matrix, used to draw and display objects on the stage. It is difficult to avoid as it is needed for some calls, especially the draw function of the BitmapData class. The Matrix if something is to be drawn without moving, but generally it's required.
The simplest use is to offset something as it is drawn. I find this is also the most common use, so it's useful to have a quick way to do it. Here's an example of that, drawing a wall block into a layer based on its grid position.
The simplest use is to offset something as it is drawn. I find this is also the most common use, so it's useful to have a quick way to do it. Here's an example of that, drawing a wall block into a layer based on its grid position.
Subscribe to:
Posts (Atom)