🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

I am sorry in advance

Published June 14, 2004
Advertisement
To misquote Butterfly McQueen in Gone With The Wind, 'The happiest days are the days that I get to develop games'.

And, given that Gone With The Wind predates the first computer game by about 25 years, that's about the most egregious misuse of a quote that can possibly happen.

I apologize for it. Really I do.

Pretend I didn't say it.

I'd go up and delete it and pretend it never happened, but I so hate to delete content once I've created it, and content is content no matter how stilted.


I spent the last couple of days punching up and improving the 'Honeycomb' game I bought from Ernie. First off, I changed the name to the far superior 'BaffleBees', which I got by looking up the word 'puzzle' at www.thesaurus.com and going with the first thing that would be alliterative with the word 'bees'. I then went on with futzing with the game.

First off, there was very little that required improvement. One maxim I like to follow when designing a game is to determine if the game is a 'diamond' or a 'ball of mud'. Diamonds are games that are completely self-contained and work well as their bare essentials. A good example of a diamond is Bulldozer (a sokoban knockoff). There's no rule you can remove from the game without destroying the game, and adding any new rules to the game (like crumbling walls or jumping dozers) don't improve the game at all.

On the other hand, SimCity is a perfect example of a ball of mud. It's a game where you can add or remove stuff from it all day long, and it'll still be SimCity. The structure of the game lends itself perfectly to be extended or contracted, which is why it'll suck up all your machine resources whether you're playing it on the latest PC or a Gameboy Advance :)

Okay, enough designspeak. Honeycomb/BaffleBees is a diamond. Adding 'super bees' that affect tiles two spaces away or 'weak bees' that only affect three of the hexes around 'em would only make the game worse, so it's perfect as-is. I restricted my improvements to graphical special-effects stuff and general optimizing.

First off, I decided to play around with the size. I knew there were places where the game could be made smaller, even though Ernie's version was pretty tight, compiling down to about 20k. He had some extra fat in the project, though. Early versions of his game used a statically-created grid of hexes, so he had a big hex grid in the Flash library. He wisely abandoned that idea in favor of only drawing one hex and then filling up the screen with 'em programmatically. While that saved a lot of space, he left the old grid around, and Flash isn't sure if you'll need such things so it keeps 'em around. Killing off the big hex grid saved a little space.

Next was the code. Ernie was a bit enchanted with the new ActionScript 2.0, which adds strong typing and Java-style classes and such to the much simpler ActionScript of earlier Flash versions. Problem is, ActionScript 2.0 is implemented as a preprocessor that converts the new code to original ActionScript, so you'll likely get more efficient (but admittedly not as pretty) code just programming in plain old ActionScript. Furthermore, Flash doesn't have an optimizer that removes unused code, and Ernie had stuff like a Coordinate class (an X-Y pair) with a bunch of useful functions that are never used. Removing 12 of his 15 game objects saved a lot of space.

Finally, I did a couple of things that you learn from experience. For example, the only pieces of Dynamic Text (text that changes while the program runs) in the entire game are the score displays down in the lower-right corner. All the rest of the text is static. Since Flash has to look the same on every machine, it stores the curves of your fonts internally. Also since Flash doesn't know what characters you're going to display in a Dynamic Text object, it stores the entire font unless you tell it otherwise. There's a 'character' button on the Dynamic Text properties where you can tell it what to display. By telling Dynamic Text that this object could only display the numbers 0-9, I was able to drop the number of characters stored internally from 100+ characters to ten.

After a day of tweaking and toying with the code, I had reduced the size of the game from 20k to 13k, a pretty substantial reduction.



Next came time for improvements. The most obvious need was sound, as Ernie's version was silent. A google search for bee sounds turned up a good loop-able buzzing bee sound that could be reduced to an 8-bit MP3 with no loss of sound quality. I added a bit of code to make the bees buzz as you dragged 'em. Since Rimsky-Korsakov's 'Flight of the Bumblebee' is public domain, I took the last 5.9 seconds of the song and made it the musical 'punch' when you start the game. It's also the 'you completed the level' song, but I start it later in the clip so it only plays the final couple of notes. Doing this bloated the game up to 23k, but I figured it was a worthwhile addition. I also added a little toggle (the musical note in the bottom center of the screen) to shut the music off for office play.

After showing the 'improved' game to Ernie, he was determined to get all the way to level 30 without making a single mistake. He did make it (I messed up around level 20-something), and he came across a couple of devilish puzzles that he wanted me to see. Since the levels are randomly-generated, level 24 on his machine was different from level 24 on my machine, and I couldn't see his particular version. I then decided that levels should have some kind of number associated with 'em (i.e. the random seed) so people can challenge their friends to best their score on a particularly hairy level. Problem is, ActionScript's Math.rand() function is the sum-total of random numbers in Flash. It's initially seeded with the current time and there's no way to change the seed. Hence I needed a better ActionScript random number generator. A bit of research and a couple minutes coding gave me this. . .

class Randomer{    private var m_seed:Number;    function get val()    {        m_seed = (m_seed*[[9301]]+[[49297]]) % [[233280]];        return m_seed/([[233280]].[[0]]);    }    function set seed(s)    {        m_seed = s;    }    function get seed()    {        return m_seed;    }    function Randomer()    {        m_seed = new Date().getTime();    }};


I've started on a simple dialog box that shows the current level's 'serial number' (which is the level number followed by the random seed) and allows you to enter your own. It's simplistic, but it should be sufficient to allow folks to share levels.

And that's it. It's my (hopefully successful) attempt to improve an existing game without 'gilding the lily'. Before I make it public, I'll need to add a couple of security features to it so that it'll only run in thecodezone's webspace. Flash applet theft is rampant nowadays, but there are a couple of ways to prevent casual thieves from stealing your applets. The determined ones will decompile your applet and remove all the security, so I'll just have to resign myself to that.
Previous Entry FreebieFest 2004
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement