essytas 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. data/LICENSE +19 -0
  2. data/README +3 -0
  3. data/Rakefile +44 -0
  4. data/bin/essytas +2 -0
  5. data/lib/animation.rb +74 -0
  6. data/lib/config.rb +63 -0
  7. data/lib/core.rb +242 -0
  8. data/lib/cursor.rb +43 -0
  9. data/lib/def/animations/explosion1.anim +103 -0
  10. data/lib/def/characters.def +132 -0
  11. data/lib/def/de/dialogues/test.dlg +4 -0
  12. data/lib/def/de/enemies.trans +6 -0
  13. data/lib/def/de/items.trans +84 -0
  14. data/lib/def/de/skills.trans +48 -0
  15. data/lib/def/de/spells.trans +31 -0
  16. data/lib/def/en/dialogues/test.dlg +4 -0
  17. data/lib/def/en/enemies.trans +6 -0
  18. data/lib/def/en/items.trans +78 -0
  19. data/lib/def/en/skills.trans +48 -0
  20. data/lib/def/en/spells.trans +31 -0
  21. data/lib/def/enemies.def +8 -0
  22. data/lib/def/enemies/wolf.bhv +11 -0
  23. data/lib/def/init.def +5 -0
  24. data/lib/def/items.def +153 -0
  25. data/lib/def/loot.def +2 -0
  26. data/lib/def/particles.def +66 -0
  27. data/lib/def/recipies.def +18 -0
  28. data/lib/def/skills.def +40 -0
  29. data/lib/def/spells.def +42 -0
  30. data/lib/def/spells.rb +16 -0
  31. data/lib/def/weapons.def +9 -0
  32. data/lib/ext/astar/AMap.rb +146 -0
  33. data/lib/ext/astar/node.rb +72 -0
  34. data/lib/ext/astar/priority_queue.rb +44 -0
  35. data/lib/ext/shader.rb +116 -0
  36. data/lib/game/alchemy/recipe.rb +26 -0
  37. data/lib/game/character.rb +102 -0
  38. data/lib/game/combat/bar.rb +119 -0
  39. data/lib/game/combat/battle.rb +345 -0
  40. data/lib/game/combat/control.rb +18 -0
  41. data/lib/game/combat/gui.rb +190 -0
  42. data/lib/game/combat/gui/select_item.rb +11 -0
  43. data/lib/game/combat/gui/select_spell.rb +38 -0
  44. data/lib/game/constitution.rb +48 -0
  45. data/lib/game/equipment.rb +34 -0
  46. data/lib/game/inventory.rb +37 -0
  47. data/lib/game/item.rb +54 -0
  48. data/lib/game/magic.rb +33 -0
  49. data/lib/game/map/events.rb +29 -0
  50. data/lib/game/map/fog.rb +41 -0
  51. data/lib/game/map/map.rb +247 -0
  52. data/lib/game/map/map_animation.rb +26 -0
  53. data/lib/game/map/map_loader.rb +177 -0
  54. data/lib/game/map/map_object.rb +208 -0
  55. data/lib/game/map/map_particle.rb +27 -0
  56. data/lib/game/map/player.rb +78 -0
  57. data/lib/game/map/tile.rb +35 -0
  58. data/lib/game/mind.rb +24 -0
  59. data/lib/game/npc/behaviour.rb +45 -0
  60. data/lib/game/npc/bubble.rb +28 -0
  61. data/lib/game/npc/goal.rb +93 -0
  62. data/lib/game/npc/npc.rb +95 -0
  63. data/lib/game/npc/task.rb +73 -0
  64. data/lib/game/osd/magic.rb +24 -0
  65. data/lib/game/party.rb +42 -0
  66. data/lib/game/skills.rb +64 -0
  67. data/lib/game/spell.rb +35 -0
  68. data/lib/game_window.rb +95 -0
  69. data/lib/glsl/contrast.frag +12 -0
  70. data/lib/glsl/fade.frag +11 -0
  71. data/lib/glsl/mezzotint.frag +20 -0
  72. data/lib/glsl/noise.frag +20 -0
  73. data/lib/glsl/pixelate.frag +42 -0
  74. data/lib/glsl/radialblur.frag +28 -0
  75. data/lib/glsl/sepia.frag +15 -0
  76. data/lib/glsl/shockwave.frag +24 -0
  77. data/lib/glsl/tv_screen.frag +17 -0
  78. data/lib/graphics/animations/credits.txt +1 -0
  79. data/lib/graphics/animations/explosion2.png +0 -0
  80. data/lib/graphics/backgrounds/white_ties_grass.png +0 -0
  81. data/lib/graphics/chars/ejera.png +0 -0
  82. data/lib/graphics/chars/salyjea.png +0 -0
  83. data/lib/graphics/chars/tharat.png +0 -0
  84. data/lib/graphics/combat/tharat.png +0 -0
  85. data/lib/graphics/cursors/normal.png +0 -0
  86. data/lib/graphics/fog/clouds1.png +0 -0
  87. data/lib/graphics/gui/bar_center.png +0 -0
  88. data/lib/graphics/gui/bar_left.png +0 -0
  89. data/lib/graphics/gui/bar_right.png +0 -0
  90. data/lib/graphics/gui/button_background.png +0 -0
  91. data/lib/graphics/gui/button_close.png +0 -0
  92. data/lib/graphics/gui/button_close_hi.png +0 -0
  93. data/lib/graphics/gui/button_highlight.png +0 -0
  94. data/lib/graphics/gui/charequip_background.png +0 -0
  95. data/lib/graphics/gui/charselect_background.png +0 -0
  96. data/lib/graphics/gui/container_background.png +0 -0
  97. data/lib/graphics/gui/drop_item.png +0 -0
  98. data/lib/graphics/gui/equip_Etarae.png +0 -0
  99. data/lib/graphics/gui/equip_Mensch.png +0 -0
  100. data/lib/graphics/gui/equipslot_background.png +0 -0
  101. data/lib/graphics/gui/iteminfo_background.png +0 -0
  102. data/lib/graphics/gui/msg_background.png +0 -0
  103. data/lib/graphics/gui/scrollbar_background.png +0 -0
  104. data/lib/graphics/gui/scroller.png +0 -0
  105. data/lib/graphics/gui/tile_32.png +0 -0
  106. data/lib/graphics/gui/tile_32_highlight.png +0 -0
  107. data/lib/graphics/icons/items/arrow.png +0 -0
  108. data/lib/graphics/icons/items/bandage.png +0 -0
  109. data/lib/graphics/icons/items/boots_leather.png +0 -0
  110. data/lib/graphics/icons/items/bow.png +0 -0
  111. data/lib/graphics/icons/items/credits.txt +8 -0
  112. data/lib/graphics/icons/items/harness_leather.png +0 -0
  113. data/lib/graphics/icons/items/knife.png +0 -0
  114. data/lib/graphics/icons/items/shirt_linen.png +0 -0
  115. data/lib/graphics/items/none.png +0 -0
  116. data/lib/graphics/menu/ingame_background.png +0 -0
  117. data/lib/graphics/menu/ingame_background.xcf +0 -0
  118. data/lib/graphics/menu/start_background.png +0 -0
  119. data/lib/graphics/missing.png +0 -0
  120. data/lib/graphics/osd/magic_bg.png +0 -0
  121. data/lib/graphics/particles/leaf.png +0 -0
  122. data/lib/graphics/particles/smoke.png +0 -0
  123. data/lib/graphics/pixel.png +0 -0
  124. data/lib/graphics/tiles/test.png +0 -0
  125. data/lib/gui/base.rb +278 -0
  126. data/lib/gui/button.rb +93 -0
  127. data/lib/gui/char_equip.rb +118 -0
  128. data/lib/gui/char_selector.rb +54 -0
  129. data/lib/gui/context_menu.rb +115 -0
  130. data/lib/gui/draggable.rb +18 -0
  131. data/lib/gui/grid.rb +118 -0
  132. data/lib/gui/image.rb +17 -0
  133. data/lib/gui/inventory.rb +42 -0
  134. data/lib/gui/item_info.rb +33 -0
  135. data/lib/gui/slider.rb +10 -0
  136. data/lib/gui/textfield.rb +57 -0
  137. data/lib/layer.rb +64 -0
  138. data/lib/load.rb +31 -0
  139. data/lib/main.rb +18 -0
  140. data/lib/maps/def/test.bhv +26 -0
  141. data/lib/maps/def/test.rb +14 -0
  142. data/lib/maps/test.tmx +133 -0
  143. data/lib/maps/test2.tmx +94 -0
  144. data/lib/maps/test3.tmx +29 -0
  145. data/lib/maps/test3_lower.tmx +25 -0
  146. data/lib/maps/test3_upper.tmx +25 -0
  147. data/lib/maps/test_left.tmx +25 -0
  148. data/lib/maps/test_upper.tmx +25 -0
  149. data/lib/music/Butterfly Tea - A New Hope 2K11.mp3 +0 -0
  150. data/lib/music/Greendjohn - Rebirth.mp3 +0 -0
  151. data/lib/music/credits.txt +8 -0
  152. data/lib/parse.rb +605 -0
  153. data/lib/parse_tmx.rb +114 -0
  154. data/lib/particles.rb +127 -0
  155. data/lib/sample.rb +29 -0
  156. data/lib/save.rb +44 -0
  157. data/lib/song.rb +41 -0
  158. data/lib/sounds/click1.wav +0 -0
  159. data/lib/sounds/credits.txt +2 -0
  160. data/lib/sounds/error1.wav +0 -0
  161. data/lib/sprite.rb +35 -0
  162. data/lib/states/menus.rb +17 -0
  163. data/lib/states/menus/alchemy.rb +53 -0
  164. data/lib/states/menus/equip.rb +79 -0
  165. data/lib/states/menus/ingame.rb +34 -0
  166. data/lib/states/menus/magic.rb +31 -0
  167. data/lib/states/menus/options.rb +54 -0
  168. data/lib/states/menus/start.rb +38 -0
  169. data/lib/states/states.rb +154 -0
  170. data/lib/tileset.rb +42 -0
  171. data/lib/tools/world.rb +103 -0
  172. data/lib/tools/worldmap_editor.rb +221 -0
  173. data/lib/translate.rb +368 -0
  174. metadata +255 -0
