Archive for March, 2009

Games I’ve Coded – Triple Pop

Steve on Mar 30th 2009

Triple Pop Splash Screen

Triple Pop was the first Java J2ME game I coded at iomo, back in about 2002. It was a white label game for Nokia Series 40 devices, initially the 7210, but it found it’s way onto dozens of similar devices. The 7210 was one of the first colour screen Nokia J2ME devices. Until then, they had the 3410 and 6310i with Java embedded, but these had 96×65 1 bpp  screens (that’s 2 colours, black and white, or dark grey and light grey on the phone!). The 7210 had a 128×128 colour display, could run jar files that were up to 64k and had 210k of runtime heap. It’s CPU was actually pretty nippy too, maths and game logic almost never turned out to be bottlenecks, it was always the screen updating that took time. The LCD response time was pretty slow, any attempt at animation over about 10 frames per second blurred terribly.

Triple Pop was already available as a Symbian application for the Series 80 communicator range, and we got the contract to write a Java version. I had the C++ Symbian code available to refer to when writing the Java version, which helped a lot. I lifted the algorithms for the heap of bubbles collapsing and rotating directly from the Symbian code. I still had to write the Java code from scratch, but there was no need to invent everything myself.

I won’t write too much about the game play, a video is worth way more than some words to show you what it’s about.

To be honest, there’s nothing very interesting to say about the development cycle of the game. The concept was simple and an implementation already existed to set the standard, there wasn’t much need for innovation or fancy coding. Early on we didn’t have actual devices, but the emulator turned out to be a pretty accurate model for the real thing, something Nokia sadly didn’t continue in later years! The game didn’t tax the device to any great length, it ran in about 60k of memory, jar size was less than 32k in the end, and it loaded quickly. Looking back, the aspect of development that strikes me the most is the similarity with how I do things today.

My basic development tools in 2003 were SlickEdit (v4 I think then), CVS, Java v1.3, Apache Ant and an obfuscator, at the time I used JODE. Today I use SlickEdit 2009 (v14 in old numbers), Perforce, Java 6 (or 1.6 in relation to 1.3), Ant and Proguard as an obfuscator. Basically the same tools, but there’s one difference. Today I code on top of a middleware framework that is the culmination of 7 years of mobile phone development experience. When I wrote Triple Pop, it was meant for a single class of very similar devices. Today, the codebase of a J2ME title must support hundreds of devices from many manufacturers. The specifics of doing this are the subjects for another time though.

Anyone developing a commercial J2ME application or game today needs to have a framework in place that assists with device fragmentation and porting.  This could be an in house system built up over time, or a middleware platform bought from a 3rd party.  Triple Pop had no underlying technology of note, it was just over 5000 lines of Java code and some PNG images.  Later on, we used a system of pre-processing the source code for different devices and SKUs, but this early approach only scaled so far.  Further to that, as iomo was acquired by Infospace and game production really stepped up, we adopted a full featured in house framework developed by Elkware (another Infospace acquisition).   Today, at FinBlade, we use Bedrock from Metismo, which allows us to target both J2ME and numerous other systems such as iPhone and Google Android, all from a single source code base.

Triple Pop in action

Mobile development has moved on a lot since 2002.  Soon, I hope to write about more games I’ve been involved with, if for no other reason than to have a record for myself.  Going back and playing Triple Pop again to make the video above made me think ‘that’s really quite fun, it’s worth remembering’, so I have :-)

Filed in Games | 2 responses so far

My next Java ME mobile application probably won’t include JavaFX Mobile!

Steve on Mar 24th 2009

When I installed the latest Sun JDK 6 recently, one of the installer wizard screens had a JavaFX logo on it, and I wondered what it was, so I checked it out.  It turns out that JavaFX is a family of products from Sun to compliment Java, specifically geared towards designers and web developers creating dynamic web content.  The Java language was originally supposed to do this anyway, but it never really got off the ground for web content in the face of Flash and Javascript.  Java is a fairly traditional programming language, with it’s syntax based on C and is likely to give any web developers and designers, who aren’t necessarily classically trained programmers, a bit of a shock.  JavaFX contains a completely new language, which is declarative in style, and hence should make it easier to code graphical UIs and content based around concepts like screens, images, animations etc. rather than worry it’s users with threads, memory management and data structures.

Something that also caught my eye was it’s mobile cousin, JavaFX Mobile.  Sun has been successful in getting Java technology into mobile phones, a lot of mobile phones to be precise!  A few minutes of Googling didn’t come up with any actual figures, however I would go so far as to say that Java ME is probably the most ubiquitous general purpose computing application platform on the planet, in terms of numbers of in use handsets today.  I expect actual numbers are available to industry insiders who pay subscriptions to data gathering companies, rather than casual internet searchers!

According to Bruce Hopkins in an article on Sun’s web site, there are Three Reasons Why Your Next Java ME Mobile Application Should Include JavaFX Mobil. I’m not going to be using JavaFX in my next mobile application however, and I’ll explain why in relation to Bruce’s reasons one at a time.

Reason #1: JavaFX is a Brand New Platform and Language With a New Declarative Syntax

A declarative syntax is certainly useful when getting non-programmers to actually produce content for your application.  Looking at it from a mobile games point of view, I work with game and level designers who take an engine that I create and use it to build a game.  This is a two way parallel process, not something that happens in series.  A designer will create an initial specification including a feature set, the programmer will go away and implement that, and then as the level designer (often the same person as before) uses the engine to create and add game content (eg. levels), there will be a back and forth dialog with the programmer as new features are proposed and potentially implemented, bugs ironed out and the newly designer created content fed back into the game build process.

The tools that the programmer creates to give to the designer often contain a scripting language. It would be nice to build a fully featured graphical design tool specific to every game, but time constraints usually prevent that. The designer almost always has to get their hands dirty with some game scripting. This might be in a custom language written by the programmer, or it could be in a general purpose scripting language like Ruby, Lua or Python to name three. Either way, it’s likely to be heavily declarative in nature. The designer will use the script to declare game elements, like the level layout, player start position, enemy positions, enemy types and actions, scripted events keyed to triggers and timers, etc.  In this respect, JavaFX Mobile looks like it might be are great tool, a declarative language already built on top of the game implementation language (Java ME)…

However, as a programmer, have a look at this syntax and see if you’d give it to a designer?

package notifier;

import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.text.Text;
import javafx.scene.text.Font;

var img = Image {
            url: "{__DIR__}email.png"
          }

Stage {
    width: 200
    height: 250
    title: "Mail Notifier"
    scene: Scene {
        content: [

            ImageView {
                image: img
                x: 0
                y: 0
            }

            Text {
                font: Font {
                    size: 16
                }
                x: 10
                y: 140
                content: "New Email Received!"
            }
        ]
    }
}

There are way to many curly brackets for a start, giving you all that nesting to contend with. And look at those square braces in the middle there, what the hell are they suppose to mean? There’s no way I would save any time by giving this to a designer, I’d be constantly hand holding them through the compile errors and reminding them when they need one type of bracket or another.  There are lots of existing scripting languages that have a much cleaner and more natural syntax for ease of use by non-programmers.  Creating your own language can also be an enticing prospect, but it’s not something to get into lightly. Programming language processors and compiler techniques are a highly complex area to deal in, but experience in it can be very valuable. In the tradition of Blue Peter, here’s one I made earlier:

# Level script file.
# Anything after a hash on a line is a comment.
# Case is not important.

# Initialisation section
code=start

# Dimensions (in tiles) and tile size (in pixels)
level dim=54,50 tilesize=16 id=mission3 number=3
      flags=!revealed, !complete, !failed, !shop
      nametext=Text_mission3_name
      introtext=Text_mission3_prologue
      outrotext=Text_mission3_epilogue
      respawn_id=respawn1

# Garret's start position
character type=garrett id=garrett posn=51,48.95 anim=idle:0:left

# 2nd guard in left tower
item type=map id=map3 posn=0,0 flags=hidden,infront
character type=guard id=guard2
          posn=10,23.95
          anim=walk:0:right
          pocket_id=map3
          action=patrolling_left
          end0=left:8,27 end1=right:8,19 look=10 stand=5 health=8 hit=2

# End of initialisation section
endcode

# Triggers that cause things to happen
code=triggers

# Map trigger
trigger action_id=reveal_map when
  test_flags item id=map3 flags=owned
endtrigger

# End of triggers
endcode 

# Actions that are run by triggers
code=actions

# reveal the map
action id=reveal_map
setflags level id=mission3 flags=revealed
endaction

# End of actions
endcode

The comparisons here should be pretty obvious. No braces or nesting to worry about, just 3 separate sections that contain code for different purposes. No import statements, which comes from the domain specific nature of the language. I myself can never remember which package or library a class comes from most of the time, someone scripting for me shouldn’t have to. The one common element between both examples is named parameters. That’s something I would consider essential in any language intended for a non-programmer to use, at least JavaFX has that right.

Reason #2: The JavaFX Platform is a Software Layer Above the JVM

On the surface, this is a pretty good reason to use JavaFX, if it wasn’t for the fact that all those millions of mobile devices available in the shops today won’t support it!  Only the very latest handsets will have support for it included, and the numbers of those sold are going to pale in comparison to the existing device take up figures.  That’s the big problem with mobile development, the massive device fragmentation problem.  I expect that it will take at least 1 years for any new Java ME feature to make it into handsets, and then at least another year on top of that before enough handsets are available to make it worthwhile developers using that feature.  I’m assuming that JavaFX mobile needs device manufacturers to make devices that support it.  It may be possible to code using the JavaFX script and have the source compile to standard Java bytecode that runs on existing MIDP 2.0 devices.  If that’s the case, then fantastic, as long as the required supporting libraries aren’t 100′s of kilobytes big!  There are still phones that only support jars of 64k or less, I’m looking at you Nokia Series 40 v1 devices.

