Tutorial #2: Using GMP in a Palm application
These are the steps to getting the GMP game engine working in a Palm WebOS application. Thanks to Nigel Kelly for writing this tutorial!
- Create a new palm app with the name myGmpGame.
- Open the file index.html in the base of the game directory.
- You will see something like the following:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>myGmpGame</title> <script src="/usr/palm/frameworks/mojo/mojo.js" type="text/javascript" x-mojo-version="1" /> <!-- application stylesheet should come in after the one loaded by the framework --> <link href="stylesheets/mygmpgame.css" media="screen" rel="stylesheet" type="text/css" /> </head> <body> <h2>This text verifies your application is running.</h2> <p> To create a fully functional Palm application create a scene and remove this text from index.html. See the documentation on Palm Applications for more information on creating applications and scenes. </p> </body> </html> - The palm mojo framework is already included in the head of the file. To include the GMP game engine, copy the gmp-engine.js file to the base application directory, then add the following lines into the <body> section of index.html:
<script type="text/javascript" src="gmp-engine.1.7.3.js"></script> - Now create a new file called game.js in the base app directory (on the same level as gmp-engine.js). We'll be putting the hello world game tutorial code in here. Include the game.js file in the <body> section, below the gmp-engine.js file, as follows:
<script type="text/javascript" src="gmp-engine.1.7.3.js"></script> <script type="text/javascript" src="game.js"></script> - Now go through the hello world tutorial, and take care to do the following:
- game.js replaces hello-world.js
- mygmpgame.css replaces hello-world.css
- The Palm Pre keyboard has no arrow keys, so change the left and right arrow keys to 'Z' and 'X'
- Now run the app in the device or emulator, and hey presto, you have a new little game to play!