@@ -0,0 +1,94 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <map version="1.0" orientation="orthogonal" width="20" height="15" tilewidth="32" tileheight="32">
3
+ <tileset firstgid="1" name="Test" tilewidth="32" tileheight="32">
4
+ <image source="../graphics/tiles/test.png" width="256" height="1312"/>
5
+ </tileset>
6
+ <layer name="ground_lowest" width="20" height="15">
7
+ <properties>
8
+ <property name="z" value="1"/>
9
+ </properties>
10
+ <data encoding="csv">
11
+ 1,1,11,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
12
+ 1,1,11,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
13
+ 1,1,11,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
14
+ 1,1,11,11,11,11,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
15
+ 1,1,1,1,1,11,11,11,11,1,1,1,1,1,1,1,1,1,1,1,
16
+ 1,1,1,1,1,1,1,1,11,1,1,1,1,1,1,1,1,1,1,1,
17
+ 1,1,1,1,1,1,1,1,11,11,11,11,11,1,1,1,1,1,1,1,
18
+ 11,11,11,11,11,1,1,11,11,11,11,11,11,1,1,1,1,1,1,1,
19
+ 1,1,1,1,11,11,11,11,11,11,11,11,11,1,1,1,1,1,1,1,
20
+ 1,1,1,1,1,1,1,11,11,11,11,11,11,1,1,1,1,1,1,1,
21
+ 1,1,1,1,1,1,1,1,11,11,11,11,1,1,1,1,1,1,1,1,
22
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
23
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
24
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
25
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
26
+ </data>
27
+ </layer>
28
+ <layer name="ground2" width="20" height="15">
29
+ <properties>
30
+ <property name="z" value="2"/>
31
+ </properties>
32
+ <data encoding="csv">
33
+ 0,10,0,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
34
+ 0,10,0,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
35
+ 0,10,0,3,3,3,4,0,0,0,0,0,0,0,0,0,0,0,0,0,
36
+ 0,10,0,0,0,0,3,3,3,4,0,0,0,0,0,0,0,0,0,0,
37
+ 0,18,19,19,10,0,0,0,0,12,0,0,0,0,0,0,0,0,0,0,
38
+ 0,0,0,0,18,19,19,10,0,3,3,3,3,4,0,0,0,0,0,0,
39
+ 3,3,3,3,3,4,2,3,0,0,0,0,0,12,0,0,0,0,0,0,
40
+ 0,0,0,0,0,3,3,0,0,0,0,0,0,12,0,0,0,0,0,0,
41
+ 19,19,19,10,0,0,0,0,0,0,0,0,0,12,0,0,0,0,0,0,
42
+ 0,0,0,18,19,19,10,0,0,0,0,0,0,12,0,0,0,0,0,0,
43
+ 0,0,0,0,0,0,18,10,0,0,0,0,12,20,0,0,0,0,0,0,
44
+ 0,0,0,0,0,0,0,18,19,19,19,19,20,0,0,0,0,0,0,0,
45
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
46
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
47
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
48
+ </data>
49
+ </layer>
50
+ <layer name="ground3" width="20" height="15">
51
+ <properties>
52
+ <property name="z" value="3"/>
53
+ </properties>
54
+ <data encoding="csv">
55
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
56
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
57
+ 0,0,0,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
58
+ 0,0,0,0,0,0,12,0,0,0,0,0,0,0,0,0,0,0,0,0,
59
+ 0,0,0,0,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
60
+ 0,0,0,0,0,0,0,19,0,12,0,0,0,0,0,0,0,0,0,0,
61
+ 0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,
62
+ 0,0,0,0,0,12,10,0,0,0,0,0,0,0,0,0,0,0,0,0,
63
+ 0,0,0,19,0,0,0,0,0,0,0,0,0,0,0,98,99,100,0,0,
64
+ 0,0,0,0,0,0,19,0,0,0,0,0,0,0,0,106,107,108,0,0,
65
+ 0,0,0,0,0,0,0,19,0,0,0,0,19,0,0,0,0,0,0,0,
66
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
67
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
68
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
69
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
70
+ </data>
71
+ </layer>
72
+ <layer name="air1" width="20" height="15">
73
+ <properties>
74
+ <property name="z" value="400"/>
75
+ </properties>
76
+ <data encoding="csv">
77
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
78
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
79
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
80
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,57,58,59,60,61,0,
81
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,65,66,67,68,69,0,
82
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,73,74,75,76,77,0,
83
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,81,82,83,84,85,0,
84
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,89,90,91,92,93,0,
85
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
86
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
87
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
88
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
89
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
90
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
91
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
92
+ </data>
93
+ </layer>
94
+ </map>
@@ -0,0 +1,29 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <map version="1.0" orientation="orthogonal" width="20" height="15" tilewidth="32" tileheight="32">
3
+ <properties>
4
+ <property name="lower" value="test3_lower"/>
5
+ <property name="upper" value="test3_upper"/>
6
+ </properties>
7
+ <tileset firstgid="1" name="test" tilewidth="32" tileheight="32">
8
+ <image source="../graphics/tiles/test.png" width="256" height="1312"/>
9
+ </tileset>
10
+ <layer name="Tile Layer 1" width="20" height="15">
11
+ <data encoding="csv">
12
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
13
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
14
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
15
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
16
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
17
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
18
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
19
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
20
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
21
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
22
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
23
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
24
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
25
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
26
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
27
+ </data>
28
+ </layer>
29
+ </map>
@@ -0,0 +1,25 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <map version="1.0" orientation="orthogonal" width="20" height="15" tilewidth="32" tileheight="32">
3
+ <tileset firstgid="1" name="test" tilewidth="32" tileheight="32">
4
+ <image source="../graphics/tiles/test.png" width="256" height="1312"/>
5
+ </tileset>
6
+ <layer name="Tile Layer 1" width="20" height="15">
7
+ <data encoding="csv">
8
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
9
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
10
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
11
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
12
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
13
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
14
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
15
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
16
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
17
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
18
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
19
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
20
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
21
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
22
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
23
+ </data>
24
+ </layer>
25
+ </map>
@@ -0,0 +1,25 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <map version="1.0" orientation="orthogonal" width="20" height="15" tilewidth="32" tileheight="32">
3
+ <tileset firstgid="1" name="test" tilewidth="32" tileheight="32">
4
+ <image source="../graphics/tiles/test.png" width="256" height="1312"/>
5
+ </tileset>
6
+ <layer name="Tile Layer 1" width="20" height="15">
7
+ <data encoding="csv">
8
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
9
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
10
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
11
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
12
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
13
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
14
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
15
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
16
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
17
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
18
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
19
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
20
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
21
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
22
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
23
+ </data>
24
+ </layer>
25
+ </map>
@@ -0,0 +1,25 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <map version="1.0" orientation="orthogonal" width="20" height="15" tilewidth="32" tileheight="32">
3
+ <tileset firstgid="1" name="test" tilewidth="32" tileheight="32">
4
+ <image source="../graphics/tiles/test.png" width="256" height="1312"/>
5
+ </tileset>
6
+ <layer name="Tile Layer 1" width="20" height="15">
7
+ <data encoding="csv">
8
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
9
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
10
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
11
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
12
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
13
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
14
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
15
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
16
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
17
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
18
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
19
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
20
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
21
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
22
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
23
+ </data>
24
+ </layer>
25
+ </map>
@@ -0,0 +1,25 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <map version="1.0" orientation="orthogonal" width="20" height="15" tilewidth="32" tileheight="32">
3
+ <tileset firstgid="1" name="test" tilewidth="32" tileheight="32">
4
+ <image source="../graphics/tiles/test.png" width="256" height="1312"/>
5
+ </tileset>
6
+ <layer name="Tile Layer 1" width="20" height="15">
7
+ <data encoding="csv">
8
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
9
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
10
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
11
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
12
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
13
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
14
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
15
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
16
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
17
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
18
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
19
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
20
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
21
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
22
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
23
+ </data>
24
+ </layer>
25
+ </map>
@@ -0,0 +1,8 @@
1
+
2
+ Butterfly Tea - http://www.jamendo.com/en/artist/Butterfly_Tea
3
+ Butterfly Tea - A New Hope 2K11.mp3
4
+
5
+ Greendjohn - http://www.jamendo.com/en/artist/Greendjohn / http://www.greendjohn.net/
6
+ Greendjohn - Rebirth.mp3
7
+
8
+
@@ -0,0 +1,605 @@
1
+
2
+ # Parsers
3
+
4
+ require_relative "game/map/map.rb"
5
+ require_relative "game/item.rb"
6
+ require_relative "game/spell.rb"
7
+ require_relative "game/alchemy/recipe.rb"
8
+
9
+ require_relative "tileset.rb"
10
+ require_relative "layer.rb"
11
+
12
+ require_relative "game/npc/behaviour.rb"
13
+
14
+ # TODO function to look for key in a line and return it; then refactor
15
+
16
+ module Core::Parse
17
+
18
+ class Parser
19
+ def initialize(file, parsables, klass, stfu=false)
20
+ begin
21
+ @file = File.open("#{Core::LIBRARY_PATH}/#{file}")
22
+ rescue
23
+ warn("ERROR: Failed to open file #{file}")
24
+ end
25
+ @parsables = parsables
26
+ @klass = klass
27
+ @stfu = stfu
28
+ end
29
+
30
+ def parse
31
+ parsed = []
32
+ vars = []
33
+ block = false
34
+
35
+ @parsables.each_key { |str|
36
+ vars.push("@#{str}_parsed".to_sym)
37
+ }
38
+
39
+ @file.each_line { |line|
40
+ line.sub!("\n", "")
41
+ if line[0] == "#" or line.length == 0
42
+ break if line.index("#EOF")
43
+ next
44
+ end
45
+ if line[0] == "{"
46
+ block = true
47
+ next
48
+ end
49
+ if line[0] == "}"
50
+ block = false
51
+ parsed.push(@klass.send(:new))
52
+ vars.each { |var|
53
+ parsed.last.ivs(var.to_s[0...-7].to_sym, ivg(var))
54
+ }
55
+ next
56
+ end
57
+ if block
58
+ line.gsub!("\"", "")
59
+ line =~ /(.+)\s\=\s(.+)/
60
+ key = $1
61
+ val = cast_type($2, @parsables[key])
62
+ ivs("@#{key}_parsed".to_sym, val)
63
+ end
64
+ }
65
+ if !@stfu
66
+ puts("INFO: Parsed #{parsed.length} #{File.basename(@file).sub('.def', '')}")
67
+ end
68
+ @file.close
69
+ return parsed
70
+ end
71
+
72
+ private
73
+
74
+ def eval_type(sym)
75
+ case sym
76
+ when :string
77
+ return ""
78
+ when :symbol
79
+ return :nil
80
+ when :int
81
+ return 0
82
+ when :float
83
+ return 0.0
84
+ when :array, :symarray, :intarray
85
+ return []
86
+ when :color
87
+ return Gosu::Color::WHITE
88
+ end
89
+ end
90
+
91
+ def cast_type(str, sym)
92
+ case sym
93
+ when :string
94
+ return str
95
+ when :symbol
96
+ return str.to_sym
97
+ when :int
98
+ return str.to_i
99
+ when :float
100
+ return str.to_f
101
+ when :array
102
+ s = str.gsub!(/\s|\[|\]/, '')
103
+ ary = s.split(',')
104
+ ary.each { |el|
105
+ if el.include?('*')
106
+ a = el.split('*')
107
+ ary.delete(el)
108
+ a[0].to_i.times {
109
+ ary.push(a[1])
110
+ }
111
+ end
112
+ }
113
+ return ary
114
+ when :symarray
115
+ s = str.gsub!(/\s|\[|\]/, '')
116
+ ary = s.split(',')
117
+ ary.each { |el|
118
+ if el.include?('*')
119
+ a = el.split('*')
120
+ ary.delete(el)
121
+ a[0].to_i.times {
122
+ ary.push(a[1])
123
+ }
124
+ end
125
+ }
126
+ return ary.map(&:to_sym)
127
+ when :intarray
128
+ s = str.gsub!(/\s|\[|\]/, '')
129
+ ary = s.split(',')
130
+ ary.each { |el|
131
+ if el.include?('*')
132
+ a = el.split('*')
133
+ ary.delete(el)
134
+ a[0].to_i.times {
135
+ ary.push(a[1])
136
+ }
137
+ end
138
+ }
139
+ return ary.map(&:to_i)
140
+ when :color
141
+ s = str.gsub!(/\s|\[|\]/, '')
142
+ ary = s.split(',')
143
+ ary.each { |el|
144
+ if el.include?('*')
145
+ a = el.split('*')
146
+ ary.delete(el)
147
+ a[0].to_i.times {
148
+ ary.push(a[1])
149
+ }
150
+ end
151
+ }
152
+ ary = ary.map(&:to_i)
153
+ color = Gosu::Color.new(ary[3], ary[0], ary[1], ary[2])
154
+ return color
155
+ when :image
156
+ return Core.sprite(str)
157
+ end
158
+ end
159
+ end
160
+
161
+ def self.map(file, tiny=false)
162
+ return Core::Parse::TMX.parse(file)
163
+ end
164
+
165
+ # TODO create special parser
166
+ def self.particles
167
+ hash = {}
168
+ begin
169
+ file = File.open("#{Core::LIBRARY_PATH}/def/particles.def")
170
+ rescue
171
+ warn("ERROR: Couldn't find particles.def")
172
+ return hash
173
+ end
174
+ block = false
175
+
176
+ name = filename = ""
177
+ mode = :default
178
+ delay = time = fadein = fadeout = 0
179
+ color = 0xffffffff
180
+ xrange = yrange = xoffset = yoffset = (0..0)
181
+ angle = false
182
+
183
+ file.each_line { |line|
184
+ line.sub!("\n", "")
185
+ if line[0] == "#" or line.length == 0
186
+ break if line.index("#EOF")
187
+ next
188
+ end
189
+ if line[0] == "{"
190
+ block = true
191
+ end
192
+ if line[0] == "}"
193
+ block = false
194
+ hash.store(name.to_sym, Core::ParticleEmitter.new(filename, time, fadein, fadeout, color, delay, angle, mode, xrange, yrange, xoffset, yoffset))
195
+ name = filename = ""
196
+ mode = :default
197
+ delay = time = fadein = fadeout = 0
198
+ color = 0xffffffff
199
+ xrange = yrange = xoffset = yoffset = (0..0)
200
+ angle = false
201
+ end
202
+ if block
203
+ if line.start_with?("name")
204
+ line.gsub!(/name *= */, "")
205
+ name = line.gsub("\"", "")
206
+ elsif line.start_with?("file")
207
+ line.gsub!(/file *= */, "")
208
+ filename = line.gsub("\"", "")
209
+ elsif line.start_with?("delay")
210
+ line.gsub!(/delay *= */, "")
211
+ delay = line.gsub("\"", "").to_i
212
+ elsif line.start_with?("time")
213
+ line.gsub!(/time *= */, "")
214
+ time = line.gsub("\"", "").to_i
215
+ elsif line.start_with?("fadein")
216
+ line.gsub!(/fadein *= */, "")
217
+ fadein = line.gsub("\"", "").to_i
218
+ elsif line.start_with?("fadeout")
219
+ line.gsub!(/fadeout *= */, "")
220
+ fadeout = line.gsub("\"", "").to_i
221
+ elsif line.start_with?("mode")
222
+ line.gsub!(/mode *= *:/, "")
223
+ mode = line.gsub("\"", "").to_sym
224
+ elsif line.start_with?("color")
225
+ line.gsub!(/color *= */, "")
226
+ color = parse_int_array(line.gsub("\"", "")).to_color
227
+ elsif line.start_with?("angle")
228
+ line.gsub!(/angle *= */, "")
229
+ angle = line.gsub("\"", "").to_b
230
+ elsif line.start_with?("xrange")
231
+ line.gsub!(/xrange *= */, "")
232
+ xrange = parse_range(line.gsub("\"", ""))
233
+ elsif line.start_with?("yrange")
234
+ line.gsub!(/yrange *= */, "")
235
+ yrange = parse_range(line.gsub("\"", ""))
236
+ elsif line.start_with?("xoffset")
237
+ line.gsub!(/xoffset *= */, "")
238
+ xoffset = parse_range(line.gsub("\"", ""))
239
+ elsif line.start_with?("yoffset")
240
+ line.gsub!(/yoffset *= */, "")
241
+ yoffset = parse_range(line.gsub("\"", ""))
242
+ end
243
+ end
244
+ }
245
+ puts("INFO: Parsed #{hash.length} particles")
246
+ return hash
247
+ end
248
+
249
+ def self.parse_range(str)
250
+ r = (0..0)
251
+ str.gsub!("(", "")
252
+ str.gsub!(")", "")
253
+ first = last = 0
254
+ first = str.gsub(/\D{2,}.+/, "").to_i
255
+ last = str.gsub(/-?\d+\D{2}/, "").to_i
256
+ r = (first..last)
257
+ return r
258
+ end
259
+
260
+ def self.parse_sym_array(str)
261
+ ary = []
262
+ str.gsub!("[", "")
263
+ str.gsub!("]", "")
264
+ str.gsub!(" ", "")
265
+ str.each_line(",") { |c|
266
+ ary.push(c.sub(",", "").to_sym)
267
+ }
268
+ return ary
269
+ end
270
+
271
+ def self.parse_int_array(str)
272
+ ary = []
273
+ str.gsub!("[", "")
274
+ str.gsub!("]", "")
275
+ str.gsub!(" ", "")
276
+ str.each_line(",") { |c|
277
+ ary.push(c.sub(",", "").to_i)
278
+ }
279
+ return ary
280
+ end
281
+
282
+ def self.behaviour(map, npc)
283
+ begin
284
+ file = File.open("#{Core::LIBRARY_PATH}/maps/def/#{map}.bhv", "r")
285
+ block = ary = false
286
+
287
+ b = nil
288
+
289
+ name = array = type = ""
290
+ init = trigger = motion = update = Core::Game::NPC::Task.new([])
291
+
292
+ file.each_line { |line|
293
+ line.sub!("\n", "")
294
+ if line[0] == "#" or line.length == 0
295
+ if line == "#EOF"
296
+ break
297
+ end
298
+ next
299
+ end
300
+ line.lstrip!
301
+ if ary
302
+ if line == "]"
303
+ array.gsub!("<", "")
304
+ array.gsub!(">", "")
305
+ ret = self.task_array(array.split("?"), npc)
306
+ # TODO needs some magic
307
+ case type
308
+ when "init"
309
+ init = ret
310
+ when "trigger"
311
+ trigger = ret
312
+ when "motion"
313
+ motion = ret
314
+ when "update"
315
+ update = ret
316
+ end
317
+ array = ""
318
+ ary = false
319
+ next
320
+ end
321
+ array += "#{line}?"
322
+ next
323
+ end
324
+ if block
325
+ if line.include?("}")
326
+ block = false
327
+ b = Core::Game::NPC::Behaviour.new(npc, init, trigger, motion, update)
328
+ init = trigger = motion = update = Core::Game::NPC::Task.new([])
329
+ break
330
+ end
331
+ type = line.gsub(/\s?=\s?\[/, "")
332
+ ary = true
333
+ else
334
+ if line.include?("{")
335
+ block = true
336
+ name = line.gsub(/\s?\{/, "")
337
+ if npc.properties[:id] != name
338
+ ary = block = false
339
+ next
340
+ end
341
+ end
342
+ end
343
+ }
344
+ file.close
345
+ rescue Errno::ENOENT
346
+ # we dont care about missing definition files
347
+ end
348
+ return b
349
+ end
350
+
351
+ def self.task_array(inp, npc)
352
+ ret = []
353
+ inp.each { |el|
354
+ delete = []
355
+ ary = el.split(" ")
356
+ ary.each { |parm|
357
+ if parm.include?("|")
358
+ if parm.include?("@")
359
+ parm.sub!("@x", "#{npc.x}")
360
+ parm.sub!("@y", "#{npc.y}")
361
+ end
362
+ ary[ary.index(parm)] = parm.to_pos
363
+ next
364
+ elsif ary.first == :msg and parm.include?(":")
365
+ ary[ary.index(parm)] = Core::Trans.dialogue(parm.gsub(":", "").to_sym)
366
+ next
367
+ end
368
+ ary[ary.index(parm)] = parm.to_sym
369
+ }
370
+ ary.compact!
371
+ ret.push(ary)
372
+ }
373
+ ret.compact!
374
+ return Core::Game::NPC::Task.new(ret)
375
+ end
376
+
377
+ # TODO create special parser
378
+ def self.enemy_behaviour(name)
379
+ hash = {}
380
+ begin
381
+ file = File.open("#{Core::LIBRARY_PATH}/def/enemies/#{name}.bhv")
382
+ rescue
383
+ warn("ERROR: Couldn't find enemies/#{name}.bhv")
384
+ return hash
385
+ end
386
+
387
+ actions = [:on_turn, :on_defeat]
388
+ number = 0
389
+ block = false
390
+
391
+ action = nil
392
+ ary = []
393
+
394
+ file.each_line { |line|
395
+ number += 1
396
+ line.gsub!("\n", "")
397
+ if line[0] == "#" or line.length == 0
398
+ if line == "#EOF"
399
+ break
400
+ end
401
+ next
402
+ end
403
+ if line[0] == "{"
404
+ block = true
405
+ elsif line[0] == "}" and block and action
406
+ hash.store(action, ary)
407
+ action = nil
408
+ ary = []
409
+ block = false
410
+ next
411
+ else
412
+ if !action and !block
413
+ action = line.gsub("\"", "").to_sym
414
+ if !actions.include?(action)
415
+ warn("WARNING: Unknown action key #{action} at enemies/#{name}.bhv, line #{number}")
416
+ action = nil
417
+ block = false
418
+ end
419
+ elsif block and action
420
+ ary.push(line.gsub("\"", ""))
421
+ end
422
+ end
423
+ }
424
+ file.close
425
+ return Core::Game::Combat::Behaviour.new(hash)
426
+ end
427
+
428
+ def self.characters
429
+ p = {
430
+ "name" => :string,
431
+ "age" => :int,
432
+ "strength" => :int,
433
+ "weight" => :int,
434
+ "agility" => :int,
435
+ "file" => :string,
436
+ "race" => :string,
437
+ "gender" => :symbol,
438
+ "healing" => :int,
439
+ "crafting" => :int,
440
+ "botany" => :int,
441
+ "healing_magic" => :int,
442
+ "mind" => :int,
443
+ "elemental" => :int,
444
+ "ranged" => :int,
445
+ "melee" => :int,
446
+ }
447
+ chars = Parser.new("def/characters.def", p, Core::Game::Character).parse
448
+ chars.each { |char|
449
+ char.setup
450
+ char.validate
451
+ }
452
+ return chars
453
+ end
454
+
455
+ def self.skills
456
+ p = {
457
+ "name" => :symbol,
458
+ "icon" => :image,
459
+ }
460
+ return Parser.new("def/skills.def", p, Core::Game::Skill).parse
461
+ end
462
+
463
+ def self.recipies
464
+ p = {
465
+ "name" => :symbol,
466
+ "icon" => :image,
467
+ "output" => :symbol,
468
+ "input" => :symarray,
469
+ "level" => :int,
470
+ }
471
+ return Parser.new("def/recipies.def", p, Core::Game::Alchemy::Recipe).parse
472
+ end
473
+
474
+ def self.items
475
+ p = {
476
+ "name" => :symbol,
477
+ "icon" => :string,
478
+ "weight" => :float,
479
+ "effects" => :symarray,
480
+ "type" => :symbol,
481
+ }
482
+ items = Parser.new("def/items.def", p, Core::Game::Item).parse
483
+ items.each { |item|
484
+ icon = item.icon
485
+ item.ivs("@icon".to_sym, Core.sprite("icons/items/#{icon}"))
486
+ item.ivs("@icon_file".to_sym, "icons/items/#{icon}")
487
+ item.ivs("@img".to_sym, Core.sprite("items/#{icon}"))
488
+ }
489
+ return items
490
+ end
491
+
492
+ def self.spells
493
+ p = {
494
+ "name" => :symbol,
495
+ "icon" => :image,
496
+ "type" => :symbol,
497
+ "cost" => :int,
498
+ }
499
+ return Parser.new("def/spells.def", p, Core::Game::Spell).parse
500
+ end
501
+
502
+ def self.enemies
503
+ p = {
504
+ "name" => :symbol,
505
+ "file" => :image,
506
+ "type" => :symbol,
507
+ "strength" => :int,
508
+ "weapons" => :symarray,
509
+ }
510
+ return Parser.new("def/enemies.def", p, Core::Game::Combat::Enemy).parse
511
+ end
512
+
513
+ # TODO create special parser
514
+ def self.weapons
515
+ hash = {}
516
+ begin
517
+ file = File.open("#{Core::LIBRARY_PATH}/def/weapons.def")
518
+ rescue
519
+ warn("ERROR: Couldn't find weapons.def")
520
+ return hash
521
+ end
522
+ block = false
523
+
524
+ name = icon = ""
525
+ type = :melee
526
+ effects = []
527
+
528
+ file.each_line { |line|
529
+ line.gsub!("\n", "")
530
+ if line[0] == "#" or line.length == 0
531
+ if line == "#EOF"
532
+ break
533
+ end
534
+ next
535
+ end
536
+ if line[0] == "{"
537
+ block = true
538
+ end
539
+ if line[0] == "}"
540
+ block = false
541
+ hash.store(name, Core::Game::Combat::Weapon.new(name, type, effects, icon))
542
+ next
543
+ end
544
+ if block
545
+ if line.start_with?("icon")
546
+ line.gsub!(/icon *= */, "")
547
+ icon = line.gsub("\"", "")
548
+ elsif line.start_with?("type")
549
+ line.gsub!(/type *= */, "")
550
+ type = line.gsub("\"", "").to_sym
551
+ elsif line.start_with?("effects")
552
+ line.gsub!(/effects *= */, "")
553
+ effects = parse_sym_array(line.gsub("\"", ""))
554
+ end
555
+ else
556
+ name = line.gsub("\"", "").to_sym
557
+ end
558
+ }
559
+ file.close
560
+ puts("INFO: Parsed #{hash.size} weapons")
561
+ return hash
562
+ end
563
+
564
+ # FIXME bit hacked
565
+ def self.animations
566
+ p = {
567
+ "length" => :int,
568
+ "color" => :color,
569
+ "x" => :float,
570
+ "y" => :float,
571
+ "mode" => :symbol,
572
+ }
573
+ anims = {}
574
+ Dir.new("#{Core::LIBRARY_PATH}/def/animations").each { |file|
575
+ next if file == "." or file == ".."
576
+ frames = Parser.new("def/animations/#{file}", p, Core::Frame, true).parse
577
+ block = false
578
+ @graphic = @split_x = @split_y = @repeat = nil
579
+ f = File.open("#{Core::LIBRARY_PATH}/def/animations/#{file}")
580
+ f.each_line { |line|
581
+ line.gsub!(" ", "")
582
+ if line[0] == '('
583
+ block = true
584
+ next
585
+ end
586
+ if block
587
+ if line[0] == ')'
588
+ anims.store(file.gsub(".anim", "").to_sym, Core::Animation.new(@graphic, @split_x.to_i, @split_y.to_i, @repeat.to_b, frames))
589
+ break
590
+ else
591
+ line.gsub!("\"", "")
592
+ line =~ /(.+)\=(.+)/
593
+ key = $1
594
+ val = $2
595
+ ivs("@#{key}", val)
596
+ end
597
+ end
598
+ }
599
+ f.close
600
+ }
601
+ puts("INFO: Parsed #{anims.size} animations")
602
+ return anims
603
+ end
604
+
605
+ end