From 33ec37b141e896b47ed642923fd33b0c658ae9fb Mon Sep 17 00:00:00 2001 From: Amir Rajan Date: Fri, 11 Sep 2020 02:02:01 -0500 Subject: synced samples --- .../app/main.rb | 98 --------------------- .../license-for-sample.txt | 9 -- .../sprites/horizontal-run.png | Bin 20080 -> 0 bytes .../sprites/horizontal-stand.png | Bin 4120 -> 0 bytes 4 files changed, 107 deletions(-) delete mode 100644 samples/09_sprite_animation_using_tile_sheet/app/main.rb delete mode 100644 samples/09_sprite_animation_using_tile_sheet/license-for-sample.txt delete mode 100644 samples/09_sprite_animation_using_tile_sheet/sprites/horizontal-run.png delete mode 100644 samples/09_sprite_animation_using_tile_sheet/sprites/horizontal-stand.png (limited to 'samples/09_sprite_animation_using_tile_sheet') diff --git a/samples/09_sprite_animation_using_tile_sheet/app/main.rb b/samples/09_sprite_animation_using_tile_sheet/app/main.rb deleted file mode 100644 index 17bfd49..0000000 --- a/samples/09_sprite_animation_using_tile_sheet/app/main.rb +++ /dev/null @@ -1,98 +0,0 @@ -def tick args - args.state.player.x ||= 100 - args.state.player.y ||= 100 - args.state.player.w ||= 64 - args.state.player.h ||= 64 - args.state.player.direction ||= 1 - - args.state.player.is_moving = false - - # get the keyboard input and set player properties - if args.inputs.keyboard.right - args.state.player.x += 3 - args.state.player.direction = 1 - args.state.player.started_running_at ||= args.state.tick_count - elsif args.inputs.keyboard.left - args.state.player.x -= 3 - args.state.player.direction = -1 - args.state.player.started_running_at ||= args.state.tick_count - end - - if args.inputs.keyboard.up - args.state.player.y += 1 - args.state.player.started_running_at ||= args.state.tick_count - elsif args.inputs.keyboard.down - args.state.player.y -= 1 - args.state.player.started_running_at ||= args.state.tick_count - end - - # if no arrow keys are being pressed, set the player as not moving - if !args.inputs.keyboard.directional_vector - args.state.player.started_running_at = nil - end - - # wrap player around the stage - if args.state.player.x > 1280 - args.state.player.x = -64 - args.state.player.started_running_at ||= args.state.tick_count - elsif args.state.player.x < -64 - args.state.player.x = 1280 - args.state.player.started_running_at ||= args.state.tick_count - end - - if args.state.player.y > 720 - args.state.player.y = -64 - args.state.player.started_running_at ||= args.state.tick_count - elsif args.state.player.y < -64 - args.state.player.y = 720 - args.state.player.started_running_at ||= args.state.tick_count - end - - # render player as standing or running - if args.state.player.started_running_at - args.outputs.sprites << running_sprite(args) - else - args.outputs.sprites << standing_sprite(args) - end - args.outputs.labels << [30, 700, "Use arrow keys to move around."] -end - -def standing_sprite args - { - x: args.state.player.x, - y: args.state.player.y, - w: args.state.player.w, - h: args.state.player.h, - path: "sprites/horizontal-stand.png", - flip_horizontally: args.state.player.direction > 0 - } -end - -def running_sprite args - if !args.state.player.started_running_at - tile_index = 0 - else - how_many_frames_in_sprite_sheet = 6 - how_many_ticks_to_hold_each_frame = 3 - should_the_index_repeat = true - tile_index = args.state - .player - .started_running_at - .frame_index(how_many_frames_in_sprite_sheet, - how_many_ticks_to_hold_each_frame, - should_the_index_repeat) - end - - { - x: args.state.player.x, - y: args.state.player.y, - w: args.state.player.w, - h: args.state.player.h, - path: 'sprites/horizontal-run.png', - tile_x: 0 + (tile_index * args.state.player.w), - tile_y: 0, - tile_w: args.state.player.w, - tile_h: args.state.player.h, - flip_horizontally: args.state.player.direction > 0, - } -end diff --git a/samples/09_sprite_animation_using_tile_sheet/license-for-sample.txt b/samples/09_sprite_animation_using_tile_sheet/license-for-sample.txt deleted file mode 100644 index 100dcec..0000000 --- a/samples/09_sprite_animation_using_tile_sheet/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. diff --git a/samples/09_sprite_animation_using_tile_sheet/sprites/horizontal-run.png b/samples/09_sprite_animation_using_tile_sheet/sprites/horizontal-run.png deleted file mode 100644 index 1e98253..0000000 Binary files a/samples/09_sprite_animation_using_tile_sheet/sprites/horizontal-run.png and /dev/null differ diff --git a/samples/09_sprite_animation_using_tile_sheet/sprites/horizontal-stand.png b/samples/09_sprite_animation_using_tile_sheet/sprites/horizontal-stand.png deleted file mode 100644 index 9d320e7..0000000 Binary files a/samples/09_sprite_animation_using_tile_sheet/sprites/horizontal-stand.png and /dev/null differ -- cgit v1.2.3