ruby2d 0.10.0 → 0.11.2

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 (387) 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/build_config.rb +13 -0
  172. data/assets/wasm/libmruby.a +0 -0
  173. data/assets/wasm/template.html +17 -0
  174. data/assets/windows/glew/README.md +10 -0
  175. data/assets/windows/glew/glew.h +23686 -0
  176. data/assets/{mingw/lib → windows/glew}/libglew32.a +0 -0
  177. data/assets/windows/mingw-w64-x86_64/bin/mrbc.exe +0 -0
  178. data/assets/windows/mingw-w64-x86_64/lib/libFLAC.a +0 -0
  179. data/assets/windows/mingw-w64-x86_64/lib/libLerc.a +0 -0
  180. data/assets/windows/mingw-w64-x86_64/lib/libSDL2.a +0 -0
  181. data/assets/windows/mingw-w64-x86_64/lib/libSDL2_image.a +0 -0
  182. data/assets/windows/mingw-w64-x86_64/lib/libSDL2_mixer.a +0 -0
  183. data/assets/windows/mingw-w64-x86_64/lib/libSDL2_ttf.a +0 -0
  184. data/assets/windows/mingw-w64-x86_64/lib/libbrotlicommon.a +0 -0
  185. data/assets/windows/mingw-w64-x86_64/lib/libbrotlidec.a +0 -0
  186. data/assets/windows/mingw-w64-x86_64/lib/libbz2.a +0 -0
  187. data/assets/windows/mingw-w64-x86_64/lib/libdeflate.a +0 -0
  188. data/assets/windows/mingw-w64-x86_64/lib/libfreetype.a +0 -0
  189. data/assets/windows/mingw-w64-x86_64/lib/libglew32.a +0 -0
  190. data/assets/windows/mingw-w64-x86_64/lib/libgraphite2.a +0 -0
  191. data/assets/windows/mingw-w64-x86_64/lib/libharfbuzz.a +0 -0
  192. data/assets/windows/mingw-w64-x86_64/lib/libjbig.a +0 -0
  193. data/assets/windows/mingw-w64-x86_64/lib/libjpeg.a +0 -0
  194. data/assets/windows/mingw-w64-x86_64/lib/liblzma.a +0 -0
  195. data/assets/windows/mingw-w64-x86_64/lib/libmodplug.a +0 -0
  196. data/assets/windows/mingw-w64-x86_64/lib/libmpg123.a +0 -0
  197. data/assets/windows/mingw-w64-x86_64/lib/libmruby.a +0 -0
  198. data/assets/windows/mingw-w64-x86_64/lib/libogg.a +0 -0
  199. data/assets/windows/mingw-w64-x86_64/lib/libopus.a +0 -0
  200. data/assets/windows/mingw-w64-x86_64/lib/libopusfile.a +0 -0
  201. data/assets/windows/mingw-w64-x86_64/lib/libpng16.a +0 -0
  202. data/assets/windows/mingw-w64-x86_64/lib/libsndfile.a +0 -0
  203. data/assets/windows/mingw-w64-x86_64/lib/libssp.a +0 -0
  204. data/assets/windows/mingw-w64-x86_64/lib/libstdc++.a +0 -0
  205. data/assets/windows/mingw-w64-x86_64/lib/libtiff.a +0 -0
  206. data/assets/windows/mingw-w64-x86_64/lib/libvorbis.a +0 -0
  207. data/assets/windows/mingw-w64-x86_64/lib/libvorbisfile.a +0 -0
  208. data/assets/windows/mingw-w64-x86_64/lib/libwebp.a +0 -0
  209. data/assets/windows/mingw-w64-x86_64/lib/libz.a +0 -0
  210. data/assets/windows/mingw-w64-x86_64/lib/libzstd.a +0 -0
  211. data/assets/{ios → xcode/ios}/Assets.xcassets/AppIcon.appiconset/Contents.json +0 -0
  212. data/assets/{ios → xcode/ios}/Assets.xcassets/Contents.json +0 -0
  213. data/assets/{ios → xcode/ios}/Base.lproj/LaunchScreen.storyboard +0 -0
  214. data/assets/{ios → xcode/ios}/Info.plist +0 -0
  215. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mrbconf.h +0 -0
  216. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/array.h +0 -0
  217. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/boxing_nan.h +0 -0
  218. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/boxing_no.h +0 -0
  219. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/boxing_word.h +0 -0
  220. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/class.h +0 -0
  221. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/common.h +0 -0
  222. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/compile.h +0 -0
  223. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/data.h +0 -0
  224. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/debug.h +0 -0
  225. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/dump.h +0 -0
  226. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/error.h +0 -0
  227. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/gc.h +0 -0
  228. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/hash.h +0 -0
  229. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/irep.h +0 -0
  230. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/istruct.h +0 -0
  231. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/khash.h +0 -0
  232. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/numeric.h +0 -0
  233. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/object.h +0 -0
  234. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/opcode.h +0 -0
  235. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/ops.h +0 -0
  236. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/proc.h +0 -0
  237. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/range.h +0 -0
  238. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/re.h +0 -0
  239. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/string.h +0 -0
  240. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/throw.h +0 -0
  241. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/value.h +0 -0
  242. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/variable.h +0 -0
  243. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/version.h +0 -0
  244. data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby.h +0 -0
  245. data/assets/{ios → xcode/ios}/MRuby.framework/Info.plist +0 -0
  246. data/assets/{ios → xcode/ios}/MRuby.framework/MRuby +0 -0
  247. data/assets/{ios → xcode/ios}/MyApp.xcodeproj/project.pbxproj +0 -0
  248. data/assets/{ios → xcode/ios}/MyApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -0
  249. data/assets/{ios → xcode/ios}/MyApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -0
  250. data/assets/{ios → xcode/ios}/MyApp.xcodeproj/project.xcworkspace/xcshareddata/MyApp.xcscmblueprint +0 -0
  251. data/assets/{ios → xcode/ios}/main.c +0 -0
  252. 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
  253. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Back.imagestacklayer/Contents.json +0 -0
  254. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Contents.json +0 -0
  255. 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
  256. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Front.imagestacklayer/Contents.json +0 -0
  257. 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
  258. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Middle.imagestacklayer/Contents.json +0 -0
  259. 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
  260. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Back.imagestacklayer/Contents.json +0 -0
  261. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Contents.json +0 -0
  262. 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
  263. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Front.imagestacklayer/Contents.json +0 -0
  264. 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
  265. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Middle.imagestacklayer/Contents.json +0 -0
  266. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Contents.json +0 -0
  267. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image Wide.imageset/Contents.json +0 -0
  268. data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image.imageset/Contents.json +0 -0
  269. data/assets/{tvos → xcode/tvos}/Assets.xcassets/Contents.json +0 -0
  270. data/assets/{tvos → xcode/tvos}/Assets.xcassets/LaunchImage.launchimage/Contents.json +0 -0
  271. data/assets/{tvos → xcode/tvos}/Info.plist +0 -0
  272. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mrbconf.h +0 -0
  273. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/array.h +0 -0
  274. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/boxing_nan.h +0 -0
  275. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/boxing_no.h +0 -0
  276. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/boxing_word.h +0 -0
  277. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/class.h +0 -0
  278. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/common.h +0 -0
  279. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/compile.h +0 -0
  280. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/data.h +0 -0
  281. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/debug.h +0 -0
  282. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/dump.h +0 -0
  283. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/error.h +0 -0
  284. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/gc.h +0 -0
  285. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/hash.h +0 -0
  286. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/irep.h +0 -0
  287. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/istruct.h +0 -0
  288. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/khash.h +0 -0
  289. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/numeric.h +0 -0
  290. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/object.h +0 -0
  291. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/opcode.h +0 -0
  292. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/ops.h +0 -0
  293. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/proc.h +0 -0
  294. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/range.h +0 -0
  295. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/re.h +0 -0
  296. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/string.h +0 -0
  297. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/throw.h +0 -0
  298. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/value.h +0 -0
  299. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/variable.h +0 -0
  300. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/version.h +0 -0
  301. data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby.h +0 -0
  302. data/assets/{tvos → xcode/tvos}/MRuby.framework/Info.plist +0 -0
  303. data/assets/{tvos → xcode/tvos}/MRuby.framework/MRuby +0 -0
  304. data/assets/{tvos → xcode/tvos}/MyApp.xcodeproj/project.pbxproj +0 -0
  305. data/assets/{tvos → xcode/tvos}/MyApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -0
  306. data/assets/{tvos → xcode/tvos}/MyApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -0
  307. data/assets/{tvos → xcode/tvos}/MyApp.xcodeproj/project.xcworkspace/xcshareddata/MyApp.xcscmblueprint +0 -0
  308. data/assets/{tvos → xcode/tvos}/main.c +0 -0
  309. data/bin/ruby2d +3 -4
  310. data/ext/ruby2d/extconf.rb +68 -46
  311. data/ext/ruby2d/font.c +35 -0
  312. data/ext/ruby2d/gl.c +9 -58
  313. data/ext/ruby2d/gl2.c +8 -83
  314. data/ext/ruby2d/gl3.c +57 -116
  315. data/ext/ruby2d/gles.c +130 -151
  316. data/ext/ruby2d/image.c +16 -96
  317. data/ext/ruby2d/ruby2d.c +265 -298
  318. data/ext/ruby2d/ruby2d.h +69 -159
  319. data/ext/ruby2d/sound.c +1 -1
  320. data/ext/ruby2d/text.c +20 -114
  321. data/ext/ruby2d/window.c +257 -219
  322. data/lib/ruby2d/circle.rb +3 -1
  323. data/lib/ruby2d/cli/build.rb +239 -59
  324. data/lib/ruby2d/cli/colorize.rb +5 -4
  325. data/lib/ruby2d/cli/platform.rb +17 -0
  326. data/lib/ruby2d/font.rb +26 -1
  327. data/lib/ruby2d/image.rb +22 -17
  328. data/lib/ruby2d/line.rb +3 -1
  329. data/lib/ruby2d/quad.rb +3 -1
  330. data/lib/ruby2d/rectangle.rb +1 -1
  331. data/lib/ruby2d/renderable.rb +0 -12
  332. data/lib/ruby2d/sound.rb +25 -0
  333. data/lib/ruby2d/sprite.rb +44 -89
  334. data/lib/ruby2d/square.rb +1 -1
  335. data/lib/ruby2d/text.rb +40 -20
  336. data/lib/ruby2d/texture.rb +28 -0
  337. data/lib/ruby2d/tileset.rb +47 -28
  338. data/lib/ruby2d/triangle.rb +3 -1
  339. data/lib/ruby2d/version.rb +1 -1
  340. data/lib/ruby2d/vertices.rb +89 -0
  341. data/lib/ruby2d/window.rb +13 -3
  342. data/lib/ruby2d.rb +16 -20
  343. metadata +249 -153
  344. data/assets/README.md +0 -22
  345. data/assets/Rakefile +0 -85
  346. data/assets/macos/lib/libFLAC.a +0 -0
  347. data/assets/macos/lib/libSDL2.a +0 -0
  348. data/assets/macos/lib/libSDL2_image.a +0 -0
  349. data/assets/macos/lib/libSDL2_ttf.a +0 -0
  350. data/assets/macos/lib/libfreetype.a +0 -0
  351. data/assets/macos/lib/libjpeg.a +0 -0
  352. data/assets/macos/lib/libpng16.a +0 -0
  353. data/assets/macos/lib/libtiff.a +0 -0
  354. data/assets/macos/lib/libvorbis.a +0 -0
  355. data/assets/macos/lib/libvorbisfile.a +0 -0
  356. data/assets/macos/lib/libwebp.a +0 -0
  357. data/assets/mingw/bin/SDL2.dll +0 -0
  358. data/assets/mingw/bin/SDL2_image.dll +0 -0
  359. data/assets/mingw/bin/SDL2_mixer.dll +0 -0
  360. data/assets/mingw/bin/SDL2_ttf.dll +0 -0
  361. data/assets/mingw/bin/glew32.dll +0 -0
  362. data/assets/mingw/bin/libFLAC-8.dll +0 -0
  363. data/assets/mingw/bin/libfreetype-6.dll +0 -0
  364. data/assets/mingw/bin/libjpeg-9.dll +0 -0
  365. data/assets/mingw/bin/libmodplug-1.dll +0 -0
  366. data/assets/mingw/bin/libmpg123-0.dll +0 -0
  367. data/assets/mingw/bin/libogg-0.dll +0 -0
  368. data/assets/mingw/bin/libopus-0.dll +0 -0
  369. data/assets/mingw/bin/libopusfile-0.dll +0 -0
  370. data/assets/mingw/bin/libpng16-16.dll +0 -0
  371. data/assets/mingw/bin/libtiff-5.dll +0 -0
  372. data/assets/mingw/bin/libvorbis-0.dll +0 -0
  373. data/assets/mingw/bin/libvorbisfile-3.dll +0 -0
  374. data/assets/mingw/bin/libwebp-7.dll +0 -0
  375. data/assets/mingw/bin/zlib1.dll +0 -0
  376. data/assets/mingw/lib/libSDL2.dll.a +0 -0
  377. data/assets/mingw/lib/libSDL2_image.a +0 -0
  378. data/assets/mingw/lib/libSDL2_image.dll.a +0 -0
  379. data/assets/mingw/lib/libSDL2_mixer.a +0 -0
  380. data/assets/mingw/lib/libSDL2_mixer.dll.a +0 -0
  381. data/assets/mingw/lib/libSDL2_test.a +0 -0
  382. data/assets/mingw/lib/libSDL2_ttf.a +0 -0
  383. data/assets/mingw/lib/libSDL2_ttf.dll.a +0 -0
  384. data/assets/mingw/lib/libSDL2main.a +0 -0
  385. data/assets/mingw/lib/libglew32.dll.a +0 -0
  386. data/ext/ruby2d/sprite.c +0 -147
  387. data/ext/ruby2d/tileset.c +0 -30
data/lib/ruby2d/sprite.rb CHANGED
@@ -5,32 +5,27 @@ module Ruby2D
5
5
  include Renderable
6
6
 
7
7
  attr_reader :path
8
- attr_accessor :rotate, :loop, :clip_x, :clip_y, :clip_width, :clip_height, :data
8
+ attr_accessor :rotate, :loop, :clip_x, :clip_y, :clip_width, :clip_height, :data, :x, :y, :width, :height
9
9
 
10
10
  def initialize(path, opts = {})
11
- unless File.exist? path
12
- raise Error, "Cannot find sprite image file `#{path}`"
13
- end
14
-
15
11
  # Sprite image file path
16
12
  @path = path
17
13
 
14
+ # Initialize the sprite texture
15
+ @texture = Texture.new(*Image.load_image(@path))
16
+ @img_width = @texture.width
17
+ @img_height = @texture.height
18
+
18
19
  # Coordinates, size, and rotation of the sprite
19
20
  @x = opts[:x] || 0
20
21
  @y = opts[:y] || 0
21
22
  @z = opts[:z] || 0
22
- @width = opts[:width] || nil
23
- @height = opts[:height] || nil
24
23
  @rotate = opts[:rotate] || 0
25
24
  self.color = opts[:color] || 'white'
26
- self.opacity = opts[:opacity] if opts[:opacity]
25
+ self.color.opacity = opts[:opacity] if opts[:opacity]
27
26
 
28
- # Flipping status, coordinates, and size, used internally
27
+ # Flipping status
29
28
  @flip = nil
30
- @flip_x = @x
31
- @flip_y = @y
32
- @flip_width = @width
33
- @flip_height = @height
34
29
 
35
30
  # Animation attributes
36
31
  @start_time = 0.0
@@ -42,20 +37,16 @@ module Ruby2D
42
37
  @last_frame = 0
43
38
  @done_proc = nil
44
39
 
45
- # The sprite image size set by the native extension `ext_init`
46
- @img_width = nil; @img_height = nil
47
-
48
- # Initialize the sprite
49
- unless ext_init(@path)
50
- raise Error, "Sprite image `#{@path}` cannot be created"
51
- end
52
-
53
40
  # The clipping rectangle
54
41
  @clip_x = opts[:clip_x] || 0
55
42
  @clip_y = opts[:clip_y] || 0
56
43
  @clip_width = opts[:clip_width] || @img_width
57
44
  @clip_height = opts[:clip_height] || @img_height
58
45
 
46
+ # Dimensions
47
+ @width = opts[:width] || nil
48
+ @height = opts[:height] || nil
49
+
59
50
  # Set the default animation
60
51
  @animations[:default] = 0..(@img_width / @clip_width) - 1
61
52
 
@@ -75,38 +66,6 @@ module Ruby2D
75
66
  unless opts[:show] == false then add end
76
67
  end
77
68
 
78
- # Set the x coordinate
79
- def x=(x)
80
- @x = @flip_x = x
81
- if @flip == :horizontal || @flip == :both
82
- @flip_x = x + @width
83
- end
84
- end
85
-
86
- # Set the y coordinate
87
- def y=(y)
88
- @y = @flip_y = y
89
- if @flip == :vertical || @flip == :both
90
- @flip_y = y + @height
91
- end
92
- end
93
-
94
- # Set the width
95
- def width=(width)
96
- @width = @flip_width = width
97
- if @flip == :horizontal || @flip == :both
98
- @flip_width = -width
99
- end
100
- end
101
-
102
- # Set the height
103
- def height=(height)
104
- @height = @flip_height = height
105
- if @flip == :vertical || @flip == :both
106
- @flip_height = -height
107
- end
108
- end
109
-
110
69
  # Play an animation
111
70
  def play(opts = {}, &done_proc)
112
71
 
@@ -165,26 +124,6 @@ module Ruby2D
165
124
  end
166
125
 
167
126
  @flip = flip
168
-
169
- # Reset flip values
170
- @flip_x = @x
171
- @flip_y = @y
172
- @flip_width = @width
173
- @flip_height = @height
174
-
175
- case flip
176
- when :horizontal
177
- @flip_x = @x + @width
178
- @flip_width = -@width
179
- when :vertical
180
- @flip_y = @y + @height
181
- @flip_height = -@height
182
- when :both # horizontal and vertical
183
- @flip_x = @x + @width
184
- @flip_width = -@width
185
- @flip_y = @y + @height
186
- @flip_height = -@height
187
- end
188
127
  end
189
128
 
190
129
  # Reset frame to defaults
@@ -238,8 +177,13 @@ module Ruby2D
238
177
  unless @loop
239
178
  # Stop animation and play block, if provided
240
179
  stop
241
- if @done_proc then @done_proc.call end
242
- @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
243
187
  end
244
188
  end
245
189
 
@@ -248,8 +192,10 @@ module Ruby2D
248
192
  end
249
193
 
250
194
  def draw(opts = {})
251
- opts[:width] = opts[:width] || @flip_width
252
- opts[:height] = opts[:height] || @flip_height
195
+ Window.render_ready_check
196
+
197
+ opts[:width] = opts[:width] || (@width || @clip_width)
198
+ opts[:height] = opts[:height] || (@height || @clip_height)
253
199
  opts[:rotate] = opts[:rotate] || @rotate
254
200
  opts[:clip_x] = opts[:clip_x] || @clip_x
255
201
  opts[:clip_y] = opts[:clip_y] || @clip_y
@@ -259,24 +205,33 @@ module Ruby2D
259
205
  opts[:color] = [1.0, 1.0, 1.0, 1.0]
260
206
  end
261
207
 
262
- self.class.ext_draw([
263
- self, opts[:x], opts[:y], opts[:width], opts[:height], opts[:rotate],
264
- opts[:clip_x], opts[:clip_y], opts[:clip_width], opts[:clip_height],
265
- opts[:color][0], opts[:color][1], opts[:color][2], opts[:color][3]
266
- ])
208
+ render(x: opts[:x], y: opts[:y], width: opts[:width], height: opts[:height], color: Color.new(color), rotate: opts[:rotate], crop: {
209
+ x: opts[:clip_x],
210
+ y: opts[:clip_y],
211
+ width: opts[:clip_width],
212
+ height: opts[:clip_height],
213
+ image_width: @img_width,
214
+ image_height: @img_height,
215
+ })
267
216
  end
268
217
 
269
218
  private
270
219
 
271
- def render
220
+ def render(x: @x, y: @y, width: (@width || @clip_width), height: (@height || @clip_height) , color: @color, rotate: @rotate, flip: @flip, crop: {
221
+ x: @clip_x,
222
+ y: @clip_y,
223
+ width: @clip_width,
224
+ height: @clip_height,
225
+ image_width: @img_width,
226
+ image_height: @img_height,
227
+ })
272
228
  update
273
- self.class.ext_draw([
274
- self, @flip_x, @flip_y, @flip_width, @flip_height, @rotate,
275
- @clip_x, @clip_y, @clip_width, @clip_height,
276
- @color.r, @color.g, @color.b, @color.a
277
- ])
278
- end
279
229
 
230
+ vertices = Vertices.new(x, y, width, height, rotate, crop: crop, flip: flip)
280
231
 
232
+ @texture.draw(
233
+ vertices.coordinates, vertices.texture_coordinates, color
234
+ )
235
+ end
281
236
  end
282
237
  end
data/lib/ruby2d/square.rb CHANGED
@@ -11,7 +11,7 @@ module Ruby2D
11
11
  @z = opts[:z] || 0
12
12
  @width = @height = @size = opts[:size] || 100
13
13
  self.color = opts[:color] || 'white'
14
- self.opacity = opts[:opacity] if opts[:opacity]
14
+ self.color.opacity = opts[:opacity] if opts[:opacity]
15
15
  update_coords(@x, @y, @size, @size)
16
16
  add
17
17
  end
data/lib/ruby2d/text.rb CHANGED
@@ -4,8 +4,8 @@ module Ruby2D
4
4
  class Text
5
5
  include Renderable
6
6
 
