Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

How to write portable Java Games


Published on

A presentation that I've made in JavaOne 2003 about making portable JavaGames....

  • no, nyet, nahi....which part of no don't you understand?
    I'm not interetsed in helpin' yuh
    I'm not yor that?
    Are you sure you want to  Yes  No
    Your message goes here

How to write portable Java Games

  1. 1. How to write portable J2ME games Thomas Landspurg CTO In-Fusio
  2. 2. Objectives <ul><li>Describes some of the issue that needs to be addressed when trying to create a multiplatform J2ME game: </li></ul><ul><ul><li>Graphics </li></ul></ul><ul><ul><li>Memory </li></ul></ul><ul><ul><li>Speed </li></ul></ul><ul><ul><li>Test </li></ul></ul><ul><ul><li>Business Models </li></ul></ul><ul><ul><li>Deployment </li></ul></ul><ul><li>And to share with you some of the ideas that have been used to solve these issues </li></ul>
  3. 3. About In-Fusio <ul><li>Provide Game Services to operators </li></ul><ul><li>First provider in Europe of Downloadable mobile games </li></ul><ul><ul><li>Several thousand of players </li></ul></ul><ul><ul><li>More than 100 000 of download per month, 1M of interactions/month </li></ul></ul><ul><ul><li>And got revenues from this! </li></ul></ul><ul><li>Member of JSR118 Game Expert Group </li></ul><ul><li>Developed his own Downloadable game engine (ExEn) </li></ul>
  4. 4. The dream…. <ul><li>Thanks to J2ME, my application (and more especially my Game) will run on all J2ME compatible devices…. </li></ul>
  5. 5. Reality (sometime!) <ul><li>Yes, you write once, for one device…. </li></ul>
  6. 6. Why….
  7. 7. Graphic diversity <ul><li>One of the biggest issue: </li></ul><ul><ul><li>Screen size are different </li></ul></ul><ul><ul><ul><li>From 86x48 to 236x240 </li></ul></ul></ul><ul><ul><li>Number of colors </li></ul></ul><ul><ul><ul><li>2 to 16 millions </li></ul></ul></ul><ul><ul><li>B&W, Grayscale, Colors </li></ul></ul>
  8. 8. Few ideas and techniques <ul><li>Layout management </li></ul><ul><li>Resource management </li></ul><ul><li>Vector Graphic </li></ul><ul><li>Others: </li></ul><ul><ul><li>Centering </li></ul></ul><ul><ul><li>Rescaling </li></ul></ul>
  9. 9. Game design <ul><li>Include layout management in game design: </li></ul><ul><ul><li>Define what is variable, fixed to left, proportional to screen size, etc… </li></ul></ul>
  10. 10. Game design cont… Other example: Use of tiled background Two different phones use the same graphics, but the game display area is different.
  11. 11. Resource management <ul><li>Do specific version of some resources for different devices (mainly images) </li></ul><ul><li>More complex to handle </li></ul><ul><li>Deployment platform does not always handle this </li></ul>JPIII image JPIII_BW.jar JPIII_ColorSmall.jar JPIII_GrayScale.jar
  12. 12. Vector Graphic approach <ul><li>Instead of using bitmap, use vector gfx </li></ul><ul><ul><li>Pro: </li></ul></ul><ul><ul><ul><li>easily scaleable graphics </li></ul></ul></ul><ul><ul><ul><li>Data space for graphics usually small </li></ul></ul></ul><ul><ul><li>Con: </li></ul></ul><ul><ul><ul><li>not suitable for all games (except 3D ones) </li></ul></ul></ul>
  13. 13. Others techniques <ul><li>Centering or Rescaling </li></ul><ul><ul><li>« cheap » but bad result </li></ul></ul><ul><ul><li>Centering could be used for small screen size differences: </li></ul></ul><ul><ul><ul><li>Ex: go from 86x65 to 100x70 if games is not designed to be scaleable </li></ul></ul></ul><ul><ul><li>Rescaling: </li></ul></ul><ul><ul><ul><li>Actually not possible as there is no API to do this, but could is useable if multiplication factor is an integer: </li></ul></ul></ul><ul><ul><ul><ul><li>Ex: going from 100x64 to 200x128 </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Nice way to provide Wireless game for PDA class devices </li></ul></ul></ul></ul>
  14. 14. Graphics <ul><li>All of the technique could be mixed: </li></ul><ul><ul><li>First find the best graphics that are available for the platform (resource management) </li></ul></ul><ul><ul><li>Then compute the values for the layout </li></ul></ul><ul><ul><li>Finally, if there is still some difficulties, use centering </li></ul></ul>
  15. 15. Memory available <ul><li>Memory between devices differs: </li></ul><ul><ul><li>one game running well on one device may crash on another due to memory issues </li></ul></ul><ul><li>Garbage collection strategy may differ from different devices </li></ul><ul><li>Usually games tends to use maximum of the device memory </li></ul><ul><li>VM implementation may differ from phone to phone </li></ul>
  16. 16. Memory <ul><li>Tips and Tricks: </li></ul><ul><ul><li>Find good balance between global memory use and temporary memory use: </li></ul></ul><ul><ul><ul><li>Ex: don’t put all image in a single file, but don’t make an image object per sprite. </li></ul></ul></ul><ul><ul><li>Reduce number of colors used by images </li></ul></ul><ul><ul><li>Avoid creation of objects during game </li></ul></ul><ul><ul><li>Obfuscator to reduce code size </li></ul></ul><ul><ul><li>Avoid too much OO! </li></ul></ul>
  17. 17. Speed <ul><li>Games needs to run as fast as possible! </li></ul><ul><li>How to make the same game running on a Strong ARM and on a 16 bits proc? </li></ul>
  18. 18. Speed <ul><li>Solutions: </li></ul><ul><ul><li>Two strategies: </li></ul></ul><ul><ul><ul><li>Speed should be maintained – use timer and reduce number of object displayed </li></ul></ul></ul><ul><ul><ul><li>Speed is reduced if handset is slower (usual case) </li></ul></ul></ul><ul><ul><li>Impact of not having the game running at the same speed on several devices: </li></ul></ul><ul><ul><ul><li>Real time multiplayer game: faster device will be advantaged </li></ul></ul></ul><ul><ul><ul><li>Contest (non real time): slower devices will be advantaged, because game will probably be easiest </li></ul></ul></ul>
  19. 19. More specific issues for J2ME games <ul><li>Keyboard: </li></ul><ul><ul><li>Not suited for games, usually only one key pressed at a time </li></ul></ul><ul><li>Backlight: </li></ul><ul><ul><li>Not possible to force backlight on </li></ul></ul>
  20. 20. Multiple APIs <ul><li>Proprietary API </li></ul><ul><ul><ul><li>Game oriented APIs: </li></ul></ul></ul><ul><ul><ul><ul><li>ExEn </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Siemens </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Nokia </li></ul></ul></ul></ul><ul><ul><ul><ul><li>J-Phone </li></ul></ul></ul></ul><ul><ul><ul><ul><li>NTT-Docomo </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Sprint? </li></ul></ul></ul></ul><ul><li>MIDP1.0 or 2.0? </li></ul><ul><ul><li>Transparency or not? </li></ul></ul><ul><ul><li>Game API? </li></ul></ul>
  21. 21. Multiple API <ul><li>Not all the API provide the same level of functionalities: </li></ul><ul><ul><li>Ex: </li></ul></ul><ul><ul><ul><li>Nokia provide low level pixel based API </li></ul></ul></ul><ul><ul><ul><li>Siemens provides high level games API (Tiled Layer) </li></ul></ul></ul><ul><li>Some fast phone (ex: Nextel Motorola phone) can simulate some of the native API </li></ul>
  22. 22. Business Model <ul><li>Different BM may change the Game himself: </li></ul><ul><ul><li>Pay per download? </li></ul></ul><ul><ul><li>Pay per play? </li></ul></ul><ul><ul><li>Pay per time? </li></ul></ul><ul><ul><li>Pay per interaction? </li></ul></ul><ul><ul><li>Different carrier may have different billing needs, and they are not always transparent: </li></ul></ul><ul><ul><ul><li>Ex: SMS for billing </li></ul></ul></ul>
  23. 23. Testing <ul><li>Image that you have to deploy on all the J2ME devices: how to be 100% sure that the game will run perfectly? </li></ul><ul><li>Correction for one devices: does this haves an impact on others? </li></ul><ul><li>How manage unknown devices? </li></ul>
  24. 24. Testing <ul><li>Restrict the number of devices by creating families </li></ul><ul><li>Do some common classes – test them on all devices (and all languages) and reuses them as must as possible – even if these add overhead memory </li></ul>
  25. 25. Tools <ul><li>Tools may help you to save time, by creating automatically specific version for specific handsets </li></ul><ul><li>In-Fusio SDK: </li></ul><ul><ul><li>Notion of criteria's: </li></ul></ul><ul><ul><ul><li>A resource (image, text, sound, even Java Code) can be depend of criteria's </li></ul></ul></ul><ul><ul><ul><li>Example of criteria's: </li></ul></ul></ul><ul><ul><ul><ul><li>Resolution, B&W, operator, language, handset, etc…. </li></ul></ul></ul></ul><ul><ul><ul><li>Then the server manage to get the right version for the right handset, according to criteria's defined by the developer. </li></ul></ul></ul>
  26. 26. Language management <ul><li>If you have to provide your Midlet in several languages, then: </li></ul><ul><ul><li>Make sure that display is correct in every language! (painful for testing) </li></ul></ul>
  27. 27. Conditionnal compilation? <ul><li>Could be a way to solve some of the issues…. </li></ul><ul><li>Does not sounds very good from a design point of view (especially in Java), but life is life… </li></ul>
  28. 28. MIDP 2.0 <ul><li>Future MIDP will help developer to solve some of these issues by: </li></ul><ul><ul><li>Consistent behavior across manufacturers </li></ul></ul><ul><ul><li>Improved speed (native implementation) </li></ul></ul><ul><ul><li>Reduced code size </li></ul></ul>
  29. 29. MIDP2.0 <ul><li>Transparency mandatory </li></ul><ul><li>Triangle filling </li></ul><ul><li>Access to pixel level image </li></ul><ul><li>2D Graphics API: </li></ul><ul><ul><li>Tiled Layer </li></ul></ul><ul><ul><li>Sprite </li></ul></ul><ul><li>Sound </li></ul><ul><li>Key polling </li></ul>
  30. 30. Wireless Game profile proposal <ul><li>JSR178: </li></ul><ul><ul><li>How to deploy games on a wide range of device </li></ul></ul><ul><ul><li>Avoid horizontal fragmentation (different handset haves different APIs) </li></ul></ul><ul><ul><li>Vertical fragmentation (low end vs. high end) </li></ul></ul><ul><ul><li>Intend to address future Wireless Gaming issues: </li></ul></ul><ul><ul><ul><li>3D APIs </li></ul></ul></ul><ul><ul><ul><li>Vector Graphic (Flash?) </li></ul></ul></ul><ul><ul><ul><li>Multiplayer oriented game features </li></ul></ul></ul><ul><ul><ul><li>… </li></ul></ul></ul>
  31. 31. Conclusion: <ul><li>The problematic of Multiplatform must be take in account since the beginning </li></ul><ul><li>It can be solved with </li></ul><ul><ul><li>Experience </li></ul></ul><ul><ul><li>Good tools </li></ul></ul><ul><li>Take times…. </li></ul>
  32. 32. <ul><li>Slides available at </li></ul><ul><li> </li></ul>
  33. 33. Thanks you… <ul><li>In-Fusion: The mobile game connection </li></ul><ul><ul><li> </li></ul></ul><ul><ul><li>Tel : +33 (0)556 799 200 </li></ul></ul><ul><li>Thomas LANDSPURG - CTO </li></ul><ul><ul><li>[email_address] </li></ul></ul>