logo

libbulletml

Library of Bullet Markup Language (forked from https://shinh.skr.jp/libbulletml/index_en.html )git clone https://hacktivis.me/git/libbulletml.git

README.md (4726B)


  1. # libBulletML
  2. This is a library to parse (Bullet Markup Language)[http://www.asahi-net.or.jp/~cs8k-cyu/bulletml/index_e.html] files.
  3. ## Dependencies
  4. - POSIX environment with make
  5. - A Yacc implementation (supported: bison, byacc)
  6. - C++11 compiler (supported: gcc, clang)
  7. ## Tutorial
  8. This library's basic usage is event driven model.
  9. 0. Get XML file written in BulletML.
  10. You can use BulletML file in "siroi danmakukun". (bosses.d/*.xml in
  11. archive)
  12. 1. Include headers
  13. ```c++
  14. #include "bulletml/bulletmlparser.h"
  15. #include "bulletml/bulletmlparser-tinyxml.h"
  16. #include "bulletml/bulletmlrunner.h"
  17. ```
  18. 2. Create class that inherits `BulletMLRunner`
  19. ```c++
  20. class BulletCommand : public BulletMLRunner {
  21. // ...
  22. // the bullet you will handle
  23. Bullet* bullet_;
  24. }
  25. ```
  26. 3. Implement all pure virtual function defined in bulletmlrunner.h
  27. For example:
  28. ```c++
  29. class BulletCommand : public BulletMLRunner {
  30. virtual void doVanish() {
  31. bullet_->die();
  32. }
  33. // ... and other pure virtual functions
  34. }
  35. ```
  36. `createSimpleBullet` and `createBullet` method should be implemented
  37. carefully. In libBulletML, all bullets are divided to two
  38. types. `createSimpleBullet` type does not have `<action>`, `createBullet`
  39. type has `<action>`. For example, "siroi danmakukun" uses two class:
  40. Shot and Enemy.
  41. When libBulletML handle `<fire>` element that does not have `<action>`
  42. element, BulletMLRunner calls `createSimpleBullet` method with two
  43. arguments: `direction` and `speed`.
  44. In the other hand, if `<fire>` element has `<action>` element,
  45. BulletMLRunner calls `createBullet` method with three arguments:
  46. `direction`, `speed`, and `state`. You should not care the detail of the
  47. state argument. But it should be given to the class derived from
  48. BulletMLRunner in its constructor. The creation of this class is
  49. described in next section.
  50. 4. Create of the class derived from BulletMLRunner
  51. In libBulletML, the batteries are divided two types. One type is the
  52. battery that is defined in <action label="top"> (first order battery),
  53. and one type is the battery that is created by the other battery
  54. (second, third, forth... battery).
  55. Then, you should create two constructors to handle these two kind of
  56. batteries.
  57. For example, first order battery is implemented like following:
  58. ```c++
  59. BulletCommand::BulletCommand(BulletMLParser* bp, Bullet* b)
  60. : BulletMLRunner(bp), bullet_(b)
  61. ``
  62. For example, second, third... order battery is implemented like following:
  63. ```c++
  64. BulletCommand::BulletCommand(BulletMLState* bs, Bullet* b)
  65. : BulletMLRunner(bs), bullet_(b)
  66. ```
  67. You should call this constructor when createBullet method is called.
  68. 5. Create BulletML document
  69. ```c++
  70. BulletMLParser* bp = new BulletMLParserTinyXML("foo.xml");
  71. bp->build();
  72. ```
  73. Because parsing BulletML is slow, all xml files should be loaded in
  74. the initialization of the program.
  75. 6. Create first order battery
  76. ```c++
  77. BulletCommand* bc = new BulletCommand(bp)
  78. ```
  79. 7. Run BulletCommand in all turn.
  80. ```c++
  81. while (1) {
  82. // the main loop of game
  83. bc->run();
  84. }
  85. ```
  86. If some errors are occured, libBulletML throws BulletMLError. You can
  87. catch this exception.
  88. * Modified BSD License
  89. Copyright (c) 2003, shinichiro.h All rights reserved.
  90. Redistribution and use in source and binary forms, with or without
  91. modification, are permitted provided that the following conditions are
  92. met:
  93. * Redistributions of source code must retain the above copyright
  94. notice, this list of conditions and the following disclaimer.
  95. * Redistributions in binary form must reproduce the above
  96. copyright notice, this list of conditions and the following
  97. disclaimer in the documentation and/or other materials provided
  98. with the distribution.
  99. * The name of the author may not be used to endorse or promote
  100. products derived from this software without specific prior
  101. written permission.
  102. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  103. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  104. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  105. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  106. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  107. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  108. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  109. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  110. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  111. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  112. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  113. shinichiro.h
  114. s31552@mail.ecc.u-tokyo.ac.jp
  115. http://user.ecc.u-tokyo.ac.jp/~s