Thursday, April 5, 2007

Egg on my Site

I posted a new "game" on Blazing Games today, which is what I do every Thursday evening as being in the west coast it is Friday in most of the world by the time my post is released. You will notice that I have the word "game" in quotes because this week's release wasn't really a game. With all the overhauling of the site that I have been doing I simply didn't have time to create a new game for Easter. I still have a huge amount of minor changes to make to the site yet, but all the major changes have been complete. I was just going to take my existing Evil Eggs game and release it as open source. Then I thought it might be nice to write a short article about making Evil Eggs. The only really significant thing about the game, though, is the egg generator, and that is not overly complicated. Then I remembered that when I was originally creating the game I had wrote a simple testing program for testing my random eggs. I then thought that with a bit of tweaking, it would be perfect for the release today.

As people who have visited Blazing Games and played with the egg generator have already figured out, the random eggs in Evil Eggs were fairly simple to generate. All that is happening is that an egg color, a pattern color, and a pattern are selected at random. Of course, the original reason I wrote the egg test was due to strange problems I was having with Flash. As much as I like Flash, there are still occasionally quirks that one must discover and often find ways to work around the quirk.

The problem I had with Evil Eggs was that the patterns were not working. As any Flash developer reading this already has figured out, the egg is made up of a group of layers. The bottom layer is the basic egg movie which holds a color for the egg. Over that is another basic egg movie of a different color that has a mask applied to it. The mask causes only part of this egg to be shown, resulting in the egg. There is also a light layer to add a bit of a glint to the egg.

The problem is that masks, at least when compiled for Flash Player 7, are not always accurately rendered. In particular, any mask that has a hollow portion within the mask area will not render properly. This quirk resulted in some of my masks not rendering properly resulting in rather strange looking eggs. The solution to this problem is to simply make sure that there is a open path that will lead to the gap within the mask. For instance, my checkerboard pattern actually has notches cut out of the corners, and my O shape has a hairline crack in it.

So, if any Flash developer is having problems with using masks, remember that flash expects masks to be solid shapes.

No comments: