Jan 11 2011

BattleWire16K in Chinese

BattleWire16K was translated to Chinese courtesy MochiMedia/ShandaGames. You can see it here. Note that that’s a link to a Chinese website and other than to note that the orange button below the screenshot launches the game, I don’t really know what any of the text says.

The one issue that came up, is that the recommended font, Microsoft YaHei, is large and embedding it into my .swf turned a game made for a 16kb contest into an 7,823kb monster. (MSYH, being a font designed for use in China contains character information for over 20,000 characters in comparison to an English/Latin font which has a few hundred.)

However, the translation needed only a handful of these. The solution was to embed by unicode range. Of course I didn’t know the character numbers for the Chinese text, and don’t have a utility to readily find unicode character numbers. Fortunatley, there are several web pages which will take arbitrary text and turn them into a series of unicode characters. I used one by Russel Cottrell.

To get the characters which needed to be embedded, I took the text sent back by the translator and copy-pasted it into the block which is labeled ‘Click to insert characters below’, selected Hex and click convert to HTML. This produces in the bottom block output which will look like “知名坦克”

Copy paste that block to a new file in any adequate text editor, and find-replace &#x with U+ and ; with ,

Remove any linebreaks and you now have a list of Unicode characters used in your translation, which you can copy into your embed tag using the unicodeRange= option. Using this process, I was able to reduce the file size from almost 8MB to a more reasonable 76kb.

Jun 09 2010

Impossible Bugs

So, I’m still hard at work on Puzzle Runners. Remember when I said that I had written the single player version in a way that lent itself easily to being converted over to multiplayer?

Yeah, I’m not as smart as I thought. :( It took 17.5 hours spread over many days to get the setup and sync working.* Or at least working well enough that I could move onto the ingame message handling, I still need to go back to the setup code and handle some loose ends.

So… the whole game is setup using a “bounce” server which just bounces all the messages it receives to all the connected clients. The first client to connect becomes the ‘Master’ which is responsible for setting up the game and owns the AIs. And now I’ve got an error state where if only the Master is connected, the AIs behave correctly, but if there are two or more clients the AIs just stand in place.

This is my code which dispatches messages to the server:

Here’s the crazy part… that “trace” statement marked with the red arrow? All it does is print the message being sent to the server to the debugging console (or copies it to a log file). I added it because I wanted to make sure the AI messages were being sent (they were). If the trace statement is present, the AIs move correctly. If the trace statement is commented out**, the AIs don’t move. Human players however, move correctly regardless of the presence of the trace, so I know the dispatch function is working.

Ultimately of course, the lack of a trace can not be the reason why the AIs are turning themselves off… I’m guessing the trace is affecting the timing in which the messages are being received and that’s causing something I didn’t intend (I designed the message handler to work regardless of the order in which messages are received, and independently of the refresh timer… but I’ve made bigger mistakes before! :)).

Anybody reading this got a good story of a bug where the symptom and the root cause didn’t appear connected?


* – That’s not a complaint… I haven’t worked with multiplayer games before, so I’m turning up issues I’ve never considered before. (ie: How should the game react when a client disconnects before setup is complete? What should happen if a player attempts to join a table that’s already full? etc) So to the extent that I am a programmer, this is interesting stuff… it just taking longer than I had budgeted.

**- For the non-programmers, commenting out a statement makes the computer ignore it when it’s executing the program. The words following // are comments.

Oct 13 2009

Cellular Automator 0.2

This is the first version of a cellular automata visulizer. At the moment it’s just kind of a toy. Click the screen to add cells, then press play to see how they develop. I’ll do a separate post for the why’s and wherefore’s when I get around to it. Any and all feedback is appreciated!

Current features:
– Three rulesets implemented

– Allows resizing from 3×3 to 500×500, including non-square grid sizes
– Allows the grid to be cleared
– Allows single generation stepping
– Attempts to run at 5 generations per second in normal mode
– Attempts to run at 10 generations per second in fast mode (skips rendering every other generation)

Known Bugs (so far):
– Sometimes you may have to press clear twice to reset the generation counter. (I know why, but it’s not a straightforward fix unfortunately)
– After resizing, the ruleset will be set for Conway’s Game of Life, regardless of what is being indicated. Click your desired ruleset again if you wanted something different.

Jul 23 2009

Whirled API: Keyboard Focus

One of the most vexing issues with implementing the Whirled API in your single player game is keyboard input. With a standalone .swf deployment (such as a normal game), resetting the focus to the stage periodically is sufficient to keep keyboard inputs going to your handlers. However, due to Whirled’s security model, you are not allowed to add handlers to the stage directly, and instead must add your handlers to _control.local. (Assuming you named your GameControl object _control!) stage.addEventListener(KeyboardEvent.KEY_DOWN, KeyDownListener) will through security errors.

Unfortunately, stage’s focus can only be set to an InteractiveObject. Therefore stage.focus = _control.local does not work to regain focus when it is lost.
This is because _control does not inherit from InteractiveObject.

There are at least two situations where your game is going to lose focus when running in the Whirled platform.

  1. The player clicks outside your game. (ie: to type in the chat window)
  2. The player clicks a button which you then remove from the stage. (ie: Start New Game)

Read more »

Jul 23 2009

Whirled API: Setting Game Dimensions

Whirled is a somewhat interesting gaming platform backed by Three Rings, the makers of Puzzle Pirates. Games played on Whirled are Flash (.swf) files, which are played inside the platform’s wrapper which is itself a large swf file. Unfortunately, Whirled’s dev forums are located inside Whirled and have poor search functionality. Additionally, because Whirled itself is similar to an open MMO and every in game object is coded by someone in flash, many of the people on their forums are not focused on building games– they’re building toys and avatars and furniture.

That’s not a problem, but sometimes it is very difficult to find information about fixing simple problems. Particularly when the technique you need is one you haven’t run into before at all. Read more »