Reason #3: Data Binding with the Bind Keyword

I’ll concede that this feature is quite nice, and certainly makes trivial examples like updating a text field when a slider moves nice and easy.  I’d like to see some more heavyweight usage examples though, and I’d like to see what non-programmer designers make of it.  If programmers are going to be writing the scripts, they’ll probably quite quickly run into it’s limitations and end up writing custom code for all sorts of circumstances.  I won’t rag on this feature too much at the moment though since I’ve got more to learn about it.  One thing I will say though is that it’s simply one language feature, and not something I think should weigh heavily on any decision to use JavaFX in a project or not.

So, there’s a brief look at JavaFX Mobile and why my next mobile application won’t use it. It’s certainly interesting, and might have more relevance to non-game applications, but I predict it won’t be a feature anyone shouts about loudly for very long!

Filed in Articles | No responses yet

Free software worth checking out – TrueCrypt

Steve on Mar 13th 2009

I’ve already done one post about software worth paying for, and I’ve got plenty of other software I want to mention lined up for the future.  However, you don’t necessarily have to pay for software, there’s an astonishing amount of freely available software that won’t cost you a penny.

You probably have data on your PC that you wouldn’t necessarily want other people to be able to see.  It might not be anything too serious, just a few passwords for web sites maybe. Alternatively, you might well have passwords for online banking written down somewhere, and these really should be looked after carefully.  PadlockMaybe you write documents for your job that are confidential or sensitive in nature, or you have personal diaries and journals that are private. Even though you might have to enter a password to log into your PC, that doesn’t mean other people can’t see you data.  On Windows PCs especially, unless you (or your IT department) have done some specific setup and are using special software, anything you put onto the hard drive (or store on a memory stick) is freely available for anyone to look at, if they can physically touch your machine, or indeed if they can dupe you into installing malacious software.

TrueCrypt is free software that solves this problem. It scrambles the data you save to a disc drive, or memory stick using cryptographic algorithms that mean only someone with the pass phrase (or a specially designated key file) can access that data. It will encrypt your hard drive so you need to enter a password before a machine boots if you like. Truecrypt main interfaceYou can also create ‘containers’ that can be accessed just like any other drive on your PC. The difference being that anything written to the TrueCrypt ‘virtual’ drive is securely encrypted. It’s very simple to use, and is available for Windows, Linux and Mac OS X, so transferring data between systems isn’t a worry.

The TrueCrypt web site is easy to understand and contains excellent documentation for a truely useful piece of software.  If you’ve got anything on your PC you want to look after carefully, TrueCrypt will almost certainly be what you’re looking for.

Filed in Software | No responses yet

Free Software – When did Linux get this good?

Steve on Mar 1st 2009

I started writing a post about TrueCrypt as the first in a series about “free software worth checking out” and I found myself going off on the current state of free and open source software.  Rather than bloat out the TrueCrypt post with this guff, I’ve given it it’s own post!

A couple of years ago, I don’t think I would have found myself saying this, but it truely is amazing, the quality of free software available today.  I’m currently writing this blog post on a PC running Ubuntu Linux 8.10 as it’s sole operating system. I’m using Firefox 3 and the blog software running on this website is WordPress.  All of these pieces of software, which have taken countless thousands of man hours to create, don’t cost anything except time to download, install or use, and that time cost is getting less and less it seems.

It wasn’t that long ago that free software took considerable dedication, time and expertise to use. I first started with Linux back in the early 90′s using Slackware, I dabbled again around 2005 with Gentoo.  From then on I’ve occasionally installed Red Hat, maybe SUSE or tried a live CD here and there and generally kept an eye out. Each time I spent any time with Linux though, I always came to the conclusion that anyone without a Computer Science degree wouldn’t stand a chance of getting anywhere with these systems.  I always got what I wanted out of them (an educational experience, a Mythtv PVR, NAS server, etc.), but then I’ve got a Comp/Sci degree and I live and breath computers.  The function was always there, but the barrier to entry was so high, only the few ever got to use it.

Ubuntu changed that for me recently though. I decided to overhaul my PC that had been running Kubuntu for a couple of years. I rarely touched it and it had been pretty much gathering dust.  I remember there were a lot of bugs when I first installed it, and I’d pretty much left it alone, using a Windows laptop for all my home computing needs. To my amazement, the Ubuntu install was painlessly easy.  Upon first boot up, the desktop looked great, it had working sound, needed no network configuration, updated itself automatically and accessed my NAS drive seemlessly.  Crikey, where was the catch?  Surely it wouldn’t be long before I was scouring forums, delving into the command line shell to edit config files and generally getting frustrated about a missing piece of function or funky bug, but that hasn’t happened yet!  Web browsing, email, IM, OpenOffice, Java, video encoding, music playback, video playback, if it didn’t already support such features out of the box, the simple package manager allowed me to add it without any hassles. I would give my wife and my mum  a PC running Ubuntu to use, it’s that easy.  I’m pleased that there really is a serious alternative to Windows these days.

Filed in Software | No responses yet