diff options
| author | _Tradam <[email protected]> | 2021-12-16 19:22:26 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-12-16 19:22:26 -0500 |
| commit | 5954b9beb4d4a3b4f248d72d1851195f030558a8 (patch) | |
| tree | fecd8aa840a25afdb502915b0fdb4d03b7ed339a /samples/07_advanced_rendering/02_render_targets_with_alphas | |
| parent | 2f845281f133849256b57bb08fd3e9ae57600784 (diff) | |
| parent | eaa29e72939f5edf61735ccbb73c36ee89369f65 (diff) | |
| download | dragonruby-game-toolkit-contrib-master.tar.gz dragonruby-game-toolkit-contrib-master.zip | |
Diffstat (limited to 'samples/07_advanced_rendering/02_render_targets_with_alphas')
| -rw-r--r-- | samples/07_advanced_rendering/02_render_targets_with_alphas/app/main.rb | 95 | ||||
| -rw-r--r-- | samples/07_advanced_rendering/02_render_targets_with_alphas/license-for-sample.txt | 9 |
2 files changed, 0 insertions, 104 deletions
diff --git a/samples/07_advanced_rendering/02_render_targets_with_alphas/app/main.rb b/samples/07_advanced_rendering/02_render_targets_with_alphas/app/main.rb deleted file mode 100644 index 2caec43..0000000 --- a/samples/07_advanced_rendering/02_render_targets_with_alphas/app/main.rb +++ /dev/null @@ -1,95 +0,0 @@ -# This sample is meant to show you how to do that dripping transition thing -# at the start of the original Doom. Most of this file is here to animate -# a scene to wipe away; the actual wipe effect is in the last 20 lines or -# so. - -$gtk.reset # reset all game state if reloaded. - -def circle_of_blocks pass, xoffset, yoffset, angleoffset, blocksize, distance - numblocks = 10 - - for i in 1..numblocks do - angle = ((360 / numblocks) * i) + angleoffset - radians = angle * (Math::PI / 180) - x = (xoffset + (distance * Math.cos(radians))).round - y = (yoffset + (distance * Math.sin(radians))).round - pass.solids << [ x, y, blocksize, blocksize, 255, 255, 0 ] - end -end - -def draw_scene args, pass - pass.solids << [0, 360, 1280, 360, 0, 0, 200] - pass.solids << [0, 0, 1280, 360, 0, 127, 0] - - blocksize = 100 - angleoffset = args.state.tick_count * 2.5 - centerx = (1280 - blocksize) / 2 - centery = (720 - blocksize) / 2 - - circle_of_blocks pass, centerx, centery, angleoffset, blocksize * 2, 500 - circle_of_blocks pass, centerx, centery, angleoffset, blocksize, 325 - circle_of_blocks pass, centerx, centery, angleoffset, blocksize / 2, 200 - circle_of_blocks pass, centerx, centery, angleoffset, blocksize / 4, 100 -end - -def tick args - segments = 160 - - # On the first tick, initialize some stuff. - if !args.state.yoffsets - args.state.baseyoff = 0 - args.state.yoffsets = [] - for i in 0..segments do - args.state.yoffsets << rand * 100 - end - end - - # Just draw some random stuff for a few seconds. - args.state.static_debounce ||= 60 * 2.5 - if args.state.static_debounce > 0 - last_frame = args.state.static_debounce == 1 - target = last_frame ? args.render_target(:last_frame) : args.outputs - draw_scene args, target - args.state.static_debounce -= 1 - return unless last_frame - end - - # build up the wipe... - - # this is the thing we're wiping to. - args.outputs.sprites << [ 0, 0, 1280, 720, 'dragonruby.png' ] - - return if (args.state.baseyoff > (1280 + 100)) # stop when done sliding - - segmentw = 1280 / segments - - x = 0 - for i in 0..segments do - yoffset = 0 - if args.state.yoffsets[i] < args.state.baseyoff - yoffset = args.state.baseyoff - args.state.yoffsets[i] - end - - # (720 - yoffset) flips the coordinate system, (- 720) adjusts for the height of the segment. - args.outputs.sprites << [ x, (720 - yoffset) - 720, segmentw, 720, 'last_frame', 0, 255, 255, 255, 255, x, 0, segmentw, 720 ] - x += segmentw - end - - args.state.baseyoff += 4 - - tick_instructions args, "Sample app shows an advanced usage of render_target." -end - -def tick_instructions args, text, y = 715 - return if args.state.key_event_occurred - if args.inputs.mouse.click || - args.inputs.keyboard.directional_vector || - args.inputs.keyboard.key_down.enter || - args.inputs.keyboard.key_down.escape - args.state.key_event_occurred = true - end - - args.outputs.debug << [0, y - 50, 1280, 60].solid - args.outputs.debug << [640, y, text, 1, 1, 255, 255, 255].label - args.outputs.debug << [640, y - 25, "(click to dismiss instructions)" , -2, 1, 255, 255, 255].label -end diff --git a/samples/07_advanced_rendering/02_render_targets_with_alphas/license-for-sample.txt b/samples/07_advanced_rendering/02_render_targets_with_alphas/license-for-sample.txt deleted file mode 100644 index 100dcec..0000000 --- a/samples/07_advanced_rendering/02_render_targets_with_alphas/license-for-sample.txt +++ /dev/null @@ -1,9 +0,0 @@ -Copyright 2019 DragonRuby LLC - -MIT License - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
