Friday, December 7, 2007

The importance of beta testing

Of course you can test your program yourself, you run it a thousand times when you're developing it testing small pieces of the code. But when you want to develop a first-class program without spending a lot of money, you need to ask some friends for their help in this annoying but very important task.

It doesn't matter if you offer them a free copy of the final release, a couple beers, a free dinner (specially good idea if the beta tester in question is a girl you like), you will always find at least half a dozen friends willing to test your game. This will allow you to have different points of view regarding certain features and will expose your program to different environments. In this case, testing your mobile game against different phones is very important because they all use different screen resolutions and keyboard mappings.

As of today, I haven't really figured out the best way to tackle those two problems: screen resolution and keyboard mappings.

For the first one, I've made everything that's drawn in the screen adjust to a ratio of the total screen resolution, but that's more difficult when it comes to stored graphics because you need to choose a different image file depending on the resolution. It has come to my mind that I could make a "screen definition" file format that defines which image files to use and where to put them in the screen. It could also define font styles and sizes, colors and so on. This would not only make it very easy to setup a new screen resolution for a newly marketed mobile device but would also make the game "skinable", which would make a great feature altogether.

About the keyboard mappings, I also think I should make a "keyboard configuration" option. That way, the user itself could choose what keys he wants to use for every action and the game would work with every possible device.

As a proof of concept, and also to figure out the keyboard mappings of the phones a couple friends use, I developed a small Midlet that gives feedback of the keys as the user presses them. This is the code of the Canvas that does it all:

import javax.microedition.lcdui.*;
import javax.microedition.lcdui.game.*;
import java.io.IOException;
import java.io.InputStream;

class KeyTestCanvas extends Canvas {

private int lastKeyCode;

public KeyTestCanvas(){
}

protected void paint(Graphics g){
int w = getWidth();
int h = getHeight();
g.setColor(0x000000);
g.fillRect(0, 0, w, h);
g.setColor(0xFFFFFF);
g.drawString("keyCode:", 10,10,Graphics.TOP|Graphics.LEFT);
g.drawString(Integer.toString(lastKeyCode), 80,10,Graphics.TOP|Graphics.LEFT);
g.drawString("GameAction:", 10,30,Graphics.TOP|Graphics.LEFT);
try {
g.drawString(Integer.toString(getGameAction(lastKeyCode)), 80,30,Graphics.TOP|Graphics.LEFT);
} catch (Exception e) {
g.drawString("Exception", 80,30,Graphics.TOP|Graphics.LEFT);
}
g.drawString("KeyName:", 10,50,Graphics.TOP|Graphics.LEFT);
try {
g.drawString(getKeyName(lastKeyCode), 80,50,Graphics.TOP|Graphics.LEFT);
} catch (Exception e) {
g.drawString("Exception", 80,50,Graphics.TOP|Graphics.LEFT);
}
}

protected void keyPressed(int keyCode){
lastKeyCode = keyCode;
repaint();
}

}

No comments: