ruby2d 0.11.0 → 0.11.3

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 (404) hide show
  1. checksums.yaml +4 -4
  2. data/assets/include/SDL2/SDL.h +108 -14
  3. data/assets/include/SDL2/SDL_assert.h +81 -50
  4. data/assets/include/SDL2/SDL_atomic.h +135 -35
  5. data/assets/include/SDL2/SDL_audio.h +960 -355
  6. data/assets/include/SDL2/SDL_bits.h +11 -6
  7. data/assets/include/SDL2/SDL_blendmode.h +91 -14
  8. data/assets/include/SDL2/SDL_clipboard.h +30 -7
  9. data/assets/include/SDL2/SDL_config.h +3 -1
  10. data/assets/include/SDL2/SDL_config_android.h +11 -1
  11. data/assets/include/SDL2/SDL_config_emscripten.h +216 -0
  12. data/assets/include/SDL2/SDL_config_iphoneos.h +9 -1
  13. data/assets/include/SDL2/SDL_config_macosx.h +16 -2
  14. data/assets/include/SDL2/SDL_config_minimal.h +4 -1
  15. data/assets/include/SDL2/SDL_config_os2.h +37 -20
  16. data/assets/include/SDL2/SDL_config_pandora.h +6 -1
  17. data/assets/include/SDL2/SDL_config_psp.h +8 -8
  18. data/assets/include/SDL2/SDL_config_windows.h +39 -22
  19. data/assets/include/SDL2/SDL_config_winrt.h +23 -8
  20. data/assets/include/SDL2/SDL_config_wiz.h +6 -1
  21. data/assets/include/SDL2/SDL_copying.h +1 -1
  22. data/assets/include/SDL2/SDL_cpuinfo.h +331 -71
  23. data/assets/include/SDL2/SDL_egl.h +906 -280
  24. data/assets/include/SDL2/SDL_endian.h +101 -47
  25. data/assets/include/SDL2/SDL_error.h +70 -19
  26. data/assets/include/SDL2/SDL_events.h +387 -79
  27. data/assets/include/SDL2/SDL_filesystem.h +73 -64
  28. data/assets/include/SDL2/SDL_gamecontroller.h +585 -125
  29. data/assets/include/SDL2/SDL_gesture.h +36 -6
  30. data/assets/include/SDL2/SDL_haptic.h +304 -210
  31. data/assets/include/SDL2/SDL_hidapi.h +451 -0
  32. data/assets/include/SDL2/SDL_hints.h +1286 -897
  33. data/assets/include/SDL2/SDL_joystick.h +577 -130
  34. data/assets/include/SDL2/SDL_keyboard.h +162 -63
  35. data/assets/include/SDL2/SDL_keycode.h +7 -5
  36. data/assets/include/SDL2/SDL_loadso.h +42 -8
  37. data/assets/include/SDL2/SDL_locale.h +34 -32
  38. data/assets/include/SDL2/SDL_log.h +212 -19
  39. data/assets/include/SDL2/SDL_main.h +72 -17
  40. data/assets/include/SDL2/SDL_messagebox.h +70 -23
  41. data/assets/include/SDL2/SDL_metal.h +27 -32
  42. data/assets/include/SDL2/SDL_misc.h +19 -15
  43. data/assets/include/SDL2/SDL_mouse.h +262 -110
  44. data/assets/include/SDL2/SDL_mutex.h +286 -66
  45. data/assets/include/SDL2/SDL_name.h +1 -1
  46. data/assets/include/SDL2/SDL_opengl.h +1 -1
  47. data/assets/include/SDL2/SDL_opengles.h +1 -1
  48. data/assets/include/SDL2/SDL_opengles2.h +2 -2
  49. data/assets/include/SDL2/SDL_pixels.h +199 -34
  50. data/assets/include/SDL2/SDL_platform.h +39 -2
  51. data/assets/include/SDL2/SDL_power.h +23 -10
  52. data/assets/include/SDL2/SDL_quit.h +1 -1
  53. data/assets/include/SDL2/SDL_rect.h +78 -28
  54. data/assets/include/SDL2/SDL_render.h +1204 -472
  55. data/assets/include/SDL2/SDL_revision.h +2 -2
  56. data/assets/include/SDL2/SDL_rwops.h +605 -33
  57. data/assets/include/SDL2/SDL_scancode.h +1 -1
  58. data/assets/include/SDL2/SDL_sensor.h +76 -42
  59. data/assets/include/SDL2/SDL_shape.h +38 -27
  60. data/assets/include/SDL2/SDL_stdinc.h +96 -24
  61. data/assets/include/SDL2/SDL_surface.h +571 -139
  62. data/assets/include/SDL2/SDL_system.h +339 -101
  63. data/assets/include/SDL2/SDL_syswm.h +50 -20
  64. data/assets/include/SDL2/SDL_test.h +1 -1
  65. data/assets/include/SDL2/SDL_test_assert.h +2 -2
  66. data/assets/include/SDL2/SDL_test_common.h +23 -6
  67. data/assets/include/SDL2/SDL_test_compare.h +1 -1
  68. data/assets/include/SDL2/SDL_test_crc32.h +1 -1
  69. data/assets/include/SDL2/SDL_test_font.h +3 -3
  70. data/assets/include/SDL2/SDL_test_fuzzer.h +28 -26
  71. data/assets/include/SDL2/SDL_test_harness.h +6 -6
  72. data/assets/include/SDL2/SDL_test_images.h +1 -1
  73. data/assets/include/SDL2/SDL_test_log.h +1 -1
  74. data/assets/include/SDL2/SDL_test_md5.h +1 -1
  75. data/assets/include/SDL2/SDL_test_memory.h +1 -1
  76. data/assets/include/SDL2/SDL_test_random.h +2 -2
  77. data/assets/include/SDL2/SDL_thread.h +226 -128
  78. data/assets/include/SDL2/SDL_timer.h +129 -22
  79. data/assets/include/SDL2/SDL_touch.h +48 -8
  80. data/assets/include/SDL2/SDL_ttf.h +102 -9
  81. data/assets/include/SDL2/SDL_types.h +1 -1
  82. data/assets/include/SDL2/SDL_version.h +72 -46
  83. data/assets/include/SDL2/SDL_video.h +1266 -460
  84. data/assets/include/SDL2/SDL_vulkan.h +100 -161
  85. data/assets/include/SDL2/begin_code.h +22 -1
  86. data/assets/include/SDL2/close_code.h +1 -1
  87. data/assets/include/mrbconf.h +234 -0
  88. data/assets/include/mruby/array.h +317 -0
  89. data/assets/include/mruby/boxing_nan.h +130 -0
  90. data/assets/include/mruby/boxing_no.h +58 -0
  91. data/assets/include/mruby/boxing_word.h +205 -0
  92. data/assets/include/mruby/class.h +108 -0
  93. data/assets/include/mruby/common.h +92 -0
  94. data/assets/include/mruby/compile.h +210 -0
  95. data/assets/include/mruby/data.h +76 -0
  96. data/assets/include/mruby/debug.h +66 -0
  97. data/assets/include/mruby/dump.h +158 -0
  98. data/assets/include/mruby/endian.h +44 -0
  99. data/assets/include/mruby/error.h +137 -0
  100. data/assets/include/mruby/gc.h +92 -0
  101. data/assets/include/mruby/hash.h +242 -0
  102. data/assets/include/mruby/irep.h +147 -0
  103. data/assets/include/mruby/istruct.h +50 -0
  104. data/assets/include/mruby/khash.h +284 -0
  105. data/assets/include/mruby/numeric.h +169 -0
  106. data/assets/include/mruby/object.h +43 -0
  107. data/assets/include/mruby/opcode.h +43 -0
  108. data/assets/include/mruby/ops.h +122 -0
  109. data/assets/include/mruby/presym/disable.h +70 -0
  110. data/assets/include/mruby/presym/enable.h +37 -0
  111. data/assets/include/mruby/presym/scanning.h +73 -0
  112. data/assets/include/mruby/presym.h +40 -0
  113. data/assets/include/mruby/proc.h +209 -0
  114. data/assets/include/mruby/range.h +79 -0
  115. data/assets/include/mruby/re.h +16 -0
  116. data/assets/include/mruby/string.h +469 -0
  117. data/assets/include/mruby/throw.h +66 -0
  118. data/assets/include/mruby/value.h +400 -0
  119. data/assets/include/mruby/variable.h +140 -0
  120. data/assets/include/mruby/version.h +143 -0
  121. data/assets/include/mruby.h +1444 -0
  122. data/assets/macos/universal/bin/mrbc +0 -0
  123. data/assets/macos/universal/lib/libFLAC.a +0 -0
  124. data/assets/macos/universal/lib/libSDL2.a +0 -0
  125. data/assets/macos/universal/lib/libSDL2_image.a +0 -0
  126. data/assets/macos/{lib → universal/lib}/libSDL2_mixer.a +0 -0
  127. data/assets/macos/universal/lib/libSDL2_ttf.a +0 -0
  128. data/assets/macos/universal/lib/libfreetype.a +0 -0
  129. data/assets/macos/universal/lib/libgraphite2.a +0 -0
  130. data/assets/macos/universal/lib/libharfbuzz.a +0 -0
  131. data/assets/macos/universal/lib/libjpeg.a +0 -0
  132. data/assets/macos/universal/lib/libmodplug.a +0 -0
  133. data/assets/macos/{lib → universal/lib}/libmpg123.a +0 -0
  134. data/assets/{mingw/lib/libSDL2.a → macos/universal/lib/libmruby.a} +0 -0
  135. data/assets/macos/{lib → universal/lib}/libogg.a +0 -0
  136. data/assets/macos/universal/lib/libpng16.a +0 -0
  137. data/assets/macos/universal/lib/libtiff.a +0 -0
  138. data/assets/macos/universal/lib/libvorbis.a +0 -0
  139. data/assets/macos/universal/lib/libvorbisfile.a +0 -0
  140. data/assets/macos/universal/lib/libwebp.a +0 -0
  141. data/assets/test_media/README.md +3 -0
  142. data/assets/test_media/bitstream_vera/COPYRIGHT.txt +124 -0
  143. data/assets/test_media/bitstream_vera/vera.ttf +0 -0
  144. data/assets/test_media/boom.png +0 -0
  145. data/assets/test_media/coin.png +0 -0
  146. data/assets/test_media/colors.png +0 -0
  147. data/assets/test_media/controller.png +0 -0
  148. data/assets/test_media/dial.wav +0 -0
  149. data/assets/test_media/hero.png +0 -0
  150. data/assets/test_media/image.bmp +0 -0
  151. data/assets/test_media/image.jpg +0 -0
  152. data/assets/test_media/image.png +0 -0
  153. data/assets/test_media/music.flac +0 -0
  154. data/assets/test_media/music.mp3 +0 -0
  155. data/assets/test_media/music.ogg +0 -0
  156. data/assets/test_media/music.wav +0 -0
  157. data/assets/test_media/originals/boom.pxm +0 -0
  158. data/assets/test_media/originals/coin.pxm +0 -0
  159. data/assets/test_media/originals/controller.sketch +0 -0
  160. data/assets/test_media/originals/hero.pxm +0 -0
  161. data/assets/test_media/originals/image.pxm +0 -0
  162. data/assets/test_media/originals/music.caf +0 -0
  163. data/assets/test_media/originals/texture_atlas.pxm +0 -0
  164. data/assets/test_media/rondo_alla_turka.ogg +0 -0
  165. data/assets/test_media/sound.flac +0 -0
  166. data/assets/test_media/sound.mp3 +0 -0
  167. data/assets/test_media/sound.ogg +0 -0
  168. data/assets/test_media/sound.wav +0 -0
  169. data/assets/test_media/sprite_sheet.png +0 -0
  170. data/assets/test_media/texture_atlas.png +0 -0
  171. data/assets/wasm/libmruby.a +0 -0
  172. data/assets/wasm/template.html +64 -0
  173. data/assets/windows/glew/README.md +10 -0
  174. data/assets/windows/glew/glew.h +23686 -0
  175. data/assets/{mingw/lib → windows/glew}/libglew32.a +0 -0
  176. data/assets/windows/mingw-w64-ucrt-x86_64/bin/mrbc.exe +0 -0
  177. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libFLAC.a +0 -0
  178. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libLerc.a +0 -0
  179. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libSDL2.a +0 -0
  180. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libSDL2_image.a +0 -0
  181. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libSDL2_mixer.a +0 -0
  182. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libSDL2_ttf.a +0 -0
  183. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libbrotlicommon.a +0 -0
  184. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libbrotlidec.a +0 -0
  185. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libbz2.a +0 -0
  186. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libdeflate.a +0 -0
  187. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libfreetype.a +0 -0
  188. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libglew32.a +0 -0
  189. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libgraphite2.a +0 -0
  190. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libharfbuzz.a +0 -0
  191. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libjbig.a +0 -0
  192. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libjpeg.a +0 -0
  193. data/assets/windows/mingw-w64-ucrt-x86_64/lib/liblzma.a +0 -0
  194. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libmodplug.a +0 -0
  195. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libmpg123.a +0 -0
  196. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libmruby.a +0 -0
  197. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libogg.a +0 -0
  198. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libopus.a +0 -0
  199. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libopusfile.a +0 -0
  200. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libpng16.a +0 -0
  201. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libsndfile.a +0 -0
  202. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libssp.a +0 -0
  203. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libstdc++.a +0 -0
  204. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libtiff.a +0 -0
  205. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libvorbis.a +0 -0
  206. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libvorbisfile.a +0 -0
  207. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libwebp.a +0 -0
  208. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libz.a +0 -0
  209. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libzstd.a +0 -0
  210. data/assets/windows/mingw-w64-x86_64/bin/mrbc.exe +0 -0
  211. data/assets/windows/mingw-w64-x86_64/lib/libFLAC.a +0 -0
  212. data/assets/windows/mingw-w64-x86_64/lib/libLerc.a +0 -0
  213. data/assets/windows/mingw-w64-x86_64/lib/libSDL2.a +0 -0
  214. data/assets/windows/mingw-w64-x86_64/lib/libSDL2_image.a +0 -0
  215. data/assets/windows/mingw-w64-x86_64/lib/libSDL2_mixer.a +0 -0
  216. data/assets/windows/mingw-w64-x86_64/lib/libSDL2_ttf.a +0 -0
  217. data/assets/windows/mingw-w64-x86_64/lib/libbrotlicommon.a +0 -0
  218. data/assets/windows/mingw-w64-x86_64/lib/libbrotlidec.a +0 -0
  219. data/assets/windows/mingw-w64-x86_64/lib/libbz2.a +0 -0
  220. data/assets/windows/mingw-w64-x86_64/lib/libdeflate.a +0 -0
  221. data/assets/windows/mingw-w64-x86_64/lib/libfreetype.a +0 -0
  222. data/assets/windows/mingw-w64-x86_64/lib/libglew32.a +0 -0
  223. data/assets/windows/mingw-w64-x86_64/lib/libgraphite2.a +0 -0
  224. data/assets/windows/mingw-w64-x86_64/lib/libharfbuzz.a +0 -0
  225. data/assets/windows/mingw-w64-x86_64/lib/libjbig.a +0 -0
  226. data/assets/windows/mingw-w64-x86_64/lib/libjpeg.a +0 -0
  227. data/assets/windows/mingw-w64-x86_64/lib/liblzma.a +0 -0
  228. data/assets/windows/mingw-w64-x86_64/lib/libmodplug.a +0 -0
  229. data/assets/windows/mingw-w64-x86_64/lib/libmpg123.a +0 -0
  230. data/assets/windows/mingw-w64-x86_64/lib/libmruby.a +0 -0
  231. data/assets/windows/mingw-w64-x86_64/lib/libogg.a +0 -0
  232. data/assets/windows/mingw-w64-x86_64/lib/libopus.a +0 -0
  233. data/assets/windows/mingw-w64-x86_64/lib/libopusfile.a +0 -0
  234. data/assets/windows/mingw-w64-x86_64/lib/libpng16.a +0 -0
  235. data/assets/windows/mingw-w64-x86_64/lib/libsndfile.a +0 -0
  236. data/assets/windows/mingw-w64-x86_64/lib/libssp.a +0 -0
  237. data/assets/windows/mingw-w64-x86_64/lib/libstdc++.a +0 -0
  238. data/assets/windows/mingw-w64-x86_64/lib/libtiff.a +0 -0
  239. data/assets/windows/mingw-w64-x86_64/lib/libvorbis.a +0 -0
  240. data/assets/windows/mingw-w64-x86_64/lib/libvorbisfile.a +0 -0
  241. data/assets/windows/mingw-w64-x86_64/lib/libwebp.a +0 -0
  242. data/assets/windows/mingw-w64-x86_64/lib/libz.a +0 -0
  243. data/assets/windows/mingw-w64-x86_64/lib/libzstd.a +0 -0
  244. data/assets/{ios → xcode/ios}/Assets.xcassets/AppIcon.appiconset/Contents.json +0 -0
  245. data/assets/{ios → xcode/ios}/Assets.xcassets/Contents.json +0 -0
  246. data/assets/{ios → xcode/ios}/Base.lproj/LaunchScreen.storyboard +0 -0
  247. data/assets/{ios → xcode/ios}/Info.plist +0 -0
  248. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mrbconf.h +0 -0
  249. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/array.h +0 -0
  250. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/boxing_nan.h +0 -0
  251. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/boxing_no.h +0 -0
  252. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/boxing_word.h +0 -0
  253. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/class.h +0 -0
  254. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/common.h +0 -0
  255. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/compile.h +0 -0
  256. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/data.h +0 -0
  257. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/debug.h +0 -0
  258. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/dump.h +0 -0
  259. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/error.h +0 -0
  260. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/gc.h +0 -0
  261. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/hash.h +0 -0
  262. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/irep.h +0 -0
  263. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/istruct.h +0 -0
  264. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/khash.h +0 -0
  265. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/numeric.h +0 -0
  266. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/object.h +0 -0
  267. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/opcode.h +0 -0
  268. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/ops.h +0 -0
  269. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/proc.h +0 -0
  270. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/range.h +0 -0
  271. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/re.h +0 -0
  272. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/string.h +0 -0
  273. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/throw.h +0 -0
  274. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/value.h +0 -0
  275. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/variable.h +0 -0
  276. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/version.h +0 -0
  277. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby.h +0 -0
  278. data/assets/{ios → xcode/ios}/MRuby.framework/Info.plist +0 -0
  279. data/assets/{ios → xcode/ios}/MRuby.framework/MRuby +0 -0
  280. data/assets/{ios → xcode/ios}/MyApp.xcodeproj/project.pbxproj +0 -0
  281. data/assets/{ios → xcode/ios}/MyApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -0
  282. data/assets/{ios → xcode/ios}/MyApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -0
  283. data/assets/{ios → xcode/ios}/MyApp.xcodeproj/project.xcworkspace/xcshareddata/MyApp.xcscmblueprint +0 -0
  284. data/assets/{ios → xcode/ios}/main.c +0 -0
  285. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Back.imagestacklayer/Content.imageset/Contents.json +0 -0
  286. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Back.imagestacklayer/Contents.json +0 -0
  287. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Contents.json +0 -0
  288. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Front.imagestacklayer/Content.imageset/Contents.json +0 -0
  289. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Front.imagestacklayer/Contents.json +0 -0
  290. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json +0 -0
  291. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Middle.imagestacklayer/Contents.json +0 -0
  292. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Back.imagestacklayer/Content.imageset/Contents.json +0 -0
  293. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Back.imagestacklayer/Contents.json +0 -0
  294. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Contents.json +0 -0
  295. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Front.imagestacklayer/Content.imageset/Contents.json +0 -0
  296. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Front.imagestacklayer/Contents.json +0 -0
  297. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json +0 -0
  298. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Middle.imagestacklayer/Contents.json +0 -0
  299. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Contents.json +0 -0
  300. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image Wide.imageset/Contents.json +0 -0
  301. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image.imageset/Contents.json +0 -0
  302. data/assets/{tvos → xcode/tvos}/Assets.xcassets/Contents.json +0 -0
  303. data/assets/{tvos → xcode/tvos}/Assets.xcassets/LaunchImage.launchimage/Contents.json +0 -0
  304. data/assets/{tvos → xcode/tvos}/Info.plist +0 -0
  305. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mrbconf.h +0 -0
  306. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/array.h +0 -0
  307. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/boxing_nan.h +0 -0
  308. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/boxing_no.h +0 -0
  309. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/boxing_word.h +0 -0
  310. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/class.h +0 -0
  311. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/common.h +0 -0
  312. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/compile.h +0 -0
  313. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/data.h +0 -0
  314. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/debug.h +0 -0
  315. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/dump.h +0 -0
  316. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/error.h +0 -0
  317. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/gc.h +0 -0
  318. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/hash.h +0 -0
  319. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/irep.h +0 -0
  320. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/istruct.h +0 -0
  321. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/khash.h +0 -0
  322. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/numeric.h +0 -0
  323. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/object.h +0 -0
  324. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/opcode.h +0 -0
  325. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/ops.h +0 -0
  326. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/proc.h +0 -0
  327. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/range.h +0 -0
  328. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/re.h +0 -0
  329. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/string.h +0 -0
  330. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/throw.h +0 -0
  331. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/value.h +0 -0
  332. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/variable.h +0 -0
  333. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/version.h +0 -0
  334. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby.h +0 -0
  335. data/assets/{tvos → xcode/tvos}/MRuby.framework/Info.plist +0 -0
  336. data/assets/{tvos → xcode/tvos}/MRuby.framework/MRuby +0 -0
  337. data/assets/{tvos → xcode/tvos}/MyApp.xcodeproj/project.pbxproj +0 -0
  338. data/assets/{tvos → xcode/tvos}/MyApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -0
  339. data/assets/{tvos → xcode/tvos}/MyApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -0
  340. data/assets/{tvos → xcode/tvos}/MyApp.xcodeproj/project.xcworkspace/xcshareddata/MyApp.xcscmblueprint +0 -0
  341. data/assets/{tvos → xcode/tvos}/main.c +0 -0
  342. data/bin/ruby2d +3 -4
  343. data/ext/ruby2d/extconf.rb +44 -25
  344. data/ext/ruby2d/gl.c +1 -1
  345. data/ext/ruby2d/gl3.c +0 -1
  346. data/ext/ruby2d/gles.c +137 -84
  347. data/ext/ruby2d/ruby2d.c +126 -32
  348. data/ext/ruby2d/ruby2d.h +53 -6
  349. data/ext/ruby2d/text.c +14 -1
  350. data/ext/ruby2d/window.c +253 -215
  351. data/lib/ruby2d/cli/build.rb +242 -59
  352. data/lib/ruby2d/cli/colorize.rb +5 -4
  353. data/lib/ruby2d/cli/platform.rb +17 -0
  354. data/lib/ruby2d/font.rb +7 -1
  355. data/lib/ruby2d/sprite.rb +7 -2
  356. data/lib/ruby2d/text.rb +1 -3
  357. data/lib/ruby2d/texture.rb +21 -21
  358. data/lib/ruby2d/tileset.rb +34 -33
  359. data/lib/ruby2d/version.rb +1 -1
  360. data/lib/ruby2d/vertices.rb +11 -6
  361. data/lib/ruby2d.rb +14 -20
  362. metadata +279 -151
  363. data/assets/README.md +0 -22
  364. data/assets/Rakefile +0 -85
  365. data/assets/macos/lib/libFLAC.a +0 -0
  366. data/assets/macos/lib/libSDL2.a +0 -0
  367. data/assets/macos/lib/libSDL2_image.a +0 -0
  368. data/assets/macos/lib/libSDL2_ttf.a +0 -0
  369. data/assets/macos/lib/libfreetype.a +0 -0
  370. data/assets/macos/lib/libjpeg.a +0 -0
  371. data/assets/macos/lib/libpng16.a +0 -0
  372. data/assets/macos/lib/libtiff.a +0 -0
  373. data/assets/macos/lib/libvorbis.a +0 -0
  374. data/assets/macos/lib/libvorbisfile.a +0 -0
  375. data/assets/macos/lib/libwebp.a +0 -0
  376. data/assets/mingw/bin/SDL2.dll +0 -0
  377. data/assets/mingw/bin/SDL2_image.dll +0 -0
  378. data/assets/mingw/bin/SDL2_mixer.dll +0 -0
  379. data/assets/mingw/bin/SDL2_ttf.dll +0 -0
  380. data/assets/mingw/bin/glew32.dll +0 -0
  381. data/assets/mingw/bin/libFLAC-8.dll +0 -0
  382. data/assets/mingw/bin/libfreetype-6.dll +0 -0
  383. data/assets/mingw/bin/libjpeg-9.dll +0 -0
  384. data/assets/mingw/bin/libmodplug-1.dll +0 -0
  385. data/assets/mingw/bin/libmpg123-0.dll +0 -0
  386. data/assets/mingw/bin/libogg-0.dll +0 -0
  387. data/assets/mingw/bin/libopus-0.dll +0 -0
  388. data/assets/mingw/bin/libopusfile-0.dll +0 -0
  389. data/assets/mingw/bin/libpng16-16.dll +0 -0
  390. data/assets/mingw/bin/libtiff-5.dll +0 -0
  391. data/assets/mingw/bin/libvorbis-0.dll +0 -0
  392. data/assets/mingw/bin/libvorbisfile-3.dll +0 -0
  393. data/assets/mingw/bin/libwebp-7.dll +0 -0
  394. data/assets/mingw/bin/zlib1.dll +0 -0
  395. data/assets/mingw/lib/libSDL2.dll.a +0 -0
  396. data/assets/mingw/lib/libSDL2_image.a +0 -0
  397. data/assets/mingw/lib/libSDL2_image.dll.a +0 -0
  398. data/assets/mingw/lib/libSDL2_mixer.a +0 -0
  399. data/assets/mingw/lib/libSDL2_mixer.dll.a +0 -0
  400. data/assets/mingw/lib/libSDL2_test.a +0 -0
  401. data/assets/mingw/lib/libSDL2_ttf.a +0 -0
  402. data/assets/mingw/lib/libSDL2_ttf.dll.a +0 -0
  403. data/assets/mingw/lib/libSDL2main.a +0 -0
  404. data/assets/mingw/lib/libglew32.dll.a +0 -0
