Sudoku

Printer-friendly versionSend to friendPDF version
Intermediate

The Sudoku sample illustrates the usage of Streamezzo InstantScript for managing the display and navigation within a Sudoku game.

The main purpose of such implementation is to enable performing complex operations locally on device (i.e. without requiring a connection to the server, like the random Sudoku grid generation, here) but also to reduce the amount of data being transferred from server to client (bad user experience related to latency) and the effort to maintain such implementation (bad developer experience related to code complexity). This application is indeed a fully local application (i.e. not connected).

Screenshots

This sample application relies on Streamezzo Adaptation Framework to offer:

  • layout adaptation to targeted any screen size
  • support of either touchscreen or keyapd equipped devices
  • 2 skins ("basic" and "bamboo") - simply edit Service Settings > Service parameters "adaptation.theme" with value either "basic" or "bamboo"

Splash (basic skin)

   

Game (basic skin)

Splash (bamboo skin)

   

Game (bamboo skin)

Interactions

In order to interact with this application, it is possible to use touchscreen or keypad .

General

  • quit application: click on bottom right part of the footer on screen or press right softkey ([CTRL]+[RIGHT] when using Workbench Developer emulator)

Sudoku

  • restart game (generate new grid): click on bottom left part of the footer on screen or press left softkey ([CTRL]+[LEFT] when using Workbench Developer emulator)
  • select square:
    • click on screen (touchscreen equipped devices)
    • move cursor with joystick (keypad equipped devices)
  • set square value:
    • click on screen (touchscreen equipped devices) to increment or clean current value
    • press either [FIRE] key to increment or numeric key to set corresponding value or [CANCEL] key to clean current value (keypad equipped devices)

Structure of the Project

  • ant: the necessary Ant tasks to build the InstantScript lib (note: you will have to set the JDK path in file local.properties in case you want to use this task to rebuild the lib)
  • doc: the present HTML documentation
  • is: the client-side InstantScript lib subproject files (note: you can use the Ant task to build the library bin)
  • res: the adaptation resources files (layouts, skins and bitmaps)
  • src: the rich media scenes (RSP)

Conception

Scenes conception

The sample project is composed of 4 scenes:

  • splash.rsp (first scene of the service): the splash screen, containing from top to bottom the loading message, the Sudoku logo and the Streamezzo logo
  • sudoku.rsp: defines the UI elements corresponding to the display of the game and includes all InstantScript instructions to manage the game
  • navigation-touchscreen.rsp: simply defines the availed interactions for touchscreen equipped devices
  • navigation-keypad.rsp: simply defines the availed interactions for keypad equipped devices

Layout & Skins conception

The sample project is composed of 2 layouts:

  • splash.xml: defines from top to bottom the loading message area, the Sudoku logo area and the Streamezzo logo area, as specified on the figure above
  • sudoku.rsp: defines from top to bottom the message area, the game grid (divided into 9*9 squares), the footer area (containing the "Restart" and "Quit" buttons), as specified on the figure above

Following the usual good practice the skins assets, to be resized and injected in all areas specified above, are provided in a master resolution of 800*600 pixels.

Game data conception (InstantScript library)

This Java class packaged as an InstantScript library (bin) has been developed and validated completely out of Streamezzo environment. The only thing we have to take care of is to respect the limitations related to InstantScript compared to pure Java coding (refer to Workbench Developer help for more information on this).

The generation of the library bin is operated thanks to the Ant task called generateLibs provided with the sample project.

Debugging

Server-side debugging

This is the most easy part to debug as you can:

  • debug your Java libraries separately from the application itself (and from Streamezzo Workbench Developer environment)
  • use the provided ServiceLogger to log debug information while processing a RSP (including calls to your Java libraries)
  • simply disable the logs according to their level by configuring the logs level in Streamezzo Rich Media Server administration interface (i.e. with no impact on the RSP code itself and without requiring to republish the server-side part of your application); remember to finally tune the logs level appropriately when you will put your application in production

Client-side debugging

Although debugging on client (and even more a script) is usually not that easy, you can take advantage of the logs mechanism provided with the InstantScript Virtual Machine:

  • use an InstantScript variable (like LOGS_ON) to enable/disable logs; remember to finally disable logs when you will put your application in production
  • use VM.log() function to log any useful information

 

We encourage you to use this sample extensively as a reference for similar developments.

AttachmentSize
Sudoku.swz1.6 MB
Share this