7
- attr_reader :text, :font
8
- attr_accessor :x, :y, :size, :rotate, :data
7
+ attr_reader :text, :size
8
+ attr_accessor :x, :y, :rotate, :data
9
9
 
10
10
  def initialize(text, opts = {})
11
11
  @x = opts[:x] || 0
@@ -14,43 +14,63 @@ module Ruby2D
14
14
  @text = text.to_s
15
15
  @size = opts[:size] || 20
16
16
  @rotate = opts[:rotate] || 0
17
+ @style = opts[:style]
17
18
  self.color = opts[:color] || 'white'
18
- self.opacity = opts[:opacity] if opts[:opacity]
19
- @font = opts[:font] || Font.default
20
- unless File.exist? @font
21
- raise Error, "Cannot find font file `#{@font}`"
22
- end
23
- unless ext_init
24
- raise Error, "Text `#{@text}` cannot be created"
25
- end
19
+ self.color.opacity = opts[:opacity] if opts[:opacity]
20
+ @font_path = opts[:font] || Font.default
21
+ create_font
22
+ create_texture
23
+
26
24
  unless opts[:show] == false then add end
27
25
  end
28
26
 
27
+ # Returns the path of the font as a string
28
+ def font
29
+ @font_path
30
+ end
31
+
29
32
  def text=(msg)
30
33
  @text = msg.to_s
31
- ext_set(@text)
34
+ create_texture
35
+ end
36
+
37
+ def size=(size)
38
+ @size = size
39
+ create_font
40
+ create_texture
32
41
  end
33
42
 
34
43
  def draw(opts = {})
44
+ Window.render_ready_check
45
+
35
46
  opts[:rotate] = opts[:rotate] || @rotate
36
47
  unless opts[:color]
37
48
  opts[:color] = [1.0, 1.0, 1.0, 1.0]
38
49
  end
39
50
 
40
- self.class.ext_draw([
41
- self, opts[:x], opts[:y], opts[:rotate],
42
- opts[:color][0], opts[:color][1], opts[:color][2], opts[:color][3]
43
- ])
51
+ render(x: opts[:x], y: opts[:y], color: Color.new(opts[:color]), rotate: opts[:rotate])
44
52
  end
45
53
 
46
54
  private
47
55
 
48
- def render
49
- self.class.ext_draw([
50
- self, @x, @y, @rotate,
51
- @color.r, @color.g, @color.b, @color.a
52
- ])
56
+ def render(x: @x, y: @y, color: @color, rotate: @rotate)
57
+ vertices = Vertices.new(x, y, @width, @height, rotate)
58
+
59
+ @texture.draw(
60
+ vertices.coordinates, vertices.texture_coordinates, color
61
+ )
62
+ end
63
+
64
+ def create_font
65
+ @font = Font.load(@font_path, @size, @style)
53
66
  end
54
67
 
68
+ def create_texture
69
+ if @texture then @texture.delete end
70
+
71
+ @texture = Texture.new(*Text.ext_load_text(@font.ttf_font, @text))
72
+ @width = @texture.width
73
+ @height = @texture.height
74
+ end
55
75
  end
56
76
  end
@@ -0,0 +1,28 @@
1
+ # Ruby2D::Texture
2
+
3
+ module Ruby2D
4
+ class Texture
5
+ attr_reader :width, :height, :texture_id
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
19
+
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)
26
+ end
27
+ end
28
+ end
@@ -2,29 +2,32 @@
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 = {})
8
- unless File.exist? path
9
- raise Error, "Cannot find tileset image file `#{path}`"
10
- end
11
10
  @path = path
11
+
12
+ # Initialize the tileset texture
13
+ @texture = Texture.new(*Image.load_image(@path))
14
+ @width = opts[:width] || @texture.width
15
+ @height = opts[:height] || @texture.height
16
+ @z = opts[:z] || 0
17
+
12
18
  @tiles = []
13
19
  @defined_tiles = {}
14
20
  @padding = opts[:padding] || 0
15
21
  @spacing = opts[:spacing] || 0
16
22
  @tile_width = opts[:tile_width]
17
23
  @tile_height = opts[:tile_height]
18
-
19
- unless ext_init(@path)
20
- raise Error, "Tileset `#{@path}` cannot be created"
21
- end
24
+ @scale = opts[:scale] || 1
22
25
 
23
26
  unless opts[:show] == false then add end
24
27
  end
25
28
 
