2011Developing OWE Application                 1/20/2011
Table of ContentsServer Configuration .......................................................................................
OWE IDE .....................................................................................................................
Server ScriptingOpen Worlds scripting is built upon on OWScript1, an extremely simple scriptinglanguage. OWScript provides...
Widgets and commandsThe Platform handles all transport level IO between the client and server and mandatesa primitive stat...
The client scripts uses the high level client API to send a command number followed by asequence of parameters to its serv...
Core LanguageCommentsOnly line based comments are supported. A comment is indicated by a leading #character.# this is a co...
OperatorsThe usual selection of math and logic operators are supported:        + - * / % == != >= <= <>&& || ! ( )The math...
elsif a > 500     a=a-245     b=b+4else     a=a+10endifThe single line form of if is used if only one statement needs to b...
<statements>        endfuncFor example:func test(int a,string b,double c)    int count    while count<10          count=co...
map.put("a","Apple")map.put("b","Bear")map.put("c","Car")map.put("d","Demolition")There are some limitations however. Only...
Standard LibraryThe standard library is a set of built-in functions provided along side the FSscriptscripting core for dev...
Game session initialization# Controller scriptfunc main()    if CMD_ID == 1        LOG(SESSION_ID + " called start game") ...
# Controller script     func main()         if CMD_ID == 1             # initiate game session         elsif CMD_ID == 2  ...
IO (Input/Output)The IO library abstracts the communication between the client and the server to a seriesof Reads and Writ...
   void WRITE_UTF(string s)    Write a variable length text Java String into the outgoing data stream destined    for the...
Standard ObjectsWhile OWScript does not support object oriented programming constructs, it supportsJava object access (thr...
o   void PUT_UTF(String key, String value)               Associates the specified String value with the specified key in t...
Persistence     Store GET_STORE(string sessionId)      Returns the user specific store for the user associated with the p...
Developing OWE applicationOWE ScriptOWE script development use fscript( embedded in java). The functions on OWE scriptare ...
Connecting client to server.We can make a connection from client to controller using this code.from the controller we can ...
Getting Response from serverThe server will send a response using WRITE_BYTE(), this method can be called on bothcontrolle...
Tutorial: Kitty GuessWe will walk through the Open Worlds sample application Kitty Guess to achieve thefollowing objective...
Start Game       1             -        Wait for another Player                      0                                    ...
The Controller scriptThe Controller script serves to direct the client request into the Game script bytranslating the raw ...
The Game scriptThe game script will have the following segments         Constants         Game state variables         ...
Utility functionsfunc getOpponents(string session)    object opponents = NEW_SET()    opponents.addAll(players)    opponen...
startRoundfunc startRound(string session)    int ret = 1     LOG(session + "s currentRound=" + currentRound)     playerSta...
checkResultfunc checkResult(string session)    int ret = 0     playerStates.put(session, WAITED_RESULT)     int opponentSt...
Tutorial: Structure of your ClientThe client follows a specific flow to its basic functions. This is to ensure consistency...
Login  1) The client is given 2 options when the initial login screen is initialized. This is     either to enter his curr...
Home Screen   1) The home screen displays a list of games that have been downloaded or already      pre-loaded with the cl...
3) Additional details can be required by the client builder, as long the mandatory      fields are implemented.Contact Lis...
Tutorial: Starting with DevStudioDevStudio will be the point of entry for any developer that wishes to create a customOpen...
Create BuildA custom Open Worlds Engine is first created by accessing the “Create Build”. Thissection provides the develop...
Text for Menu Items: These refer to the icons that you wish to upload that will show upon the menu tabs. A strict adherenc...
Create WidgetOnce the Open World Engine build is created and instantiated, the process of buildingwidgets for the build ca...
38
Create ScriptA widget does not do anything without code written for it. In this section, the developerwrites the script th...
Support InformationZingmobile Pte LtdAddress: 229, Mountbatten Road, #02-03, Singapore 398007Support Email: support@open-w...
41
Upcoming SlideShare
Loading in …5
×

Openworld Engine workshop slides

951 views

Published on

