Thank you for visiting Blazing Games

Applying Paint to Flash

Applying the painters algorithm to Flash is remarkably easy as Flash already has support for layers. The technique I used for this episode is to simply create a movie clip for drawing a tile in three dimensions. The trick to this is realizing that there are multiple angles that any given tile can be viewed from. Because the game does not have 360 degree movement, this is not that complicated and the different views for each type of tile can be broken into a left view, center view, and right view. Flash's built in scaling capabilities means that the different sizes of the images can be handled entirely by Flash.

Laying out these tiles on the display is fairly simple. I limit the distance to four levels. The point blank level is closest to the player. Next to that is the short layer. Further back is the medium layer. Finally you have the far layer. Additional (more distant) layers would be possible, but remember that Flash does have to process all these layers so the more layers you have the slower the game will run. Each layer has three images that make up the layer. As the order of these images are somewhat important, the left image is the furthest back, followed by the right image and finally the center image. The order is important as the side views may have to be overdrawn by the center view.

To actually render a frame, we simply take the players current direction and location on the map. From this information we simply look up the tile value offsetting that location by the appropriate amount (based on which tile is being looked up). This value is assigned to the tile movie which then draws the appropriate image for that location. That is all there is to implementing the painter's algorithm in Flash. If you are just reading this book for the techniques used, you may have to do a bit more work if you are drawing this using two dimensional drawing tools. If I was coding this by hand (without 3D hardware) I would probably use a technique known as dirty rectangle management which I suspect is what the Flash rendering engine uses.

Previous page
Chapter 6 Page 5

About - Privacy Policy - Contact - Links - FAQ
Copyright © 2006 Blazing Games Inc. All Rights Reserved