26
- def define_tile(name, x, y)
27
- @defined_tiles[name] = { x: x, y: y }
29
+ def define_tile(name, x, y, rotate: 0, flip: nil)
30
+ @defined_tiles[name] = { x: x, y: y , rotate: rotate, flip: flip }
28
31
  end
29
32
 
30
33
  def set_tile(name, coordinates)
@@ -34,6 +37,8 @@ module Ruby2D
34
37
  @tiles.push({
35
38
  tile_x: tile.fetch(:x),
36
39
  tile_y: tile.fetch(:y),
40
+ tile_rotate: tile.fetch(:rotate),
41
+ tile_flip: tile.fetch(:flip),
37
42
  x: coordinate.fetch(:x),
38
43
  y: coordinate.fetch(:y)
39
44
  })
@@ -43,27 +48,41 @@ module Ruby2D
43
48
  def clear_tiles
44
49
  @tiles = []
45
50
  end
46
- end
47
51
 
48
- def draw(opts = {})
49
- render(opts)
50
- end
52
+ def draw
53
+ Window.render_ready_check
51
54
 
52
- private
53
-
54
- def render(opts = {})
55
- opts[:tile_width] = opts[:tile_width] || @tile_width
56
- opts[:tile_height] = opts[:tile_height] || @tile_height
57
- opts[:padding] = opts[:padding] || @padding
58
- opts[:spacing] = opts[:spacing] || @spacing
59
-
60
- @tiles.each do |tile|
61
- self.class.ext_draw(
62
- [
63
- self, opts[:tile_width], opts[:tile_height], opts[:padding], opts[:spacing],
64
- tile.fetch(:tile_x), tile.fetch(:tile_y), tile.fetch(:x),
65
- tile.fetch(:y)
66
- ])
55
+ render
56
+ end
57
+
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
67
86
  end
68
87
  end
69
88
  end
@@ -17,7 +17,7 @@ module Ruby2D
17
17
  @y3 = opts[:y3] || 100
18
18
  @z = opts[:z] || 0
19
19
  self.color = opts[:color] || 'white'
20
- self.opacity = opts[:opacity] if opts[:opacity]
20
+ self.color.opacity = opts[:opacity] if opts[:opacity]
21
21
  add
22
22
  end
23
23
 
@@ -39,6 +39,8 @@ module Ruby2D
39
39
  end
40
40
 
41
41
  def self.draw(opts = {})
