WidSets Developer Rewards 2008

Mobile Radicals
www.mobileradicals.com
hidden

WidSets Game Tutorial

By Will Bamford (updated 24/06/08)

Introduction

This tutorial will guide you through the development of a simple arcade game for WidSets called "Paddle Game". The final game will bear more than a passing resemblance to a popular paddle-and-ball game created over 35 years ago. Although this tutorial will build toward the development of a specific pong-style game, many of the concepts covered are applicable to a wide range of games.

Games represent only one type of widget. However, they are very popular with users and at the time of writing four of the top ten rated widgets on WidSets are games. It is possible to loosely sub-categorise games into turn-based/puzzle and real-time games:

Figure 1 (top). Turn-based/puzzle games (except Breakout).
Figure 2 (bottom). RetroBall game based on this tutorial.

The scope of this tutorial is focused quite narrowly on developing a real-time game and not on game or widget development in general, so we'll try to avoid covering topics that are already well documented in the developer wiki. If you are interested in creating a puzzle game, there is an example of a memory game on the wiki that you might find useful. Where appropriate, links will be provided to relevant pages/sections within the wiki, or other resources, that you should follow in order to gain an understanding of the concepts covered.

It is perhaps best to think of WidSets as a platform for casual games (first person shooters will have to wait). As widget game developers, we should learn to embrace the constraints or as Nokia put it Turn Limitations into Strength. For example, imagine if your game could only use a single button.

WidSets features

Before we go any further, you might be questioning why you should develop for WidSets when there are so many other mobile languages/platforms vying for your attention. Let's list some of the benefits of developing widgets and in particular, WidSets widgets:

  1. Development is free: You don't need to buy certificates, development tools or pay to access developer programs.
  2. Powerful: WidSets is a framework developed on top of Mobile Java (J2ME), therefore many of J2ME's features are also available to developers. Further, because WidSets sits between J2ME and your widget code, it helps smooth over some of the implementation cracks between different Mobile Java implementations. WidSets also adds functionality of its own. For example, there are cool new user-interface components which can be fully customised/skinned with stylesheets. Additionally, many of J2ME's features have been wrapped in a more friendly way (requiring fewer lines of code to do the same thing).
  3. Centralised: WidSets is centralised, which means that communication between your widget and the internet is routed through WidSets' servers. Because of this, WidSets is able to perform complex, time-consuming operations on the server. Examples of this include HTML filtering, XML parsing, image scaling etc. Certain widget parameters can also be stored server-side enabling data persistence.
  4. Speed and ease of development: Widgets with useful functionality can be developed, deployed and updated very quickly. However, simple does not mean trivial. You may be surprised at the range of mobile content/applications that are suitable for widgetisation!
  5. Community: Has a large user-base who can download your widget very easily from the WidSets mobile client (using the library widget) or from the web site. The WidSets community can rate your widgets, so good content will get noticed, rise up the rankings and become more visible to the community which will lead to more positive ratings etc. etc. It is easy to see how this positive feedback mechanism can lead to your widget becoming used by a large number of users in a short space of time. This kind of critical mass effect is analogous to popular videos on YouTube, or top stories on Digg.
  6. Connectivity: There has always been great promise in the mobile world for connecting people but traditionally there have been many barriers (data charges, incompatibility between devices etc.). However, there is a new type of mobile user emerging with unlimited data plans (or WiFi) and powerful handsets. There is a great potential to network these people together to create innovative and compelling new content. With the latest release of WidSets, there is support for creating public and private "channels". These channels will allow users to communicate with each other in real-time i.e. think multiplayer gaming, chat rooms, instant messaging etc. See this video for an early demo of a WidSets multiplayer game
  7. Monetisation: WidSets have recently introduced a mechanism for serving advertisements to the user. If you create a popular widget, there's the potential for revenue share between you and WidSets.

Of course, there are still many situations where you would want to develop for S60 Web Run-Time, J2ME, Symbian, Python etc. However, it's important to note that WidSets represents a viable platform for many kinds of mobile content with unique advantages in some areas.

Getting started with WidSets

Before we go any further, now would be a great time to visit the developer wiki to find out more about WidSets development and how to develop your first widget.

If you've not already done so, register as a WidSets user then download and install the WidSets SDK on your PC. Updates made to your widget can be pushed immediately to the WidSets client on the handset (Figure 3).

Figure 3. Example of push update in WidSets developer client.

All the information you need to get started is on the wiki but if you get stuck, try posting a message on the developer forum. The WidSets developer community is quite small (for now) but very helpful.

After you've got an understanding of what WidSets is about, you'll need to setup your development environment. To create your widget files, all you need is a text editor. Windows Notepad or Emacs will suffice. However, if you want to take advantage of features like syntax highlighting and code folding, you may want to try using EditPlus or UltraEdit and configure them to recognise WidSets source code files (instructions on the wiki).

Whilst developing WidSets widgets, you should probably have at least two tabs open in your browser: The developer wiki and the Apidocs which lists all the classes and methods you can use in your widget (the Apidocs shipped with the SDK may be more up-to-date than on the web site).

This tutorial is now split into three steps. In the first step, we'll develop the foundation for our widget, most of the code presented will be present in all WidSets widgets. In step two, we'll create a framework suitable for any real-time game. In step 3 we'll implement the logic that is specific to our paddle-and-ball game.

Next: Step 1. Creating a widget

Tutorial links