ruby2d 0.10.0 → 0.11.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/assets/include/SDL2/SDL.h +108 -14
- data/assets/include/SDL2/SDL_assert.h +81 -50
- data/assets/include/SDL2/SDL_atomic.h +135 -35
- data/assets/include/SDL2/SDL_audio.h +960 -355
- data/assets/include/SDL2/SDL_bits.h +11 -6
- data/assets/include/SDL2/SDL_blendmode.h +91 -14
- data/assets/include/SDL2/SDL_clipboard.h +30 -7
- data/assets/include/SDL2/SDL_config.h +3 -1
- data/assets/include/SDL2/SDL_config_android.h +11 -1
- data/assets/include/SDL2/SDL_config_emscripten.h +216 -0
- data/assets/include/SDL2/SDL_config_iphoneos.h +9 -1
- data/assets/include/SDL2/SDL_config_macosx.h +16 -2
- data/assets/include/SDL2/SDL_config_minimal.h +4 -1
- data/assets/include/SDL2/SDL_config_os2.h +37 -20
- data/assets/include/SDL2/SDL_config_pandora.h +6 -1
- data/assets/include/SDL2/SDL_config_psp.h +8 -8
- data/assets/include/SDL2/SDL_config_windows.h +39 -22
- data/assets/include/SDL2/SDL_config_winrt.h +23 -8
- data/assets/include/SDL2/SDL_config_wiz.h +6 -1
- data/assets/include/SDL2/SDL_copying.h +1 -1
- data/assets/include/SDL2/SDL_cpuinfo.h +331 -71
- data/assets/include/SDL2/SDL_egl.h +906 -280
- data/assets/include/SDL2/SDL_endian.h +101 -47
- data/assets/include/SDL2/SDL_error.h +70 -19
- data/assets/include/SDL2/SDL_events.h +387 -79
- data/assets/include/SDL2/SDL_filesystem.h +73 -64
- data/assets/include/SDL2/SDL_gamecontroller.h +585 -125
- data/assets/include/SDL2/SDL_gesture.h +36 -6
- data/assets/include/SDL2/SDL_haptic.h +304 -210
- data/assets/include/SDL2/SDL_hidapi.h +451 -0
- data/assets/include/SDL2/SDL_hints.h +1286 -897
- data/assets/include/SDL2/SDL_joystick.h +577 -130
- data/assets/include/SDL2/SDL_keyboard.h +162 -63
- data/assets/include/SDL2/SDL_keycode.h +7 -5
- data/assets/include/SDL2/SDL_loadso.h +42 -8
- data/assets/include/SDL2/SDL_locale.h +34 -32
- data/assets/include/SDL2/SDL_log.h +212 -19
- data/assets/include/SDL2/SDL_main.h +72 -17
- data/assets/include/SDL2/SDL_messagebox.h +70 -23
- data/assets/include/SDL2/SDL_metal.h +27 -32
- data/assets/include/SDL2/SDL_misc.h +19 -15
- data/assets/include/SDL2/SDL_mouse.h +262 -110
- data/assets/include/SDL2/SDL_mutex.h +286 -66
- data/assets/include/SDL2/SDL_name.h +1 -1
- data/assets/include/SDL2/SDL_opengl.h +1 -1
- data/assets/include/SDL2/SDL_opengles.h +1 -1
- data/assets/include/SDL2/SDL_opengles2.h +2 -2
- data/assets/include/SDL2/SDL_pixels.h +199 -34
- data/assets/include/SDL2/SDL_platform.h +39 -2
- data/assets/include/SDL2/SDL_power.h +23 -10
- data/assets/include/SDL2/SDL_quit.h +1 -1
- data/assets/include/SDL2/SDL_rect.h +78 -28
- data/assets/include/SDL2/SDL_render.h +1204 -472
- data/assets/include/SDL2/SDL_revision.h +2 -2
- data/assets/include/SDL2/SDL_rwops.h +605 -33
- data/assets/include/SDL2/SDL_scancode.h +1 -1
- data/assets/include/SDL2/SDL_sensor.h +76 -42
- data/assets/include/SDL2/SDL_shape.h +38 -27
- data/assets/include/SDL2/SDL_stdinc.h +96 -24
- data/assets/include/SDL2/SDL_surface.h +571 -139
- data/assets/include/SDL2/SDL_system.h +339 -101
- data/assets/include/SDL2/SDL_syswm.h +50 -20
- data/assets/include/SDL2/SDL_test.h +1 -1
- data/assets/include/SDL2/SDL_test_assert.h +2 -2
- data/assets/include/SDL2/SDL_test_common.h +23 -6
- data/assets/include/SDL2/SDL_test_compare.h +1 -1
- data/assets/include/SDL2/SDL_test_crc32.h +1 -1
- data/assets/include/SDL2/SDL_test_font.h +3 -3
- data/assets/include/SDL2/SDL_test_fuzzer.h +28 -26
- data/assets/include/SDL2/SDL_test_harness.h +6 -6
- data/assets/include/SDL2/SDL_test_images.h +1 -1
- data/assets/include/SDL2/SDL_test_log.h +1 -1
- data/assets/include/SDL2/SDL_test_md5.h +1 -1
- data/assets/include/SDL2/SDL_test_memory.h +1 -1
- data/assets/include/SDL2/SDL_test_random.h +2 -2
- data/assets/include/SDL2/SDL_thread.h +226 -128
- data/assets/include/SDL2/SDL_timer.h +129 -22
- data/assets/include/SDL2/SDL_touch.h +48 -8
- data/assets/include/SDL2/SDL_ttf.h +102 -9
- data/assets/include/SDL2/SDL_types.h +1 -1
- data/assets/include/SDL2/SDL_version.h +72 -46
- data/assets/include/SDL2/SDL_video.h +1266 -460
- data/assets/include/SDL2/SDL_vulkan.h +100 -161
- data/assets/include/SDL2/begin_code.h +22 -1
- data/assets/include/SDL2/close_code.h +1 -1
- data/assets/include/mrbconf.h +234 -0
- data/assets/include/mruby/array.h +317 -0
- data/assets/include/mruby/boxing_nan.h +130 -0
- data/assets/include/mruby/boxing_no.h +58 -0
- data/assets/include/mruby/boxing_word.h +205 -0
- data/assets/include/mruby/class.h +108 -0
- data/assets/include/mruby/common.h +92 -0
- data/assets/include/mruby/compile.h +210 -0
- data/assets/include/mruby/data.h +76 -0
- data/assets/include/mruby/debug.h +66 -0
- data/assets/include/mruby/dump.h +158 -0
- data/assets/include/mruby/endian.h +44 -0
- data/assets/include/mruby/error.h +137 -0
- data/assets/include/mruby/gc.h +92 -0
- data/assets/include/mruby/hash.h +242 -0
- data/assets/include/mruby/irep.h +147 -0
- data/assets/include/mruby/istruct.h +50 -0
- data/assets/include/mruby/khash.h +284 -0
- data/assets/include/mruby/numeric.h +169 -0
- data/assets/include/mruby/object.h +43 -0
- data/assets/include/mruby/opcode.h +43 -0
- data/assets/include/mruby/ops.h +122 -0
- data/assets/include/mruby/presym/disable.h +70 -0
- data/assets/include/mruby/presym/enable.h +37 -0
- data/assets/include/mruby/presym/scanning.h +73 -0
- data/assets/include/mruby/presym.h +40 -0
- data/assets/include/mruby/proc.h +209 -0
- data/assets/include/mruby/range.h +79 -0
- data/assets/include/mruby/re.h +16 -0
- data/assets/include/mruby/string.h +469 -0
- data/assets/include/mruby/throw.h +66 -0
- data/assets/include/mruby/value.h +400 -0
- data/assets/include/mruby/variable.h +140 -0
- data/assets/include/mruby/version.h +143 -0
- data/assets/include/mruby.h +1444 -0
- data/assets/macos/universal/bin/mrbc +0 -0
- data/assets/macos/universal/lib/libFLAC.a +0 -0
- data/assets/macos/universal/lib/libSDL2.a +0 -0
- data/assets/macos/universal/lib/libSDL2_image.a +0 -0
- data/assets/macos/{lib → universal/lib}/libSDL2_mixer.a +0 -0
- data/assets/macos/universal/lib/libSDL2_ttf.a +0 -0
- data/assets/macos/universal/lib/libfreetype.a +0 -0
- data/assets/macos/universal/lib/libgraphite2.a +0 -0
- data/assets/macos/universal/lib/libharfbuzz.a +0 -0
- data/assets/macos/universal/lib/libjpeg.a +0 -0
- data/assets/macos/universal/lib/libmodplug.a +0 -0
- data/assets/macos/{lib → universal/lib}/libmpg123.a +0 -0
- data/assets/{mingw/lib/libSDL2.a → macos/universal/lib/libmruby.a} +0 -0
- data/assets/macos/{lib → universal/lib}/libogg.a +0 -0
- data/assets/macos/universal/lib/libpng16.a +0 -0
- data/assets/macos/universal/lib/libtiff.a +0 -0
- data/assets/macos/universal/lib/libvorbis.a +0 -0
- data/assets/macos/universal/lib/libvorbisfile.a +0 -0
- data/assets/macos/universal/lib/libwebp.a +0 -0
- data/assets/test_media/README.md +3 -0
- data/assets/test_media/bitstream_vera/COPYRIGHT.txt +124 -0
- data/assets/test_media/bitstream_vera/vera.ttf +0 -0
- data/assets/test_media/boom.png +0 -0
- data/assets/test_media/coin.png +0 -0
- data/assets/test_media/colors.png +0 -0
- data/assets/test_media/controller.png +0 -0
- data/assets/test_media/dial.wav +0 -0
- data/assets/test_media/hero.png +0 -0
- data/assets/test_media/image.bmp +0 -0
- data/assets/test_media/image.jpg +0 -0
- data/assets/test_media/image.png +0 -0
- data/assets/test_media/music.flac +0 -0
- data/assets/test_media/music.mp3 +0 -0
- data/assets/test_media/music.ogg +0 -0
- data/assets/test_media/music.wav +0 -0
- data/assets/test_media/originals/boom.pxm +0 -0
- data/assets/test_media/originals/coin.pxm +0 -0
- data/assets/test_media/originals/controller.sketch +0 -0
- data/assets/test_media/originals/hero.pxm +0 -0
- data/assets/test_media/originals/image.pxm +0 -0
- data/assets/test_media/originals/music.caf +0 -0
- data/assets/test_media/originals/texture_atlas.pxm +0 -0
- data/assets/test_media/rondo_alla_turka.ogg +0 -0
- data/assets/test_media/sound.flac +0 -0
- data/assets/test_media/sound.mp3 +0 -0
- data/assets/test_media/sound.ogg +0 -0
- data/assets/test_media/sound.wav +0 -0
- data/assets/test_media/sprite_sheet.png +0 -0
- data/assets/test_media/texture_atlas.png +0 -0
- data/assets/wasm/build_config.rb +13 -0
- data/assets/wasm/libmruby.a +0 -0
- data/assets/wasm/template.html +17 -0
- data/assets/windows/glew/README.md +10 -0
- data/assets/windows/glew/glew.h +23686 -0
- data/assets/{mingw/lib → windows/glew}/libglew32.a +0 -0
- data/assets/windows/mingw-w64-x86_64/bin/mrbc.exe +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libFLAC.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libLerc.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libSDL2.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libSDL2_image.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libSDL2_mixer.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libSDL2_ttf.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libbrotlicommon.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libbrotlidec.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libbz2.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libdeflate.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libfreetype.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libglew32.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libgraphite2.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libharfbuzz.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libjbig.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libjpeg.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/liblzma.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libmodplug.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libmpg123.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libmruby.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libogg.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libopus.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libopusfile.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libpng16.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libsndfile.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libssp.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libstdc++.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libtiff.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libvorbis.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libvorbisfile.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libwebp.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libz.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libzstd.a +0 -0
- data/assets/{ios → xcode/ios}/Assets.xcassets/AppIcon.appiconset/Contents.json +0 -0
- data/assets/{ios → xcode/ios}/Assets.xcassets/Contents.json +0 -0
- data/assets/{ios → xcode/ios}/Base.lproj/LaunchScreen.storyboard +0 -0
- data/assets/{ios → xcode/ios}/Info.plist +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mrbconf.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/array.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/boxing_nan.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/boxing_no.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/boxing_word.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/class.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/common.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/compile.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/data.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/debug.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/dump.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/error.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/gc.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/hash.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/irep.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/istruct.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/khash.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/numeric.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/object.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/opcode.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/ops.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/proc.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/range.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/re.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/string.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/throw.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/value.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/variable.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby/version.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Headers/mruby.h +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/Info.plist +0 -0
- data/assets/{ios → xcode/ios}/MRuby.framework/MRuby +0 -0
- data/assets/{ios → xcode/ios}/MyApp.xcodeproj/project.pbxproj +0 -0
- data/assets/{ios → xcode/ios}/MyApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -0
- data/assets/{ios → xcode/ios}/MyApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -0
- data/assets/{ios → xcode/ios}/MyApp.xcodeproj/project.xcworkspace/xcshareddata/MyApp.xcscmblueprint +0 -0
- data/assets/{ios → xcode/ios}/main.c +0 -0
- 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
- data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Back.imagestacklayer/Contents.json +0 -0
- data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Contents.json +0 -0
- 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
- data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Front.imagestacklayer/Contents.json +0 -0
- 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
- data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Middle.imagestacklayer/Contents.json +0 -0
- 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
- data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Back.imagestacklayer/Contents.json +0 -0
- data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Contents.json +0 -0
- 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
- data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Front.imagestacklayer/Contents.json +0 -0
- 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
- data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Middle.imagestacklayer/Contents.json +0 -0
- data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Contents.json +0 -0
- data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image Wide.imageset/Contents.json +0 -0
- data/assets/{tvos → xcode/tvos}/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image.imageset/Contents.json +0 -0
- data/assets/{tvos → xcode/tvos}/Assets.xcassets/Contents.json +0 -0
- data/assets/{tvos → xcode/tvos}/Assets.xcassets/LaunchImage.launchimage/Contents.json +0 -0
- data/assets/{tvos → xcode/tvos}/Info.plist +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mrbconf.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/array.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/boxing_nan.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/boxing_no.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/boxing_word.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/class.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/common.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/compile.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/data.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/debug.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/dump.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/error.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/gc.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/hash.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/irep.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/istruct.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/khash.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/numeric.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/object.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/opcode.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/ops.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/proc.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/range.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/re.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/string.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/throw.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/value.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/variable.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby/version.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Headers/mruby.h +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/Info.plist +0 -0
- data/assets/{tvos → xcode/tvos}/MRuby.framework/MRuby +0 -0
- data/assets/{tvos → xcode/tvos}/MyApp.xcodeproj/project.pbxproj +0 -0
- data/assets/{tvos → xcode/tvos}/MyApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -0
- data/assets/{tvos → xcode/tvos}/MyApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -0
- data/assets/{tvos → xcode/tvos}/MyApp.xcodeproj/project.xcworkspace/xcshareddata/MyApp.xcscmblueprint +0 -0
- data/assets/{tvos → xcode/tvos}/main.c +0 -0
- data/bin/ruby2d +3 -4
- data/ext/ruby2d/extconf.rb +68 -46
- data/ext/ruby2d/font.c +35 -0
- data/ext/ruby2d/gl.c +9 -58
- data/ext/ruby2d/gl2.c +8 -83
- data/ext/ruby2d/gl3.c +57 -116
- data/ext/ruby2d/gles.c +130 -151
- data/ext/ruby2d/image.c +16 -96
- data/ext/ruby2d/ruby2d.c +265 -298
- data/ext/ruby2d/ruby2d.h +69 -159
- data/ext/ruby2d/sound.c +1 -1
- data/ext/ruby2d/text.c +20 -114
- data/ext/ruby2d/window.c +257 -219
- data/lib/ruby2d/circle.rb +3 -1
- data/lib/ruby2d/cli/build.rb +239 -59
- data/lib/ruby2d/cli/colorize.rb +5 -4
- data/lib/ruby2d/cli/platform.rb +17 -0
- data/lib/ruby2d/font.rb +26 -1
- data/lib/ruby2d/image.rb +22 -17
- data/lib/ruby2d/line.rb +3 -1
- data/lib/ruby2d/quad.rb +3 -1
- data/lib/ruby2d/rectangle.rb +1 -1
- data/lib/ruby2d/renderable.rb +0 -12
- data/lib/ruby2d/sound.rb +25 -0
- data/lib/ruby2d/sprite.rb +44 -89
- data/lib/ruby2d/square.rb +1 -1
- data/lib/ruby2d/text.rb +40 -20
- data/lib/ruby2d/texture.rb +28 -0
- data/lib/ruby2d/tileset.rb +47 -28
- data/lib/ruby2d/triangle.rb +3 -1
- data/lib/ruby2d/version.rb +1 -1
- data/lib/ruby2d/vertices.rb +89 -0
- data/lib/ruby2d/window.rb +13 -3
- data/lib/ruby2d.rb +16 -20
- metadata +249 -153
- data/assets/README.md +0 -22
- data/assets/Rakefile +0 -85
- data/assets/macos/lib/libFLAC.a +0 -0
- data/assets/macos/lib/libSDL2.a +0 -0
- data/assets/macos/lib/libSDL2_image.a +0 -0
- data/assets/macos/lib/libSDL2_ttf.a +0 -0
- data/assets/macos/lib/libfreetype.a +0 -0
- data/assets/macos/lib/libjpeg.a +0 -0
- data/assets/macos/lib/libpng16.a +0 -0
- data/assets/macos/lib/libtiff.a +0 -0
- data/assets/macos/lib/libvorbis.a +0 -0
- data/assets/macos/lib/libvorbisfile.a +0 -0
- data/assets/macos/lib/libwebp.a +0 -0
- data/assets/mingw/bin/SDL2.dll +0 -0
- data/assets/mingw/bin/SDL2_image.dll +0 -0
- data/assets/mingw/bin/SDL2_mixer.dll +0 -0
- data/assets/mingw/bin/SDL2_ttf.dll +0 -0
- data/assets/mingw/bin/glew32.dll +0 -0
- data/assets/mingw/bin/libFLAC-8.dll +0 -0
- data/assets/mingw/bin/libfreetype-6.dll +0 -0
- data/assets/mingw/bin/libjpeg-9.dll +0 -0
- data/assets/mingw/bin/libmodplug-1.dll +0 -0
- data/assets/mingw/bin/libmpg123-0.dll +0 -0
- data/assets/mingw/bin/libogg-0.dll +0 -0
- data/assets/mingw/bin/libopus-0.dll +0 -0
- data/assets/mingw/bin/libopusfile-0.dll +0 -0
- data/assets/mingw/bin/libpng16-16.dll +0 -0
- data/assets/mingw/bin/libtiff-5.dll +0 -0
- data/assets/mingw/bin/libvorbis-0.dll +0 -0
- data/assets/mingw/bin/libvorbisfile-3.dll +0 -0
- data/assets/mingw/bin/libwebp-7.dll +0 -0
- data/assets/mingw/bin/zlib1.dll +0 -0
- data/assets/mingw/lib/libSDL2.dll.a +0 -0
- data/assets/mingw/lib/libSDL2_image.a +0 -0
- data/assets/mingw/lib/libSDL2_image.dll.a +0 -0
- data/assets/mingw/lib/libSDL2_mixer.a +0 -0
- data/assets/mingw/lib/libSDL2_mixer.dll.a +0 -0
- data/assets/mingw/lib/libSDL2_test.a +0 -0
- data/assets/mingw/lib/libSDL2_ttf.a +0 -0
- data/assets/mingw/lib/libSDL2_ttf.dll.a +0 -0
- data/assets/mingw/lib/libSDL2main.a +0 -0
- data/assets/mingw/lib/libglew32.dll.a +0 -0
- data/ext/ruby2d/sprite.c +0 -147
- 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
|
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
|
242
|
-
|
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
|
-
|
252
|
-
|
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
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
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, :
|
8
|
-
attr_accessor :x, :y, :
|
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
|
-
@
|
20
|
-
|
21
|
-
|
22
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
50
|
-
|
51
|
-
|
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
|
data/lib/ruby2d/tileset.rb
CHANGED
@@ -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
|
-
|
49
|
-
|
50
|
-
end
|
52
|
+
def draw
|
53
|
+
Window.render_ready_check
|
51
54
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
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
|
data/lib/ruby2d/triangle.rb
CHANGED
@@ -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],
|
data/lib/ruby2d/version.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
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
|
-
|
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
|