42
+ Window.render_ready_check
43
+
42
44
  ext_draw([
43
45
  opts[:x1], opts[:y1], opts[:color][0][0], opts[:color][0][1], opts[:color][0][2], opts[:color][0][3],
44
46
  opts[:x2], opts[:y2], opts[:color][1][0], opts[:color][1][1], opts[:color][1][2], opts[:color][1][3],
@@ -1,5 +1,5 @@
1
1
  # Ruby2D::VERSION
2
2
 
3
3
  module Ruby2D
4
- VERSION = '0.10.0'
4
+ VERSION = '0.11.2'
5
5
  end
@@ -0,0 +1,89 @@
1
+ # Ruby2D::Vertices
2
+
3
+ # This class generates a vertices array which are passed to the openGL rendering code.
4
+ # The vertices array is split up into 4 groups (1 - top left, 2 - top right, 3 - bottom right, 4 - bottom left)
5
+ # This class is responsible for transforming textures, it can scale / crop / rotate and flip textures
6
+
7
+ module Ruby2D
8
+ class Vertices
9
+ def initialize(x, y, width, height, rotate, crop: nil, flip: nil)
10
+ @flip = flip
11
+ @x = x
12
+ @y = y
13
+ @width = width.to_f
14
+ @height = height.to_f
15
+
16
+ if @flip == :horizontal || @flip == :both
17
+ @x = @x + @width
18
+ @width = -@width
19
+ end
20
+
21
+ if @flip == :vertical || @flip == :both
22
+ @y = y + @height
23
+ @height = -@height
24
+ end
25
+
26
+ @rotate = rotate
27
+ @rx = @x + (@width / 2.0)
28
+ @ry = @y + (@height / 2.0)
29
+ @crop = crop
30
+ end
31
+
32
+ def coordinates
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
44
+
45
+ [ x1, y1, x2, y2, x3, y3, x4, y4 ]
46
+ end
47
+
48
+ def texture_coordinates
49
+ if @crop.nil?
50
+ tx1 = 0.0; ty1 = 0.0 # Top left
51
+ tx2 = 1.0; ty2 = 0.0 # Top right
52
+ tx3 = 1.0; ty3 = 1.0 # Bottom right
53
+ tx4 = 0.0; ty4 = 1.0 # Bottom left
54
+ else
55
+ tx1 = @crop[:x] / @crop[:image_width].to_f; ty1 = @crop[:y] / @crop[:image_height].to_f # Top left
56
+ tx2 = tx1 + (@crop[:width] / @crop[:image_width].to_f); ty2 = ty1 # Top right
57
+ tx3 = tx2; ty3 = ty1 + (@crop[:height] / @crop[:image_height].to_f) # Botttom right
58
+ tx4 = tx1; ty4 = ty3 # Bottom left
59
+ end
60
+
61
+ [ tx1, ty1, tx2, ty2, tx3, ty3, tx4, ty4 ]
62
+ end
63
+
64
+ private
65
+
66
+ def rotate(x, y)
67
+ # Convert from degrees to radians
68
+ angle = @rotate * Math::PI / 180.0
69
+
70
+ # Get the sine and cosine of the angle
71
+ sa = Math.sin(angle)
72
+ ca = Math.cos(angle)
73
+
74
+ # Translate point to origin
75
+ x -= @rx
76
+ y -= @ry
77
+
78
+ # Rotate point
79
+ xnew = x * ca - y * sa;
80
+ ynew = x * sa + y * ca;
81
+
82
+ # Translate point back
83
+ x = xnew + @rx;
84
+ y = ynew + @ry;
85
+
86
+ [x, y]
87
+ end
88
+ end
89
+ end
data/lib/ruby2d/window.rb CHANGED
@@ -4,6 +4,7 @@
4
4
 
5
5
  module Ruby2D
6
6
  class Window
7
+ @@open_window = false
7
8
 
8
9
  # Event structures
9
10
  EventDescriptor = Struct.new(:type, :id)
@@ -109,9 +110,7 @@ module Ruby2D
109
110
  @render_proc = Proc.new {}
110
111
 
111
112
  # Detect if window is being used through the DSL or as a class instance
112
- unless method(:update).parameters.empty? || method(:render).parameters.empty?
113
- @using_dsl = true
114
- end
113
+ @using_dsl = !(method(:update).parameters.empty? || method(:render).parameters.empty?)
115
114
 
116
115
  # Whether diagnostic messages should be printed
117
116
  @diagnostics = false
@@ -190,6 +189,12 @@ module Ruby2D
190
189
  def close
191
190
  DSL.window.close
192
191
  end
192
+
193
+ def render_ready_check
194
+ unless @@open_window
195
+ raise Error, "Attempting to draw before the window is ready. Please put calls to draw() inside of a render block."
196
+ end
197
+ end
193
198
  end
194
199
 
195
200
  # Public instance methods
@@ -616,6 +621,11 @@ module Ruby2D
616
621
 
617
622
  # Show the window
618
623
  def show
624
+ if @@open_window
625
+ raise Error, "Window#show called multiple times, Ruby2D only supports a single open window"
626
+ end
627
+
628
+ @@open_window = true
619
629
  ext_show
620
630
  end
621
631
 
data/lib/ruby2d.rb CHANGED
@@ -22,35 +22,31 @@ unless RUBY_ENGINE == 'mruby'
22
22
  require 'ruby2d/text'
23
23
  require 'ruby2d/sound'
24
24
  require 'ruby2d/music'
25
-
26
- if defined?(RubyInstaller)
27
- s2d_dll_path = Gem::Specification.find_by_name('ruby2d').gem_dir + '/assets/mingw/bin'
28
- RubyInstaller::Runtime.add_dll_directory(File.expand_path(s2d_dll_path))
29
- end
30
-
25
+ require 'ruby2d/texture'
26
+ require 'ruby2d/vertices'
31
27
  require 'ruby2d/ruby2d' # load native extension
32
28
  end
33
29
 
34
30
 
35
31
  module Ruby2D
36
-
37
- @assets = nil
38
-
39
- class << self
40
- def assets
41
- unless @assets
42
- if RUBY_ENGINE == 'mruby'
43
- @assets = Ruby2D.ext_base_path + 'assets'
44
- else
45
- @assets = './assets'
46
- end
47
- end
48
- @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
49
38
  end
39
+ end
40
+
41
+ def self.assets
42
+ "#{gem_dir}/assets"
43
+ end
50
44
 
51
- def assets=(path); @assets = path end
45
+ def self.test_media
46
+ "#{gem_dir}/assets/test_media"
52
47
  end
53
48
  end
54
49
 
50
+
55
51
  include Ruby2D
56
52
  extend Ruby2D::DSL