@@ -1,26 +1,30 @@
1
- # Build a Ruby 2D app natively and for the web
1
+ # Build a compiled Ruby 2D app with mruby
2
2
 
3
+ require 'ruby2d'
3
4
  require 'fileutils'
5
+ require 'ruby2d/cli/colorize'
6
+ require 'ruby2d/cli/platform'
4
7
 
5
- # The installed gem directory
6
- @gem_dir = "#{Gem::Specification.find_by_name('ruby2d').gem_dir}"
7
8
 
8
9
  # The Ruby 2D library files
9
- @lib_files = [
10
+ @ruby2d_lib_files = [
10
11
  'cli/colorize',
11
12
  'exceptions',
12
13
  'renderable',
13
14
  'color',
14
15
  'window',
15
16
  'dsl',
17
+ 'entity',
16
18
  'quad',
17
19
  'line',
18
20
  'circle',
19
21
  'rectangle',
20
22
  'square',
21
23
  'triangle',
24
+ 'pixel',
22
25
  'image',
23
26
  'sprite',
27
+ 'tileset',
24
28
  'font',
25
29
  'text',
26
30
  'sound',
@@ -31,30 +35,11 @@ require 'fileutils'
31
35
  ]
32
36
 
33
37
 
34
- # Check if source file provided is good
35
- def check_build_src_file(rb_file)
36
- if !rb_file
37
- puts "Please provide a Ruby file to build"
38
- exit
39
- elsif !File.exist? rb_file
40
- puts "Can't find file: #{rb_file}"
41
- exit
42
- end
43
- end
44
-
45
-
46
- # Assemble the Ruby 2D library in one `.rb` file
47
- def make_lib
48
- FileUtils.mkdir_p 'build'
49
-
50
- lib_dir = "#{@gem_dir}/lib/ruby2d/"
51
-
52
- lib = ''
53
- @lib_files.each do |f|
54
- lib << File.read("#{lib_dir + f}.rb") + "\n\n"
55
- end
38
+ # Helpers ######################################################################
56
39
 
57
- File.write('build/lib.rb', lib)
40
+ def run_cmd(cmd)
41
+ puts "#{'$'.info} #{cmd.bold}\n" if @debug
42
+ system cmd
58
43
  end
59
44
 
60
45
 
@@ -68,57 +53,256 @@ def strip_require(file)
68
53
  end
69
54
 
70
55
 
71
- # Build a native version of the provided Ruby application
72
- def build_native(rb_file)
73
- check_build_src_file(rb_file)
56
+ # Add linker flags
57
+ def add_ld_flags(ld_flags, name, type, dir = nil)
58
+ case type
59
+ when :archive
60
+ ld_flags << "#{dir}/lib#{name}.a "
61
+ when :framework
62
+ ld_flags << "-Wl,-framework,#{name} "
63
+ end
64
+ end
74
65
 
75
- # Check if MRuby exists; if not, quit
76
- if `which mruby`.empty?
77
- puts "#{'Error:'.error} Can't find MRuby, which is needed to build native Ruby 2D applications.\n"
66
+
67
+ # Build Tasks ##################################################################
68
+
69
+ # Build the user's application
70
+ def build(target, ruby2d_app)
71
+
72
+ # Check if source file provided is good
73
+ if !ruby2d_app
74
+ puts "Please provide a Ruby file to build"
75
+ exit
76
+ elsif !File.exist? ruby2d_app
77
+ puts "Can't find file: #{ruby2d_app}"
78
78
  exit
79
79
  end
80
80
 
81
81
  # Add debugging information to produce backtrace
82
82
  if @debug then debug_flag = '-g' end
83
83
 
84
- # Assemble the Ruby 2D library in one `.rb` file and compile to bytecode
85
- make_lib
86
- `mrbc #{debug_flag} -Bruby2d_lib -obuild/lib.c build/lib.rb`
84
+ # Create build directory
85
+ FileUtils.mkdir_p 'build'
87
86
 
88
- # Read the provided Ruby source file, copy to build dir and compile to bytecode
89
- File.open('build/src.rb', 'w') { |file| file << strip_require(rb_file) }
90
- `mrbc #{debug_flag} -Bruby2d_app -obuild/src.c build/src.rb`
87
+ # Assemble Ruby 2D library files into one '.rb' file
88
+
89
+ ruby2d_lib_dir = "#{Ruby2D.gem_dir}/lib/ruby2d/"
90
+
91
+ ruby2d_lib = ''
92
+ @ruby2d_lib_files.each do |f|
93
+ ruby2d_lib << File.read("#{ruby2d_lib_dir + f}.rb") + "\n\n"
94
+ end
95
+
96
+ File.write('build/ruby2d_lib.rb', ruby2d_lib)
97
+
98
+ # Assemble the Ruby 2D C extension files into one '.c' file
99
+
100
+ ruby2d_ext_dir = "#{Ruby2D.gem_dir}/ext/ruby2d/"
101
+
102
+ ruby2d_ext = "#define MRUBY 1" << "\n\n"
103
+ Dir["#{ruby2d_ext_dir}*.c"].each do |c_file|
104
+ ruby2d_ext << File.read(c_file)
105
+ end
106
+
107
+ File.write('build/ruby2d_ext.c', ruby2d_ext)
108
+
109
+ # Select `mrbc` executable based on platform
110
+ case $RUBY2D_PLATFORM
111
+ when :macos
112
+ mrbc = "#{Ruby2D.assets}/macos/universal/bin/mrbc"
113
+ when :windows
114
+ mrbc = "#{Ruby2D.assets}/windows/mingw-w64-x86_64/bin/mrbc.exe"
115
+ else
116
+ mrbc = 'mrbc'
117
+ end
118
+
119
+ # Compile the Ruby 2D lib (`.rb` files) to mruby bytecode
120
+ run_cmd "#{mrbc} #{debug_flag} -Bruby2d_lib -obuild/ruby2d_lib.c build/ruby2d_lib.rb"
121
+
122
+ # Read the user's provided Ruby source file, copy to build dir and compile to bytecode
123
+ File.open('build/ruby2d_app.rb', 'w') { |f| f << strip_require(ruby2d_app) }
124
+ run_cmd "#{mrbc} #{debug_flag} -Bruby2d_app -obuild/ruby2d_app.c build/ruby2d_app.rb"
91
125
 
92
126
  # Combine contents of C source files and bytecode into one file
93
127
  open('build/app.c', 'w') do |f|
94
- f << "#define MRUBY 1" << "\n\n"
95
- f << File.read("build/lib.c") << "\n\n"
96
- f << File.read("build/src.c") << "\n\n"
97
- f << File.read("#{@gem_dir}/ext/ruby2d/ruby2d.c")
128
+ ['ruby2d_app', 'ruby2d_lib', 'ruby2d_ext'].each do |c_file|
129
+ f << File.read("build/#{c_file}.c") << "\n\n"
130
+ end
98
131
  end
99
132
 
100
- # Compile to a native executable
101
- `cc build/app.c -lmruby -o build/app`
133
+ # Compile the final application based on the target platform
134
+ case target
135
+ when :native
136
+ compile_native
137
+ when :web
138
+ compile_web
139
+ end
102
140
 
103
- # Clean up
141
+ # Remove files used in the build process
104
142
  clean_up unless @debug
105
143
 
106
- # Success!
107
- puts "Native app created at `build/app`"
108
144
  end
109
145
 
110
146
 
111
- # Build a web-based version of the provided Ruby application
112
- def build_web(rb_file)
113
- puts "Warning: ".warn + "This feature is currently disabled while it's being upgraded."
147
+ # Create a native executable using the available C compiler
148
+ def compile_native
149
+
150
+ # Get include directories
151
+ incl_dir_ruby2d = "#{Ruby2D.gem_dir}/ext/ruby2d/"
152
+ incl_dir_deps = "#{Ruby2D.assets}/include/"
153
+
154
+ # Add compiler flags for each platform
155
+ case $RUBY2D_PLATFORM
156
+
157
+ when :macos
158
+ ld_dir = "#{Ruby2D.assets}/macos/universal/lib"
159
+
160
+ c_flags = '-arch arm64 -arch x86_64'
161
+
162
+ ld_flags = ''
163
+ ['mruby', 'SDL2', 'SDL2_image', 'SDL2_mixer', 'SDL2_ttf',
164
+ 'jpeg', 'png16', 'tiff', 'webp',
165
+ 'mpg123', 'ogg', 'FLAC', 'vorbis', 'vorbisfile', 'modplug',
166
+ 'freetype', 'harfbuzz', 'graphite2'].each do |name|
167
+ add_ld_flags(ld_flags, name, :archive, ld_dir)
168
+ end
169
+
170
+ ld_flags << "-lz -lbz2 -liconv -lstdc++ "
171
+ ['Cocoa', 'Carbon', 'CoreVideo', 'OpenGL', 'Metal', 'CoreAudio', 'AudioToolbox',
172
+ 'IOKit', 'GameController', 'ForceFeedback', 'CoreHaptics'].each do |name|
173
+ add_ld_flags(ld_flags, name, :framework)
174
+ end
175
+
176
+ when :linux, :linux_rpi, :bsd
177
+ # TODO: implement this
178
+ # ld_flags = '-lSDL2 -lSDL2_image -lSDL2_mixer -lSDL2_ttf -lm -lGL'
179
+
180
+ when :windows
181
+
182
+ if RUBY_PLATFORM =~ /ucrt/
183
+ ld_dir = "#{Ruby2D.assets}/windows/mingw-w64-ucrt-x86_64/lib"
184
+ else
185
+ ld_dir = "#{Ruby2D.assets}/windows/mingw-w64-x86_64/lib"
186
+ end
187
+
188
+ ld_flags = '-static -Wl,--start-group '
189
+ ['mruby',
190
+ 'SDL2',
191
+ 'SDL2_image', 'jpeg', 'png16', 'tiff', 'webp', 'jbig', 'deflate', 'lzma', 'zstd', 'Lerc',
192
+ 'SDL2_mixer', 'mpg123', 'FLAC', 'vorbis', 'vorbisfile', 'ogg', 'modplug', 'opus', 'opusfile', 'sndfile',
193
+ 'SDL2_ttf', 'freetype', 'harfbuzz', 'graphite2', 'bz2', 'brotlicommon', 'brotlidec',
194
+ 'glew32', 'stdc++', 'z', 'ssp'
195
+ ].each do |name|
196
+ add_ld_flags(ld_flags, name, :archive, ld_dir)
197
+ end
198
+ ld_flags << '-lmingw32 -lopengl32 -lole32 -loleaut32 -limm32 -lversion -lwinmm -lrpcrt4 -mwindows -lsetupapi -ldwrite '\
199
+ '-lws2_32 -lshlwapi '
200
+ ld_flags << '-Wl,--end-group'
201
+ end
202
+
203
+ # Compile the app
204
+ run_cmd "cc #{c_flags} -I#{incl_dir_ruby2d} -I#{incl_dir_deps} build/app.c #{ld_flags} -o build/app"
205
+
206
+ create_macos_bundle if $RUBY2D_PLATFORM == :macos
114
207
  end
115
208
 
116
209
 
117
- # Build an app bundle for macOS
118
- def build_macos(rb_file)
210
+ # Create a WebAssembly executable using Emscripten
211
+ def compile_web
212
+
213
+ # Check for compiler toolchain issues
214
+ if doctor_web(:building)
215
+ puts "Fix errors before building.\n\n"
216
+ end
217
+
218
+ wasm_assets = "#{Ruby2D.assets}/wasm"
219
+
220
+ # Get include directories
221
+ incl_dir_ruby2d = "#{Ruby2D.gem_dir}/ext/ruby2d/"
222
+ incl_dir_deps = "#{Ruby2D.assets}/include/"
223
+
224
+ optimize_flags = '-Os --closure 1'
225
+ ld_flags = "#{wasm_assets}/libmruby.a"
226
+
227
+ # Compile using Emscripten
228
+ run_cmd "emcc -s WASM=1 -I#{incl_dir_ruby2d} -I#{incl_dir_deps} "\
229
+ "-s USE_SDL=2 -s USE_SDL_IMAGE=2 -s USE_SDL_MIXER=2 -s USE_SDL_TTF=2 "\
230
+ "build/app.c #{ld_flags} -o build/app.html"
231
+
232
+ # TODO: Copy HTML template from gem assets to build directory
233
+ # FileUtils.cp "#{wasm_assets}/template.html", 'build/app.html'
234
+
235
+ exit(1) unless $?.success?
236
+ end
237
+
238
+
239
+ def doctor_native
240
+ # Check if MRuby exists; if not, quit
241
+ if `which mruby`.empty?
242
+ puts "#{'Error:'.error} Can't find `mruby`, which is needed to build native Ruby 2D applications.\n"
243
+ exit
244
+ end
245
+ end
246
+
247
+
248
+ # Check for problems with web build
249
+ def doctor_web(mode = nil)
250
+
251
+ errors = false
252
+ mruby_errors = false
253
+ emscripten_errors = false
254
+
255
+ puts "\nChecking for mruby"
256
+
257
+ # Check for `mrbc`
258
+ print ' mrbc...'
259
+ if `which mrbc`.empty?
260
+ puts 'not found'.error
261
+ mruby_errors = true
262
+ else
263
+ puts 'found'.success
264
+ end
119
265
 
120
- # Build native app for macOS
121
- build_native(rb_file)
266
+ puts "\nChecking for Emscripten tools"
267
+
268
+ # Check for `emcc`
269
+ print ' emcc...'
270
+ if `which emcc`.empty?
271
+ puts 'not found'.error
272
+ emscripten_errors = true
273
+ else
274
+ puts 'found'.success
275
+ end
276
+
277
+ # Check for `emar`
278
+ print ' emar...'
279
+ if `which emar`.empty?
280
+ puts 'not found'.error
281
+ emscripten_errors = true
282
+ else
283
+ puts 'found'.success
284
+ end
285
+
286
+ if mruby_errors || emscripten_errors then errors = true end
287
+
288
+ if errors
289
+ puts "\nErrors were found!\n\n"
290
+ if mruby_errors
291
+ puts "* Did you install mruby?"
292
+ end
293
+ if emscripten_errors
294
+ puts "* Did you run \`./emsdk_env.sh\` ?", " For help, check out the \"Getting Started\" guide on webassembly.org"
295
+ end
296
+ puts "\n"
297
+ exit(1)
298
+ else
299
+ puts "\n👍 Everything looks good!\n\n"
300
+ end
301
+ end
302
+
303
+
304
+ # Build an app bundle for macOS
305
+ def create_macos_bundle
122
306
 
123
307
  # Property list source for the bundle
124
308
  info_plist = %(
@@ -153,10 +337,10 @@ def build_macos(rb_file)
153
337
  # FileUtils.cp "#{@gem_dir}/assets/app.icns", 'build/App.app/Contents/Resources'
154
338
 
155
339
  # Clean up
156
- FileUtils.rm_f 'build/app' unless @debug
340
+ # FileUtils.rm_f 'build/app' unless @debug
157
341
 
158
342
  # Success!
159
- puts 'macOS app bundle created: `build/App.app`'
343
+ # puts 'macOS app bundle created: `build/App.app`'
160
344
  end
161
345
 
162
346
 
@@ -208,8 +392,7 @@ end
208
392
  # Clean up unneeded build files
209
393
  def clean_up(cmd = nil)
210
394
  FileUtils.rm(
211
- Dir.glob('build/{src,lib}.{rb,c,js}') +
212
- Dir.glob('build/app.c')
395
+ Dir.glob('build/*.{rb,c,js}')
213
396
  )
214
397
  if cmd == :all
215
398
  puts "cleaning up..."
@@ -3,8 +3,9 @@
3
3
  # Extend `String` to include some fancy colors
4
4
  class String
5
5
  def ruby2d_colorize(c); "\e[#{c}m#{self}\e[0m" end
6
- def bold; ruby2d_colorize('1') end
7
- def info; ruby2d_colorize('1;34') end
8
- def warn; ruby2d_colorize('1;33') end
9
- def error; ruby2d_colorize('1;31') end
6
+ def bold; ruby2d_colorize('1') end
7
+ def info; ruby2d_colorize('1;34') end
8
+ def warn; ruby2d_colorize('1;33') end
9
+ def success; ruby2d_colorize('1;32') end
10
+ def error; ruby2d_colorize('1;31') end
10
11
  end
@@ -0,0 +1,17 @@
1
+ # Set the OS and platform
2
+
3
+ case RUBY_PLATFORM
4
+ when /darwin/
5
+ $RUBY2D_PLATFORM = :macos
6
+ when /linux/
7
+ $RUBY2D_PLATFORM = :linux
8
+ if `cat /etc/os-release` =~ /raspbian/
9
+ $RUBY2D_PLATFORM = :linux_rpi
10
+ end
11
+ when /bsd/
12
+ $RUBY2D_PLATFORM = :bsd
13
+ when /mingw/
14
+ $RUBY2D_PLATFORM = :windows
15
+ else
16
+ $RUBY2D_PLATFORM = nil
17
+ end
data/lib/ruby2d/font.rb CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  module Ruby2D
4
4
  class Font
5
+ FONT_CACHE_LIMIT = 100
6
+
5
7
  @@loaded_fonts = {}
6
8
 
7
9
  attr_reader :ttf_font
@@ -16,7 +18,11 @@ module Ruby2D
16
18
  raise Error, "Cannot find font file `#{path}`"
17
19
  end
18
20
 
19
- @@loaded_fonts[[path, size, style]] ||= Font.new(path, size, style)
21
+ (@@loaded_fonts[[path, size, style]] ||= Font.new(path, size, style)).tap do |font|
22
+ if @@loaded_fonts.size > FONT_CACHE_LIMIT
23
+ @@loaded_fonts.shift
24
+ end
25
+ end
20
26
  end
21
27
 
22
28
  # List all fonts, names only
data/lib/ruby2d/sprite.rb CHANGED
@@ -177,8 +177,13 @@ module Ruby2D
177
177
  unless @loop
178
178
  # Stop animation and play block, if provided
179
179
  stop
180
- if @done_proc then @done_proc.call end
181
- @done_proc = nil
180
+ if @done_proc
181
+ # allow proc to make nested `play/do` calls to sequence multiple
182
+ # animations by clearing `@done_proc` before the call
183
+ kept_done_proc = @done_proc
184
+ @done_proc = nil
185
+ kept_done_proc.call
186
+ end
182
187
  end
183
188
  end
184
189
 
data/lib/ruby2d/text.rb CHANGED
@@ -66,9 +66,7 @@ module Ruby2D
66
66
  end
67
67
 
68
68
  def create_texture
69
- if defined?(@texture)
70
- @texture.delete
71
- end
69
+ if @texture then @texture.delete end
72
70
 
73
71
  @texture = Texture.new(*Text.ext_load_text(@font.ttf_font, @text))
74
72
  @width = @texture.width
@@ -1,28 +1,28 @@
1
- # Ruby2D::Text
1
+ # Ruby2D::Texture
2
2
 
3
3
  module Ruby2D
4
- class Texture
5
- attr_reader :width, :height, :texture_id
4
+ class Texture
5
+ attr_reader :width, :height, :texture_id
6
6
 
7
- def initialize(pixel_data, width, height)
8
- @pixel_data = pixel_data
9
- @width = width
10
- @height = height
11
- @texture_id = 0
12
- end
13
-
14
- def draw(coordinates, texture_coordinates, color)
15
- if @texture_id == 0
16
- @texture_id = ext_create(@pixel_data, @width, @height)
17
- @pixel_data = nil
18
- end
7
+ def initialize(pixel_data, width, height)
8
+ @pixel_data = pixel_data
9
+ @width = width
10
+ @height = height
11
+ @texture_id = 0
12
+ end
19
13
 
20
- color = [color.r, color.g, color.b, color.a]
21
- ext_draw(coordinates, texture_coordinates, color, @texture_id)
14
+ def draw(coordinates, texture_coordinates, color)
15
+ if @texture_id == 0
16
+ @texture_id = ext_create(@pixel_data, @width, @height)
17
+ @pixel_data = nil
22
18
  end
23
19
 
24
- def delete
25
- ext_delete(@texture_id)
26
- end
20
+ color = [color.r, color.g, color.b, color.a]
21
+ ext_draw(coordinates, texture_coordinates, color, @texture_id)
22
+ end
23
+
24
+ def delete
25
+ ext_delete(@texture_id)
27
26
  end
28
- end
27
+ end
28
+ end
@@ -2,6 +2,8 @@
2
2
 
3
3
  module Ruby2D
4
4
  class Tileset
5
+ DEFAULT_COLOR = Color.new([1.0, 1.0, 1.0, 1.0])
6
+
5
7
  include Renderable
6
8
 
7
9
  def initialize(path, opts = {})
@@ -46,42 +48,41 @@ module Ruby2D
46
48
  def clear_tiles
47
49
  @tiles = []
48
50
  end
49
- end
50
-
51
- def draw
52
- Window.render_ready_check
53
-
54
- render
55
- end
56
-
57
- private
58
51
 
52
+ def draw
53
+ Window.render_ready_check
59
54
 
60
- def render
61
- scaled_padding = @padding * @scale
62
- scaled_spacing = @spacing * @scale
63
- scaled_tile_width = @tile_width * @scale
64
- scaled_tile_height = @tile_height * @scale
65
- scaled_width = @width * @scale
66
- scaled_height = @height * @scale
67
-
68
- @tiles.each do |tile|
69
- crop = {
70
- x: scaled_padding + (tile.fetch(:tile_x) * (scaled_spacing + scaled_tile_width)),
71
- y: scaled_padding + (tile.fetch(:tile_y) * (scaled_spacing + scaled_tile_height)),
72
- width: scaled_tile_width,
73
- height: scaled_tile_height,
74
- image_width: scaled_width,
75
- image_height: scaled_height,
76
- }
77
-
78
- color = defined?(@color) ? @color : Color.new([1.0, 1.0, 1.0, 1.0])
79
-
80
- vertices = Vertices.new(tile.fetch(:x), tile.fetch(:y), scaled_tile_width, scaled_tile_height, tile.fetch(:tile_rotate), crop: crop, flip: tile.fetch(:tile_flip))
55
+ render
56
+ end
81
57
 
82
- @texture.draw(
83
- vertices.coordinates, vertices.texture_coordinates, color
84
- )
58
+ private
59
+
60
+ def render
61
+ scaled_padding = @padding * @scale
62
+ scaled_spacing = @spacing * @scale
63
+ scaled_tile_width = @tile_width * @scale
64
+ scaled_tile_height = @tile_height * @scale
65
+ scaled_width = @width * @scale
66
+ scaled_height = @height * @scale
67
+
68
+ @tiles.each do |tile|
69
+ crop = {
70
+ x: scaled_padding + (tile.fetch(:tile_x) * (scaled_spacing + scaled_tile_width)),
71
+ y: scaled_padding + (tile.fetch(:tile_y) * (scaled_spacing + scaled_tile_height)),
72
+ width: scaled_tile_width,
73
+ height: scaled_tile_height,
74
+ image_width: scaled_width,
75
+ image_height: scaled_height,
76
+ }
77
+
78
+ color = defined?(@color) ? @color : DEFAULT_COLOR
79
+
80
+ vertices = Vertices.new(tile.fetch(:x), tile.fetch(:y), scaled_tile_width, scaled_tile_height, tile.fetch(:tile_rotate), crop: crop, flip: tile.fetch(:tile_flip))
81
+
82
+ @texture.draw(
83
+ vertices.coordinates, vertices.texture_coordinates, color
84
+ )
85
+ end
85
86
  end
86
87
  end
87
88
  end
@@ -1,5 +1,5 @@
1
1
  # Ruby2D::VERSION
2
2
 
3
3
  module Ruby2D
4
- VERSION = '0.11.0'
4
+ VERSION = '0.11.3'
5
5
  end
@@ -30,10 +30,17 @@ module Ruby2D
30
30
  end
31
31
 
32
32
  def coordinates
33
- x1, y1 = rotate(@x, @y); # Top left
34
- x2, y2 = rotate(@x + @width, @y); # Top right
35
- x3, y3 = rotate(@x + @width, @y + @height); # Bottom right
36
- x4, y4 = rotate(@x, @y + @height); # Bottom left
33
+ if @rotate == 0
34
+ x1, y1 = @x, @y; # Top left
35
+ x2, y2 = @x + @width, @y; # Top right
36
+ x3, y3 = @x + @width, @y + @height; # Bottom right
37
+ x4, y4 = @x, @y + @height; # Bottom left
38
+ else
39
+ x1, y1 = rotate(@x, @y); # Top left
40
+ x2, y2 = rotate(@x + @width, @y); # Top right
41
+ x3, y3 = rotate(@x + @width, @y + @height); # Bottom right
42
+ x4, y4 = rotate(@x, @y + @height); # Bottom left
43
+ end
37
44
 
38
45
  [ x1, y1, x2, y2, x3, y3, x4, y4 ]
39
46
  end
@@ -57,8 +64,6 @@ module Ruby2D
57
64
  private
58
65
 
59
66
  def rotate(x, y)
60
- return [x, y] if @rotate == 0
61
-
62
67
  # Convert from degrees to radians
63
68
  angle = @rotate * Math::PI / 180.0
64
69
 
data/lib/ruby2d.rb CHANGED
@@ -24,35 +24,29 @@ unless RUBY_ENGINE == 'mruby'
24
24
  require 'ruby2d/music'
25
25
  require 'ruby2d/texture'
26
26
  require 'ruby2d/vertices'
27
-
28
- if defined?(RubyInstaller)
29
- s2d_dll_path = Gem::Specification.find_by_name('ruby2d').gem_dir + '/assets/mingw/bin'
30
- RubyInstaller::Runtime.add_dll_directory(File.expand_path(s2d_dll_path))
31
- end
32
-
33
27
  require 'ruby2d/ruby2d' # load native extension
34
28
  end
35
29
 
36
30
 
37
31
  module Ruby2D
38
-
39
- @assets = nil
40
-
41
- class << self
42
- def assets
43
- unless @assets
44
- if RUBY_ENGINE == 'mruby'
45
- @assets = Ruby2D.ext_base_path + 'assets'
46
- else
47
- @assets = './assets'
48
- end
49
- end
50
- @assets
32
+ def self.gem_dir
33
+ # mruby doesn't define `Gem`
34
+ if RUBY_ENGINE == 'mruby'
35
+ `ruby -e "print Gem::Specification.find_by_name('ruby2d').gem_dir"`
36
+ else
37
+ Gem::Specification.find_by_name('ruby2d').gem_dir
51
38
  end
39
+ end
40
+
41
+ def self.assets
42
+ "#{gem_dir}/assets"
43
+ end
52
44
 
53
- def assets=(path); @assets = path end
45
+ def self.test_media
46
+ "#{gem_dir}/assets/test_media"
54
47
  end
55
48
  end
56
49
 
50
+
57
51
  include Ruby2D
58
52
  extend Ruby2D::DSL