25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2018-01-26-mahjong-recreation-start.md 3.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. Title: Mahjong recreation start
  2. Date: 2018-01-26 00:00
  3. Category: News
  4. Slug: mahjong-recreation-start
  5. Lang: en
  6. ![Screenshot][screenshot]
  7. This article describes the start of Mahjong game recreation.
  8. **Plan**
  9. We started Mahjong recreation endeavour by composing a brief plan to get gameplay with minimal graphics:
  10. * Load single layout
  11. * Place tiles in layout positions
  12. * Distinguish tiles
  13. * Implement selection
  14. * Implement matching
  15. Just like any other plan, this one looked fine at first sight. However, once you get down to work, new details start to come out. This plan was no exception. Below are a few problems that came out during development.
  16. **Problem №1: provide binary resources across supported platforms**
  17. Mahjong is going to be available on desktop, mobile, and web. Each of these platforms has its constraints on accessing external files:
  18. * Desktop can access almost any file
  19. * Android/iOS have limited access to file system
  20. * Web does not have any file system at all
  21. To provide a unified way for accessing resources, we decided to include them into final executable. This decision led to the birth of **mjin-resource** and **mahjong-data** projects.
  22. [mjin-resource][mjin-resource]:
  23. * converts binary files to C header files with the help of **xxd** utility
  24. * generates MJIN project that contains generated headers to be compiled into static library
  25. * provides C++ interface for accessing generated resources
  26. [mahjong-data][mahjong-data] is an example of such generated MJIN project that is referenced by [mahjong][mahjong] project.
  27. **Problem №2: load PNG images across supported platforms**
  28. To load PNG, we use corresponding OpenSceneGraph plugin. We built it for desktop with no issues. Building for web (Emscripten) turned out to be more difficult: Emscripten provides its own version of **libpng**, which OpenSceneGraph build script can't detect. We had to work around several OpenSceneGraph checks to successfully build the plugin for Emscripten.
  29. Building the plugin for Android and iOS is still waiting for us. Once we get PNG plugin working across supported platforms, we are going to publish a new tutorial for [OpenSceneGraph cross-platform guide][osgcp_guide] to cover PNG image loading. We already got a [request to describe image loading][img_loading_issue].
  30. **Development**
  31. [As you know][lets-go], we published OpenSceneGraph cross-platform guide to make OpenSceneGraph community stronger. We value education, and we love to share our knowledge. That's why we decided to develop Mahjong in small reproducible chunks uniquely identified by internal versions. These versions are available in [mahjong repository][mahjong].
  32. We also provide [version history and web releases of each internal version][web-releases] for the following reasons:
  33. * education: show how development looks like internally
  34. * accessibility: provide older versions for comparison
  35. **Current Mahjong game status**
  36. As of the time of this writing, we have implemented tile selection. [Try it in your browser!][mahjong-version-tile-selection]
  37. Once we finish tile matching implementation, we are going to publish the intermediate result for all supported platforms.
  38. That's it for describing the start of Mahjong game recreation.
  39. [screenshot]: {attach}/images/2018-01-26-mahjong-recreation-start.png
  40. [mjin-resource]: https://bitbucket.org/ogstudio/mjin-resource
  41. [mahjong]: https://bitbucket.org/ogstudio-games/mahjong
  42. [mahjong-data]: https://bitbucket.org/ogstudio-games/mahjong-data
  43. [osgcp_guide]: https://github.com/ogstudio/openscenegraph-cross-platform-guide
  44. [img_loading_issue]: https://github.com/OGStudio/openscenegraph-cross-platform-guide/issues/4
  45. [lets-go]: {filename}/articles/2017-03-16_lets-go.md
  46. [web-releases]: http://ogstudio.github.io/game-mahjong
  47. [mahjong-version-tile-selection]: https://ogstudio.github.io/game-mahjong/versions/010/mjin-player.html