Using haXe for Platform Games

January 30th, 2007

In the past weeks I’ve been experimenting a lot with haXe, a new programming language that can compile to Flash SWF files. Last summer, I already played around with haXe for a while and made a little flash scroll demo. Recently, I’ve been trying out different methods of drawing tiles, in order to find the fastest method.

At first, the difference in speed appeared to be huge, but those were rather the result of other optimizations I did in the meantime. All these methods work at roughly the same speed if you’re using large tiles. But when you have small tiles (which I normally use for games) and you have hundreds of them on screen all the time, handling all those tiles seems to become far slower than rendering them.

Here are three methods I tried:

  1. The first is the method used in the scroll demo. Every tile is represented by a separate MovieClip, the total number of MovieClips stays constant, when a tile goes off-screen, its MovieClip is reused for the tile that appears on the other side. Using this method makes it very easy to add animated tiles, since they are handled by flash.
  2. The second method is the same method as above, but with only one MovieClip with a BitmapData attached to it (as the screen surface) and just “blitting” all the tiles to it using copyPixels. Here you need to implement tile animations yourself.
  3. For the third method (demonstrated below), each layer has its own BitmapData object as a surface (size of the screen + 2 tiles), which scrolls along with the layer. That way, you only need to redraw the tiles that actually change (at the edges and animating tiles). When you start to scroll, you’ll run out of space on the surface, but it wraps around to the other side. So normally, the screen will be divided in to sections horizontally and vertically. To get all those back together, there are 4 MovieClips per layer and the BitmapData is attached to all 4 of them. By placing them next to each other, you get the entire screen in the middle. The Mario example only scrolls horizontally, so it only uses 2 of those surfaces (per layer).




(click to play)

This little demo is based on my Mario clone for DOS, there are no enemies and the only thing you can do is collect coins. If you are using FireFox, click on the game first. Use the arrow keys to walk and space to jump. Enjoy!

New Training Levels in Charlie II

December 29th, 2006

3.jpg 8.jpg

Wiering Software has just released Charlie II version 3.10, which now includes two free training levels, meant for first-time players and young kids who have trouble getting through the first regular level. In fact, the first level can be completed by only holding down the right arrow key (be sure to set the difficulty to easy if you try that, or you won’t survive!).

To download, visit to the Charlie II website.

Coltris

December 23rd, 2006

coltris1.jpg coltris3.jpg coltris2.jpg

Coltris is a small casual game I wrote a long time ago. It’s a match-3 game in which you must try to line up at least three blocks of the same color to remove them. During the game, more and more colors appear, making it harder. This game was originally for DOS, but I recently ported it to Windows / DirectX. This game is freeware.
Download: DOS version | Windows version