ZingMobile

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
951
On SlideShare
0
From Embeds
0
Number of Embeds
28
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Openworld Engine workshop slides

  1. 1. 2011Developing OWE Application 1/20/2011
  2. 2. Table of ContentsServer Configuration .................................................................................................................... 4Widgets and commands ................................................................................................................ 5Core Language .............................................................................................................................. 7 Comments ..................................................................................................................... 7 Variables ....................................................................................................................... 7 Operators ...................................................................................................................... 8 Conditionals .................................................................................................................. 8 Looping ......................................................................................................................... 9 Functions ...................................................................................................................... 9 Arrays............................................................................................................................ 10 Objects .......................................................................................................................... 10Standard Library............................................................................................................................ 12 Cross script invocation................................................................................................... 12 Built in Globals and Variables ........................................................................................ 13 IO (Input/Output) .......................................................................................................... 15 Standard Objects ........................................................................................................... 17 Session Control.............................................................................................................. 18 Collections..................................................................................................................... 18 Persistence .................................................................................................................... 18 General ......................................................................................................................... 19Tutorial Developing OWE application ............................................................................................ 20 OWE Script .................................................................................................................... 20 2
  3. 3. OWE IDE ........................................................................................................................ 20 OWE Development Outline............................................................................................ 20 OWE CLIENT_MAIN ....................................................................................................... 20 OWE SERVER_CONTROLER ............................................................................................ 20 OWE GAME_SCRIPT....................................................................................................... 20Tutorial: Kitty Guess ...................................................................................................................... 23 Game flow ..................................................................................................................... 23 The Controller script ...................................................................................................... 26 The Game script ............................................................................................................ 26 Utility functions ............................................................................................................. 27 startGame ..................................................................................................................... 27Tutorial: Structure of your Client ................................................................................................... 30 Login ............................................................................................................................. 31 Signing Up ..................................................................................................................... 31 Home Screen ................................................................................................................. 32 Marketplace .................................................................................................................. 32 Profile Screen ................................................................................................................ 32 Contact List ................................................................................................................... 33 Instant Messaging ......................................................................................................... 33Tutorial: Starting with DevStudio................................................................................................... 34 Create Build................................................................................................................... 35 Create Widget ............................................................................................................... 37 Create Script.................................................................................................................. 40 Support Information ...................................................................................................... 40 3
  4. 4. Server ScriptingOpen Worlds scripting is built upon on OWScript1, an extremely simple scriptinglanguage. OWScript provides the developer with the basic programming constructs likevariables, operators, conditionals, loops and functions to script the necessary applicationflow.The Open Worlds platform comes with a set of standard library functions whichobjectively supplements OWScript with common functional features used byapplications running on the platform such as I/O, session control, persistence, etc.An Open Worlds server side script is known as a Widget, and a widget is logicallypartitioned into:  Controller Script Handles command processing and routes incoming request to a specific game session. This is "stateless".  Game Script Handles logic for a game session; instance per game session is created by Open worlds platform for every running game. This is “stateful”.The following diagram shows the logical server side scripting stack; the Open Worldsplatform runs and manages independent widgets for different content providers. Figure 1 Server scripting stack1 http://OWScript.sourceforge.net/ 4
  5. 5. Widgets and commandsThe Platform handles all transport level IO between the client and server and mandatesa primitive stateless request-response RPC code model to allow the developer to work atthe highest level of abstraction possible for the nature of applications that the Platformis designed to support.The client will send commands and parameters into the server widget; the serverwidgets controller will receive the command and route it to the game script instance. Game Script Invoke script function Client Script Controller Script COMMAND #nn,payload COMMAND #nn, payload OWE Client Server Scripting Engine Engine HTTP Figure 2 Command request pipeline 5
  6. 6. The client scripts uses the high level client API to send a command number followed by asequence of parameters to its server widget. The OWE client engine handles thetransport and delivery to the server as a HTTP stream. The server receives and translatethe HTTP stream back into the original command number along with the parameters,and pass it into the server widget. The widgets controller script perform the necessaryapplication logics and invokes the necessary function contained in the game script. RESPONSE Figure 3 Command response pipelineThe game script performs the necessary logic and writes a sequence of response back tothe client, completing the request-response flow. 6
  7. 7. Core LanguageCommentsOnly line based comments are supported. A comment is indicated by a leading #character.# this is a commentVariablesThree variable types are supported:  int  string  doubleVariables must be declared before use, the synax is:- int|string|double <varname>[=<expression>][,<varname>*]int counter,b,nstring name,addressdouble valueVariables may also be assigned a value during declarationint counter=0,b,cstring link,path="/home/"+username+"/mydir",tmpstringVariable names must start with A-Z or a-z, but numbers, "." and "_" can also used invariable names.int valid9_variable.name1 7
  8. 8. OperatorsThe usual selection of math and logic operators are supported: + - * / % == != >= <= <>&& || ! ( )The mathematical operators (+ - * / %) are valid for all numeric types. Theoperator + is also valid for string operands (which concatenates the strings).The equality & inequality operators ( == !=) are valid for all types. These operatorsyield an integer 1 or 0 as a result. All logical operators use the C convention of falsebeing zero and true being any non-zero value.The comparison operators ( ><>= <=) can be used to compare any type, again aslong as both operands are the same type. The result is (again) a 1 or 0 integer.The boolean logic operators ( && || ) work only with integer operands.int a=1, b=2int sumdouble average# add then dividesum = a + baverage = sum/2ConditionalsThe sole construct for conditional execution is the if statement.There are two forms of if statements, multi line and single line. Multi-line If statementsmay optionally contain elsif and elseclauses. The then keyword is optional for themulti-line form of if The syntax is : if <expression> [then] <statements> [else <statements>] [elsif <expression> <statements>] endifif a>300 a=a-145 b=b+3 8
  9. 9. elsif a > 500 a=a-245 b=b+4else a=a+10endifThe single line form of if is used if only one statement needs to be executed by theif. There is no provision for else or elsif and the then keyword is notoptional. For example:if a>300 then a=0Note that both elsif and elseif are valid for use in if statements.LoopingThe only loop construct supported by OWScript is while. The syntax is : while <expression> <statements> endwhileFor example:while count<500 count=count+1 value=value+calcvalue(count)endwhileFunctionsOWScript supports the declaration of functions that may return a parameter, and accepta pre-defined set of parameters. Functions may be recursive. It is not legal to nestfunctions in code (i.e. declare functions within functions). Local variables may bedeclared within the function scope. Within a function global scope variables areavailable, and in the event of a naming conflict between the global and local scope, thelocal scope wins. The return keyword can be used to return a value to the calling code.The syntax of a function declaration is: func <function name>([[<param type><param name>][,]]*) 9
  10. 10. <statements> endfuncFor example:func test(int a,string b,double c) int count while count<10 count=count+1 endwhile return countendfuncArraysOWScript does not directly support arrays, however it does support array like access tovariables that are defined in extensions/subclasses of OWScript The syntax is the sameas that found in Java (and C). e.g. <varname>[<subscript>]However in OWScript the subscript can be any supported variable type (string,int oreven double). For example:-thisvar[n]=thatvar[2]MyFunction(thisvar[n+1])In the above example the variables thisvar and thatvar are supplied by the applicationembedding OWScriptObjectsThe object type is a special type used in OWScript to contain objects. There are a fewrules governing its use.An uninitialized variable may be set to any object (either external or one of OWScriptsown types). e.g:object obj1,obj2obj1=create("java.util.HashMap") # assume this creates a HashMap objectobj2="This is a string"# methods are invoked via reflection beneath the hood 10
  11. 11. map.put("a","Apple")map.put("b","Bear")map.put("c","Car")map.put("d","Demolition")There are some limitations however. Only one level of indirection (dots) are allowed e.g.object syssys=getClass("java.lang.System") # assume this creates System objectsys.out.println("Hello") # ERROR! 11
  12. 12. Standard LibraryThe standard library is a set of built-in functions provided along side the FSscriptscripting core for developer use. The library supplements the basic programmingconstructs available in OWScript by pulling down commonly used application featuresinto the platform API level and exposing them to the developer who works at theapplication scripting level via direct function calls.Cross script invocation  CALL(string functionName, ...parameters)Cross script invocation allows a stateless controller script to delegate control to astateful game script. Depending on the nature and complexity of the application, a gamescript may or may not be required. Consider the following examples:-Echo Server - controller only# Controller scriptfunc main() if CMD_ID == 1 LOG("Incoming request from " + SESSION_ID) string msg = READ_UTF () WRITE_UTF("You sent: " + msg) endifendfunc 12
  13. 13. Game session initialization# Controller scriptfunc main() if CMD_ID == 1 LOG(SESSION_ID + " called start game") START_GAME(players) # client now bound to a game script sessioninstance CALL("startGame", SESSION_ID) endifendfunc# Game scriptobject players = NEW_SET() # stateful global variableint CAN_START = 1int WAIT = 0func startGame(string session) players.add(session) if players.size() >= 2 LOG("Game can start now for " + session) WRITE_BYTE(1) else LOG("Need to wait for an opponent") WRITE_BYTE(0) endifendfuncBuilt in Globals and Variables  int SCRIPT_ID This constant holds the widget integer ID of the currently executing script. The application script does not usually need to use this.  int CMD_ID This constant holds the incoming integer ID of the command the client is calling. The application script usually write conditionals around this variable at the stateless controller script to route clients into their respective stateful sessions. E.g. 13
  14. 14. # Controller script func main() if CMD_ID == 1 # initiate game session elsif CMD_ID == 2 # make a move elsif CMD_ID == 3 # check result endif endfunc string SESSION_ID This constant holds the session ID of the incoming client. This is usually used (added to a set) to keep track of how many/which clients are currently participating in a game script session. int PLAYER_TIMEOUT This variable setting controls the maximum duration, in milliseconds, a client can go idle (without sending any commands to the game session) before he is considered to have timed-out. Once a player has timed-out, the state of the game will be flagged as PLAYER_TIMEDOUT. string GAME_STATE This variable holds the current status of the game session, possible values are o “ON_GOING” This indicates a game session is going on normally. This state is usually set by the Platform background game monitor. o “PLAYER_TIMEDOUT” This indicates one or more players in the game session has not contacted the server for the set duration of time. This game session will be swept and removed from the server by the background game monitor after another set duration of time. This state is usually set by the Platform background game monitor. o “ENDED” This indicates that the game session has completed normally, and the background game monitor should remove this game session from the server. This state is usually set by the application script. 14
  15. 15. IO (Input/Output)The IO library abstracts the communication between the client and the server to a seriesof Reads and Writes involving just numbers (Java int primitives) and text (Java Stringobjects). Beneath the hood, variable bit length representations are used for the datatypes transfer, ensuring optimal bandwidth utilization.  String READ_UTF() Read and return a variable length text Java String from the incoming data stream.  int READ_UNSIGNEDSHORT() Read and return a Java primitive int from the incoming data stream. The client is expected to have sent an integer value between 0 through 65,535.  int READ_INT() Read and return a Java primitive int from the incoming data stream. The client is expected to have sent an integer value between -2,147,483,648 through 2,147,483,647.  int READ_BYTE() Read and return a Java primitive int from the incoming data stream. The client is expected to have sent an integer value between-128 through 127.  boolean READ_BOOLEAN() Read and return a Java primitive boolean true/false value from the incoming data stream. 15
  16. 16.  void WRITE_UTF(string s) Write a variable length text Java String into the outgoing data stream destined for the client. void WRITE_UNSIGNEDSHORT(int value) Write a integer value between 0 through 65,535 into the outgoing data stream destined for the client. void WRITE_INT(int value) Write a integer value between -2,147,483,648 through 2,147,483,647 into the outgoing data stream destined for the client. void WRITE_BYTE(int value) Write a integer value between -128 through 127 into the outgoing data stream destined for the client. void WRITE_BOOLEAN(boolean value) Write a boolean true/false value into the outgoing data stream destined for the client. 16
  17. 17. Standard ObjectsWhile OWScript does not support object oriented programming constructs, it supportsJava object access (through reflection). The Standard Library provides feature richstandard objects which encapsulate generic functions and logic for utilization within thescripting layer to achieve functionalities that may not be possible using OWScriptprogramming primitives alone.  Game The Game object is the heart of session management in the platform; the following information are tracked in this stateful object: o Game information Number of players required to start this game o Player information Player sessions that are currently associated with this game o Widget information The Widget that this game belongs to. o Scripts The scripts and their runtime and states that makes up this game. o Game state The current state of the game, whether it is ongoing, timed out or ended gracefully. The Game object exposes these methods: o int getGameId() Returns the unique game session Id, for use in private game room logics. The application scripts usually do not need to explicitly work with this object as the session control library functions will implicitly construct and manipulate the Game object.  Store The Store object is a persistence provision for the application scripts. This is a simple key-value store available for each user per widget application. Data inserted into the store will persist across sessions. Information such as character profiles, scores can be saved here. Widget 1 Widget 2 Widget 3 Store Store Store User The Store object exposes these methods: 17
  18. 18. o void PUT_UTF(String key, String value) Associates the specified String value with the specified key in this store. If this store already contains a mapping for this key, the old String value is overwritten. o void PUT_INT(String key, int value) Associates the specified int value with the specified key in this store. If this store already contains a mapping for this key, the old int value is overwritten. o String GET_UTF(String key) Returns the String value to which the specified key is mapped, or an empty String (“”) if this store contains no mapping for the key. o int GET_INT(String key) Returns the int value to which the specified key is mapped, or the value 0 if this store contains no mapping for the key. o void SAVE() Persists the current state of this store to disk.Session Control  Game START_GAME(int players) Creates, associate the current user and return a public game session requiring a minimum of players players. This game will be used for public matchmaking.  Game CREATE_NEW_PRIVATE_GAME(int players) Creates, associate the current user and return a private game session requiring a minimum of players players. This game will not be used for public matchmaking.  Game JOIN_PRIVATE_GAME(int gameId) Associate the current user with the specific parameter gameId.  Game FIND_GAME_BY_ID(int roomID)Collections  java.util.HashMap NEW_MAP() Returns a new Java HashMap object for scripting use.  java.util.HashSet NEW_SET() Returns a new Java HashSet object for scripting use.  java.util.ArrayList NEW_LIST() Returns a new Java ArrayList object for scripting use. 18
  19. 19. Persistence  Store GET_STORE(string sessionId) Returns the user specific store for the user associated with the parameter sessionId, for the current executing widget.General  void LOG(string msg) Generates a widget logging message into the Platform widget logs. This log may be viewed in the widget logging console in the Platform Dev Studio.  int RANDOM_INT(int max) Returns a random number between 0 and max – 1 inclusive. 19
  20. 20. Developing OWE applicationOWE ScriptOWE script development use fscript( embedded in java). The functions on OWE scriptare defined in java which extends FScript class and called on fscript file. All functions willbe defined on overrided method callFunction().For example, we can call QUIT() function on fscriptOWE IDEIn order to develop application, we absolutely need IDE. This is also applied to OWE,OWE has web based IDE. We can open the IDE in the openworlds site.OWE Development Outline 1. Open OWE IDE http://www.open-worlds.com/ow 2. Create widget. We will be asked to upload apps thumbnail, choose pngpicture which its size is small enough (xx KB). 3. Create script(client fscript, controller server side fscript, game server side fscript). For first trial, we can just create client fscript without connecting to server. 4. Upload image. Uploaded image will be accessed from client fscript.OWE client fscriptprogramming(CLIENT_MAIN)Function should be implemented : init(), update().OWE server fscriptprogramming(SERVER_CONTROLER, GAME_SCRIPT)In controller, we should implement main(). 20
  21. 21. Connecting client to server.We can make a connection from client to controller using this code.from the controller we can send response straight to client using WRITE_BYTE()or we can call function on game script.before make a call to game script function, we should make game object by callingSTART_GAME(), this is required. And from the server game script we will send responseto client. 21
  22. 22. Getting Response from serverThe server will send a response using WRITE_BYTE(), this method can be called on bothcontroller or game script. On client side this response will be catched usingREAD_BYTE().Put it all together 22
  23. 23. Tutorial: Kitty GuessWe will walk through the Open Worlds sample application Kitty Guess to achieve thefollowing objectives:  Understand the RPC based command model of client-server interaction  Understand the Controller and Game scripting contexts  Exercise all of OWScript’s programming constructs  Utilize the Platform’s session management functionalities  Utilize Open Worlds’ Standard Library to realize game functionalitiesGame flowKitty Guess is a game of scissors paper stone involving 2 players consisting of 3 rounds.At the start of each round, each player will submit his choice of move to the Server. Theserver waits for input from both players, compares the moves and sends the results backto the players and ends the round. Players then progress to the next round. The playerwho wins 2 or more rounds wins the game.The game play can be expressed as a series of commands and response exchangesbetween the client and the server: 1. Start Game 2. Start Round 3. Make Choice 4. Check Result 5. Go to step 2 again until game completesThe requirements of our design are as such: 1. The client should be as simplistic as possible, executing the commands in sequence functionally, i.e. make a request call into the server and act on the server’s response code 2. The clients will not communicate with each other, i.e. there is no peer handling logic. 3. Thus, the server will collect keep states for the clients by 4. Receiving and tracking commands and parameters from the client, process the input and 5. Direct the clients’ progress by returning differentiated response codesBased on the above, we describe the client-server exchange as a sequence of commandsas such:Client Client Client Server State ServerAction Command Command Response code Code Parameters 23
  24. 24. Start Game 1 - Wait for another Player 0 Two players available, proceed to start 1 roundStart Round 2 - Wait for opponent to sync 0 Opponent synced, proceed to make choice 1 No more rounds to play, game ended 2Make Choice 3 1 = Scissors Choice received, proceed to check back for 1 2 = Paper result 3 = StoneCheck Result 4 - Wait for opponent to sync 0 You won the round 1 You lost the round 2 It’s a draw 3When waiting for opponent to sync, the client must repeat the requested command,until it gets a different response code from the server. 24
  25. 25. The Controller scriptThe Controller script serves to direct the client request into the Game script bytranslating the raw incoming numerical command code into the servicing function insidethe stateful game script.int players = 2func main() if CMD_ID == 1 LOG(SESSION_ID + " called start game") object game = START_GAME(players) CALL("startGame", SESSION_ID) endif if CMD_ID == 2 LOG(SESSION_ID +" called start round") CALL("startRound", SESSION_ID) endif if CMD_ID == 3 int choice = READ_BYTE() LOG(SESSION_ID + " called makeChoice = " + choice) CALL("makeChoice", SESSION_ID, choice) endif if CMD_ID == 4 LOG(SESSION_ID + " called checkResult") int result = CALL("checkResult", SESSION_ID) endifendfunc 25
  26. 26. The Game scriptThe game script will have the following segments  Constants  Game state variables  Handler functions for each possible client command o startGame o startRound o makeChoice o checkResultConstants and game state variables are declared and initialized at the beginning of thegame script.object playerStates = NEW_MAP()object choices = NEW_MAP()object players = NEW_SET()int currentRound = 0int maxRounds = 3int roundReady = 0int roundStarted = 0int SCISSORS = 1int PAPER = 2int STONE = 3int WIN = 1int LOSE = 2int DRAW = 3int STARTED_GAME = 0int STARTED_ROUND = 1int MADE_CHOICE = 2int WAITED_RESULT = 3int PLAYER_ENDED = 4The object playerStates = NEW_MAP() map is used to keep track of the individualclient states. Together with the int roundReady and int roundStarted flags, they areused to form conditional Boolean barriers to keep the clients in sync.The object players = NEW_SET() set keeps track of the current session Ids of theplayers in this game. 26
  27. 27. Utility functionsfunc getOpponents(string session) object opponents = NEW_SET() opponents.addAll(players) opponents.remove(session) return opponents.iterator()endfuncfunc getOpponentState(string session) object opponents = getOpponents(session) return playerStates.get(opponents.next())endfuncfunc getOpponent(string session) object opponents = getOpponents(session) return opponents.next()endfuncThese functions act on the global players and playerStates objects to return theclient’s opponent’s state and sessionId.startGamefunc startGame(string session) players.add(session) playerStates.put(session, STARTED_GAME) if players.size() >= 2 LOG("game can start now for " + session) WRITE_BYTE(1) else WRITE_BYTE(0) endifendfuncThe server script immediately marks the requesting client to be in the STARTED_GAMEstate. This state capturing idiom is applied throughout the rest of the commandfunctions. 27
  28. 28. startRoundfunc startRound(string session) int ret = 1 LOG(session + "s currentRound=" + currentRound) playerStates.put(session, STARTED_ROUND) int opponentState = getOpponentState (session) if opponentState != STARTED_ROUND && roundStarted == 0 ret = 0 elsif roundStarted == 0 roundStarted = 1 roundReady = 0 currentRound = currentRound + 1 LOG("progressing round! currentRound=" + currentRound) endif if currentRound > maxRounds ret = 2 playerStates.put(session, PLAYER_ENDED) if opponentState == PLAYER_ENDED GAME_STATE = "ENDED" endif endif WRITE_BYTE(ret)endfuncWe observe the first use of the conditional state barrier to keep ensure client synchronyin the first if block; this ensures that clients will progress through the logical commandsequence in tandem with each other.makeChoicefunc makeChoice(string session, int choice) playerStates.put(session, MADE_CHOICE) choices.put(session, choice) WRITE_BYTE(1)endfuncThis function serves only to capture the state and choice of the client. The client shouldimmediately proceed to the next command in the sequence. 28
  29. 29. checkResultfunc checkResult(string session) int ret = 0 playerStates.put(session, WAITED_RESULT) int opponentState = playerStates.get(getOpponent(session)) if opponentState != WAITED_RESULT && roundReady == 0 LOG(session + " blocked by checkResult barrier") WRITE_BYTE(0) return 0 else roundReady = 1 roundStarted = 0 endif int myChoice = choices.get(session) int opponentChoice = choices.get(getOpponent(session)) LOG("Evaluating game result for " + session) if myChoice == SCISSORS if opponentChoice == SCISSORS ret = DRAW elsif opponentChoice == PAPER ret = WIN elsif opponentChoice == STONE ret = LOSE endif elsif myChoice == PAPER if opponentChoice == SCISSORS ret = LOSE elsif opponentChoice == PAPER ret = DRAW elsif opponentChoice == STONE ret = WIN endif elsif myChoice == STONE if opponentChoice == SCISSORS ret = WIN elsif opponentChoice == PAPER ret = LOSE elsif opponentChoice == STONE ret = DRAW endif endif WRITE_BYTE(ret)endfuncThis function places a conditional barrier to ensure both clients has received the roundresult before allowing the game state to progress to the next round.These 4 main command functions which we just covered combine to complete the basicflow of the Kitty Guess game.For a full version of the script involving persistence profile and score tracking, pleaserefer to the example source codes. 29
  30. 30. Tutorial: Structure of your ClientThe client follows a specific flow to its basic functions. This is to ensure consistency andreliability across the user interface.It is mandatory that the 7 indicated sections are included in each build that thedeveloper creates. While the basic build is only restricted to 7 sections for the developerto make use of, advanced users with access to the source code will be able to makemodifications by removing and adding sections to the commong Open Worlds Enginebuild. Profile Open Worlds Market Platform Login Messaging Signup Contacts Home 30
  31. 31. Login 1) The client is given 2 options when the initial login screen is initialized. This is either to enter his current credentials or sign up for a new account. 2) 2 buttons, “Login” and “Sign Up” will only be displayed. 3) User will enter his username and password using the alphabets on his numeric keypad. 4) Upon clicking the “Login” button, he will see the main home screen.Signing Up 1) User will enter the new username and password using the alphabets on his numeric keypad. At this stage of the sign-up process, minimal information is required from the user as he will only update the rest of his particulars on the other screen of the application. 2) Upon clicking the “Sign Up” button; the user will be redirected to the Login screen. 3) The fields in Login screen should be automatically field once the user signs up for the first time. This is to facilitate convenience. 31
  32. 32. Home Screen 1) The home screen displays a list of games that have been downloaded or already pre-loaded with the client. 2) It should be recommended that the games are listed in alphabetical order to minimize confusion when the user wishes to play a game.Marketplace 1) The marketplace should display a list of main categories first, followed by the sub-categories that link to each application or game. 2) Clicking on an application or game will link the user to a download information page. 3) The download information page should contain these details: a. Application / Game Description b. No. Of Players supported c. Price d. “Download Now” button (this will appear by default)Profile Screen 1) The profile screen contains the other details which pertain to the user’s particulars. 2) The basic information needed for this profile screen should be included in all client builds: a. First Name b. Last Name c. Gender d. Age e. Country f. Phone Number 32
  33. 33. 3) Additional details can be required by the client builder, as long the mandatory fields are implemented.Contact List 1) The contact list should contain the user’s contacts in alphabetical order. 2) Contacts are added through the Menu button at the bottom of the screen. 3) Contacts are added with their Username that is registered in the database, and a Nick Name can be used to recognize them.Instant Messaging 1) The screen should show a list of current contacts in alphabetical order. 2) 2 options are shown at the bottom of the menu, “New Message” and “Get Message”. 33
  34. 34. Tutorial: Starting with DevStudioDevStudio will be the point of entry for any developer that wishes to create a customOpen World Engine client and the applications and games to be packaged with it.Each developer will have access to the DevStudio per user account. Special requests canbe made to have multiple accounts per developer, but these are only given on a case-by-case basis.The development cycle for a first-time developer with the Open Worlds Engine is asfollows if a custom build were to be created, then by creation of applications and games.In this flow, “Widget” refers to the Application or Game. Create OWE Build Create Widget Create Script for Widget 34
  35. 35. Create BuildA custom Open Worlds Engine is first created by accessing the “Create Build”. Thissection provides the developer with a variety of cosmetic options to decorate his OWEbuild with.Title: Enter the name of the client that you wish to create. The character limit is 50characters.Extending over: Should you not wish to build a client from scratch, extend its style fromthe list of templates that are available.Title: Enter the name of the client that you wish to create. The character limit is 50characters.ICONS FOR MENUIn Foreground: These refer to the icons that you wish to upload that will show up on themenu tabs. A strict adherence to a size of 30x25 is required to ensure optimal layout.In Background: These refer to the background images that will be used for each screen.Due to the nature of the LWUIT layout engine used, that background images will scaleautomatically based on the resolution of the phone.Available sections that are customized: 1) Home 2) Profile 3) Marketplace 4) Widgets 5) Instant Messaging 6) Contact ListTEXT/IMAGE FOR MENUUse Text or Images: You can be given the option of using plain text or images for yourmenu headers. Menu images should maintain a strict resolution of 50x25. 35
  36. 36. Text for Menu Items: These refer to the icons that you wish to upload that will show upon the menu tabs. A strict adherence to a size of 30x25 is required to ensure optimallayout.Font Styling for Menu Items: Fonts that are used for the menu headers, should text beused, can be given in bold, italic or underline styles.Available sections that are customized: 1) Home 2) Profile 3) Marketplace 4) Widgets 5) Instant Messaging 6) Contact ListUpon submission, the build will be saved and recorded into the database as one of thebuilds in the developer directory. 36
  37. 37. Create WidgetOnce the Open World Engine build is created and instantiated, the process of buildingwidgets for the build can commence.Each widget will be built and attached to the type of build that the developer hascreated. Should the developer have 5 OWE builds, he will have to select which build thewidget should be created for.Title: Enter the name of the widget that you wish to create. The character limit is 50characters.Major Version: Specify the major build number of the widget this is for.Minor Version: Specify the minor build number of the widget this is for. This is useful fordesignating incremental changes to the widget as updates and patches are uploaded.Use generic platform: Check this if you’re prototyping the widget and want to test thison a generic Open Worlds Engine builds. Useful for development purposes.Use customized build: Should you have a list of customized builds that you have created,select the specific build that this widget will be attached to.Upon submission, the widget will be saved and recorded into the database as one of thewidgets in its respective build link. 37
  38. 38. 38
  39. 39. Create ScriptA widget does not do anything without code written for it. In this section, the developerwrites the script that willSelect Widget: Select from a list of widget that you have created so far from the “CreateWidget” section.Resource ID: Specify which ID this widget will conform to. This is useful to developers tokeep track of each Widget they have designed.Code: Implement the code that is required for the widget to function. Do note that imagelinks and variables should still be specified within this area.Upon submission, the widget will be saved and recorded into the database as one of thewidgets in its respective build link. 39
  40. 40. Support InformationZingmobile Pte LtdAddress: 229, Mountbatten Road, #02-03, Singapore 398007Support Email: support@open-worlds.comBugs and Feedback on our product can be directed to feedback@open-worlds.com 40
  41. 41. 41

×