^ click above ^
More and more J2ME handsets are being deployed world wide by all major cellular
carriers and are supported by mobile manufacturers like Nokia, Siemens, Motorola
and Sony Ericsson. There will be if not already a huge demand in mobile development,
one of these key areas undoubtly is mobile gaming.
With that being said this tutorial will give you a brief introduction in developing
games using J2ME (Java MicroEdition), visit Sun MicroSystems for further details
What this Tutorial Is
- Programming Approach
- Hurdles/limitations in mobile development
- Some solutions to improve performance
- What Development Tools to Use
- How to Market Your Game
- Useful Links - News, Multiplayer, Bluetooth
As everyone knows Java is an object-orientated language; thus, coders program
with an OO approach and for the more advanced coders design patterns are put to
use. A simple a hello program can easily bloom in to a dozen or so classes, of
course in doing this it provides maintainability and extensibility. This is normally
a good thing.
In the mobile world where memory is expensive it is best to avoid using several
objects unless truly necessary. More about memory constraints will be explained
later. This may sound easy, but trust me for those of you who are use to separating
tasks into several objects and heavily rely on patterns will find reverting back
to a more procedure way of development a challenging thing to do. However, you
do not want to write one big giant super class that does everything, rather write
your game in the simplest manner that is comfortable to you. After you should
merge classes that do not provide much gain in functionality.
general, there are three types of memory you need to concern yourself with, working
memory, storage memory and application memory. Working memory is the memory where
the game is executed during runtime. This is an obvisous concern because if the
game is too big an out of memory error will occur.
When programming games you will need to store such things as high scores, user
options, and other game state data. This is called the storage memory.
The game itself takes up memory storage as well. This is usually the same as storage
memory, it is sometimes referred to as the application memory. Application memory
takes into account the memory storage needed to hold all the games and applications.
Now knowing what memory constraints there are you need
to code your game accordingly. You should consult the manufacturers specification
for the mobile handsets you are planning to deploy your game to. Check for the
maximum size a game can be during runtime and memory storage available.
One of the biggest problems are the displays themselves. Displays on J2ME enabled
mobile handsets vary not only from manufacturer to manufacturer; but also from
model to model produced by the same manufacturer. Things to consider when adjusting
your game to the display are screen size, frame rate and color. You will have
to make a decision which handsets you want to support. It is ideal to write the
game generically then make alternate versions for certain handsets. Once again
you should consult the manufacturers specification so you can make the appropriate
Some Solutions to Improve Performance
As mentioned several times before you first need to decide which phones you want
to support. This is very important because you if decide not to support the lower
model phones you may not have to concern yourself with very limited memory constrained
handsets with limited color and screen size. However, the reality is most cellular
phones on the market purchased by regular consumers will be the lower model handsets.
As well don't forget most promotions that offer discounts or even free handset
give a ways usually involve only the lower model handsets.
Now that you've decided which models to support, what can you
do within the code to optimize your game? First of all, use the least amount of
classes, stick to shorter variable, method and class names. In general, keep it
simple for example avoid using unnecessary protocols such as SOAP, granted its
better to use a standard protocol it will increase your overhead because of all
the extra layer of processing and the libraries themselves will take extra memory.
Try to reuse objects rather then instantiating new objects over and over again.
If the game is a network game then reduce calls to the server, this is especially
so when obtaining resources such as graphics, maps and levels. Try to obtain all
your resources in one request at the begining rather then several requests to
reduce the chance of latency problems to occur. Optimize the graphics and merge
the graphics into one sheet instead of spreading them out into several seperate
graphics. Once you have completed your final version you should run an obfuscator
against your code not only to reduce the chances of someone re-engineering you
hard work but it will significantly reduce the size of the final jar file.
What Development Tools to Use
First get the J2ME Wireless Development Kit from Sun Microsystems,
http://wireless.java.sun.com. If you
are looking for an IDE, there are some free ones available:
Sun One Studio ME - http://wwws.sun.com/software/sundev/jde/index.html
JBuilder with the Mobile Set - http://www.borland.com
White Board SDK - http://www.zucotto.com
As well you should visit the individual manufacturers for their customize SDKs
for their own mobile handsets.:
Motorola - http://kb.motorola.metrowerks.com/motorola/pcsHome.do
Nokia - http://forum.nokia.com
Siemens - http://www.siemens-mobile.com
SonyEricsson - http://www.sonyericsson.com
RIM - http://www.blackberry.net/developers/index.shtml
How to Market Your Game
is an excellent article at the Sun website about making money in the mobile world,
http://wireless.java.sun.com/deploy/revenue.html. Now that you've read the article
where do you go to get help to market your games. You have 4 choices, to approach
the carriers themselves, established gaming companies that provide partnerships
to market your game, a wireless agency or aggregator, list below are a few of
them you can start with. However, if you are a single independant developer it
is best if you approach an aggregator or agency. Most carriers and manufacturers
prefer to deal with established gaming companies, aggregators and agencies rather
then deal with thousands and thousands of independant developers.
More Useful Links
Free Downloads / Demos / Reviews
Well there you go that was a brief overview about developing mobile games using
J2ME, some directions where to start and where to go. I will be releasing more
in depth tutorials on J2ME Development in the near future. Please email me for
any suggestions, questions or flames. If you do flame me please let it be constructive
About the Author:
Jason is part owner and Chief Developer at MoBro.com, http://www.mobro.com,
a wireless entertainment and application software company. Jason is a wireless
and open source developer enthusiast who enjoys creating synergy and sharing knowledge
in the software development world. To learn more about him visit his personal
site at http://www3.telus.net/jasonlam604/
Read this newsletter at: http://www.wirelesspronews.com/2003/0701.html