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.en (5344B)


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