diff options
| author | _Tradam <[email protected]> | 2022-01-03 08:26:24 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-01-03 08:26:24 -0500 |
| commit | a0f792d8feadf919290b8349dbc0eac143545927 (patch) | |
| tree | ee70c5357d5969caaed08446c32746e656b223e6 /deprecated | |
| parent | b535a6b1bd8019dbeba17f3853b338383208c9b3 (diff) | |
| download | FelECS-4.0.0.tar.gz FelECS-4.0.0.zip | |
See Changelog
Diffstat (limited to 'deprecated')
| -rw-r--r-- | deprecated/components/00_renderable.rb | 36 | ||||
| -rw-r--r-- | deprecated/components/01_sprite.rb | 103 | ||||
| -rw-r--r-- | deprecated/components/03_player_control.rb | 47 | ||||
| -rw-r--r-- | deprecated/components/04_map.rb | 3 | ||||
| -rw-r--r-- | deprecated/components/05_interactable.rb | 4 | ||||
| -rw-r--r-- | deprecated/components/06_collidable.rb | 10 | ||||
| -rw-r--r-- | deprecated/components/07_battle.rb | 2 | ||||
| -rw-r--r-- | deprecated/components/07_indoor.rb | 2 | ||||
| -rw-r--r-- | deprecated/components/07_overworld.rb | 4 | ||||
| -rw-r--r-- | deprecated/components/debug_singleton.rb | 4 | ||||
| -rw-r--r-- | deprecated/helpers/00_tileset.rb | 28 | ||||
| -rw-r--r-- | deprecated/helpers/01_component.rb | 131 | ||||
| -rw-r--r-- | deprecated/systems/00_update_levels.rb | 4 | ||||
| -rw-r--r-- | deprecated/systems/10_player.rb | 44 | ||||
| -rw-r--r-- | deprecated/systems/99_render.rb | 38 |
15 files changed, 238 insertions, 222 deletions
diff --git a/deprecated/components/00_renderable.rb b/deprecated/components/00_renderable.rb index 1d34fbb..32c93b6 100644 --- a/deprecated/components/00_renderable.rb +++ b/deprecated/components/00_renderable.rb @@ -1,19 +1,19 @@ -FelFlame::Components.new('Renderable', z: 0) -=begin -class Components - # If an entity can be rendered on screen - class Renderable < Helper::BaseComponent - attr_accessor :z - - def initialize - @z = 0 - end +# frozen_string_literal: true - def set(**opts) - opts.each do |key, value| - self.send "#{key}=", value - end - end - end -end -=end +FelFlame::Components.new('Renderable', z: 0) +# class Components +# # If an entity can be rendered on screen +# class Renderable < Helper::BaseComponent +# attr_accessor :z +# +# def initialize +# @z = 0 +# end +# +# def set(**opts) +# opts.each do |key, value| +# self.send "#{key}=", value +# end +# end +# end +# end diff --git a/deprecated/components/01_sprite.rb b/deprecated/components/01_sprite.rb index c02a51b..4ae6713 100644 --- a/deprecated/components/01_sprite.rb +++ b/deprecated/components/01_sprite.rb @@ -1,57 +1,56 @@ +# frozen_string_literal: true FelFlame::Components.new('Sprite', :x, :y, :w, :h, :path, :angle, :a, :r, :g, :b, - :source_x, :source_y, :source_w, :source_h, - :tile_x, :tile_y, :tile_w, :tile_h, - :flip_horizontally, :flip_vertically, - :angle_anchor_x, :angle_anchor_y, primative_marker: :sprite) + :source_x, :source_y, :source_w, :source_h, + :tile_x, :tile_y, :tile_w, :tile_h, + :flip_horizontally, :flip_vertically, + :angle_anchor_x, :angle_anchor_y, primative_marker: :sprite) -#Components::Sprite.define_method('primative_marker') do +# Components::Sprite.define_method('primative_marker') do # :sprite -#end +# end -=begin -class Components - # If an entity can be rendered on screen - class Sprite < Helper::BaseComponent - - attr_accessor :x, :y, :w, :h, :path, :angle, :a, :r, :g, :b, - :source_x, :source_y, :source_w, :source_h, - :tile_x, :tile_y, :tile_w, :tile_h, - :flip_horizontally, :flip_vertically, - :angle_anchor_x, :angle_anchor_y - - def set(x: @x, y: @y, w: @w, h: @h, path: @path, angle: @angle, a: @a, r: @r, g: @g, b: @b, - source_x: @source_x, source_y: @source_y, source_w: @source_w, source_h: @source_h, - tile_x: @tile_x, tile_y: @tile_y, tile_w: @tile_w, tile_h: @tile_h, - flip_horizontally: @flip_horizontally, flip_vertically: @flip_vertically, - angle_anchor_x: @angle_anchor_x, angle_anchor_y: @angle_anchor_y) - {x: @x = x, - y: @y = y, - w: @w = w, - h: @h = h, - path: @path = path, - angle: @angle = angle, - a: @a = a, - r: @r = r, - g: @g = g, - b: @b = b, - source_x: @source_x = source_x, - source_y: @source_y = source_y, - source_w: @source_w = source_w, - source_h: @source_h = source_h, - tile_x: @tile_x = tile_x, - tile_y: @tile_y = tile_y, - tile_w: @tile_w = tile_w, - tile_h: @tile_h = tile_h, - flip_horizontally: @flip_horizontally = flip_horizontally, - flip_vertically: @flip_vertically = flip_vertically, - angle_anchor_x: @angle_anchor_x = angle_anchor_x, - angle_anchor_y: @angle_anchor_y = angle_anchor_y} - end - - def primative_marker - :sprite - end - end -end -=end +# class Components +# # If an entity can be rendered on screen +# class Sprite < Helper::BaseComponent +# +# attr_accessor :x, :y, :w, :h, :path, :angle, :a, :r, :g, :b, +# :source_x, :source_y, :source_w, :source_h, +# :tile_x, :tile_y, :tile_w, :tile_h, +# :flip_horizontally, :flip_vertically, +# :angle_anchor_x, :angle_anchor_y +# +# def set(x: @x, y: @y, w: @w, h: @h, path: @path, angle: @angle, a: @a, r: @r, g: @g, b: @b, +# source_x: @source_x, source_y: @source_y, source_w: @source_w, source_h: @source_h, +# tile_x: @tile_x, tile_y: @tile_y, tile_w: @tile_w, tile_h: @tile_h, +# flip_horizontally: @flip_horizontally, flip_vertically: @flip_vertically, +# angle_anchor_x: @angle_anchor_x, angle_anchor_y: @angle_anchor_y) +# {x: @x = x, +# y: @y = y, +# w: @w = w, +# h: @h = h, +# path: @path = path, +# angle: @angle = angle, +# a: @a = a, +# r: @r = r, +# g: @g = g, +# b: @b = b, +# source_x: @source_x = source_x, +# source_y: @source_y = source_y, +# source_w: @source_w = source_w, +# source_h: @source_h = source_h, +# tile_x: @tile_x = tile_x, +# tile_y: @tile_y = tile_y, +# tile_w: @tile_w = tile_w, +# tile_h: @tile_h = tile_h, +# flip_horizontally: @flip_horizontally = flip_horizontally, +# flip_vertically: @flip_vertically = flip_vertically, +# angle_anchor_x: @angle_anchor_x = angle_anchor_x, +# angle_anchor_y: @angle_anchor_y = angle_anchor_y} +# end +# +# def primative_marker +# :sprite +# end +# end +# end diff --git a/deprecated/components/03_player_control.rb b/deprecated/components/03_player_control.rb index f48b155..6414547 100644 --- a/deprecated/components/03_player_control.rb +++ b/deprecated/components/03_player_control.rb @@ -1,26 +1,25 @@ +# frozen_string_literal: true FelFlame::Components.new :PlayerControl, north: 'up', south: 'down', east: 'right', - west: 'left', interact: 'space', menu: 'enter' -=begin -class Components - # Gives control(keyboard or otherwise) over an object - class PlayerControl < Helper::BaseComponent - attr_accessor :north, :south, :east, :west, :interact, :menu - - def initialize - @north = 'up' - @south = 'down' - @east = 'right' - @west = 'left' - @interact = 'space' - @menu = 'enter' - end - - def set(**opts) - opts.each do |key, value| - send "#{key}=", value - end - end - end -end -=end + west: 'left', interact: 'space', menu: 'enter' +# class Components +# # Gives control(keyboard or otherwise) over an object +# class PlayerControl < Helper::BaseComponent +# attr_accessor :north, :south, :east, :west, :interact, :menu +# +# def initialize +# @north = 'up' +# @south = 'down' +# @east = 'right' +# @west = 'left' +# @interact = 'space' +# @menu = 'enter' +# end +# +# def set(**opts) +# opts.each do |key, value| +# send "#{key}=", value +# end +# end +# end +# end diff --git a/deprecated/components/04_map.rb b/deprecated/components/04_map.rb index 7700e9f..5d110f0 100644 --- a/deprecated/components/04_map.rb +++ b/deprecated/components/04_map.rb @@ -1,7 +1,8 @@ +# frozen_string_literal: true + class Components # dragonruby label wrapper class Map < Helper::BaseComponent - attr_accessor :json_name, :json, :x, :y, :tilewidth, :tileheight, :a, :r, :g, :b def set(json_name: @json_name, x: @x, y: @y, tilewidth: @tilewidth, diff --git a/deprecated/components/05_interactable.rb b/deprecated/components/05_interactable.rb index 636a216..bee91f6 100644 --- a/deprecated/components/05_interactable.rb +++ b/deprecated/components/05_interactable.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Components # If an entity can be rendered on screen class Interactable < Helper::BaseComponent @@ -9,7 +11,7 @@ class Components def set(**opts) opts.each do |key, value| - self.send "#{key}=", value + send "#{key}=", value end end end diff --git a/deprecated/components/06_collidable.rb b/deprecated/components/06_collidable.rb index 76ce51e..4fde638 100644 --- a/deprecated/components/06_collidable.rb +++ b/deprecated/components/06_collidable.rb @@ -1,11 +1,9 @@ +# frozen_string_literal: true + class Components # If an entity can be rendered on screen class Collidable < Helper::BaseComponent - class <<self - def add(entity_id) - super(entity_id) - #add to grid? - end + class << self end attr_accessor :grid @@ -15,7 +13,7 @@ class Components def set(**opts) opts.each do |key, value| - self.send "#{key}=", value + send "#{key}=", value end end end diff --git a/deprecated/components/07_battle.rb b/deprecated/components/07_battle.rb index b4ef622..996c03c 100644 --- a/deprecated/components/07_battle.rb +++ b/deprecated/components/07_battle.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Components class Battle < Helper::Level end diff --git a/deprecated/components/07_indoor.rb b/deprecated/components/07_indoor.rb index e409da8..762c239 100644 --- a/deprecated/components/07_indoor.rb +++ b/deprecated/components/07_indoor.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Components class Indoor < Helper::Level end diff --git a/deprecated/components/07_overworld.rb b/deprecated/components/07_overworld.rb index 55ab38a..cea11f5 100644 --- a/deprecated/components/07_overworld.rb +++ b/deprecated/components/07_overworld.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Components class Overworld < Helper::Level attr_accessor :x, :y @@ -9,7 +11,7 @@ class Components def set(**opts) opts.each do |key, value| - self.send "#{key}=", value + send "#{key}=", value end end end diff --git a/deprecated/components/debug_singleton.rb b/deprecated/components/debug_singleton.rb index f298172..e667191 100644 --- a/deprecated/components/debug_singleton.rb +++ b/deprecated/components/debug_singleton.rb @@ -1,7 +1,9 @@ +# frozen_string_literal: true + class Components # If an entity can be rendered on screen class DebugSingleton - class <<self + class << self @data = false attr_accessor :data diff --git a/deprecated/helpers/00_tileset.rb b/deprecated/helpers/00_tileset.rb index c4293cb..9d727f9 100644 --- a/deprecated/helpers/00_tileset.rb +++ b/deprecated/helpers/00_tileset.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Coverage Ignored because the functionality of this # code will not be used for the core of FelFlame. # It will most likely be released as a seperate package @@ -9,39 +11,39 @@ class Helper # If any are missing then it will load them from files @json_data = {} - class <<self + class << self attr_accessor :json_data def get_json_tiles(json_name, hitbox: false) - unless hitbox - return nil if json_name == 'hitbox' && !Components::DebugSingleton.data - end + return nil if !hitbox && (json_name == 'hitbox' && !Components::DebugSingleton.data) - if self.json_data[json_name].nil? - self.json_data[json_name] = $gtk.parse_json_file "assets/json/#{json_name}.json" - raise Exception.new "#{json_name} is null and not loaded. Cannot get json tile" if self.json_data[json_name].nil? + if json_data[json_name].nil? + json_data[json_name] = $gtk.parse_json_file "assets/json/#{json_name}.json" + raise StandardError, "#{json_name} is null and not loaded. Cannot get json tile" if json_data[json_name].nil? - if self.json_data[json_name]['type'] == 'map' #json_name.split("_").first == 'map' - self.json_data[json_name]['tilesets'].each do |tileset| + if json_data[json_name]['type'] == 'map' # json_name.split("_").first == 'map' + json_data[json_name]['tilesets'].each do |tileset| tileset = Helper.get_json_tiles(tileset['source'].split('/').last.delete_suffix('.tsx')) # download tileset here # $gtk.args.gtk.http_get 'https://mysite.net/#{tileset['name']}.png' end end end - self.json_data[json_name] + json_data[json_name] end def get_tile(json_name:, tile_index:) if json_name == 'hitbox' && !Components::DebugSingleton.data return tile_index - 1 if tile_index > 1 + return {} end - json_tiles = self.get_json_tiles(json_name) - raise Exception.new "Error, json file not a tileset" unless json_tiles['type'] == 'tileset' + json_tiles = get_json_tiles(json_name) + raise StandardError, 'Error, json file not a tileset' unless json_tiles['type'] == 'tileset' return tile_index - json_tiles['tilecount'] if tile_index > json_tiles['tilecount'] - source_height_tiles = (tile_index.to_i / json_tiles['columns'].to_i).to_i# * json_tiles['tileheight'] + + source_height_tiles = (tile_index.to_i / json_tiles['columns'].to_i).to_i # * json_tiles['tileheight'] { w: json_tiles['tilewidth'], h: json_tiles['tileheight'], path: json_tiles['image'].split('mygame/').last.delete('\\'), diff --git a/deprecated/helpers/01_component.rb b/deprecated/helpers/01_component.rb index 2065d0c..12cce09 100644 --- a/deprecated/helpers/01_component.rb +++ b/deprecated/helpers/01_component.rb @@ -1,74 +1,67 @@ +# frozen_string_literal: true + class FelFlame class Helper + # # Unused: + # class Level < FelFlame::Helper::ComponentManager + # class <<self + # def data + # @data ||= { add: [], remove: [], grid: FelFlame::Helper::Array2D.new } + # end + # + # def add(entity_id) + # super + # data[:add].push entity_id + # end + # + # def remove(entity_id) + # data[:remove].push entity_id + # super + # end + # end + # end + # class Array2D < Array + # def [](val) + # unless val.nil? + # return self[val] = [] if super.nil? + # end + # super + # end + # end + # class ArrayOfHashes < Array + # def [](val) + # unless val.nil? + # return self[val] = {} if super.nil? + # end + # super + # end + # end -=begin - # Unused: - class Level < FelFlame::Helper::ComponentManager - class <<self - def data - @data ||= { add: [], remove: [], grid: FelFlame::Helper::Array2D.new } - end - - def add(entity_id) - super - data[:add].push entity_id - end - - def remove(entity_id) - data[:remove].push entity_id - super - end - end - end -=end -=begin - class Array2D < Array - def [](val) - unless val.nil? - return self[val] = [] if super.nil? - end - super - end - end -=end -=begin - class ArrayOfHashes < Array - def [](val) - unless val.nil? - return self[val] = {} if super.nil? - end - super - end - end -=end - -=begin - module ComponentHelper - class <<self - def up? char - char == char.upcase - end - - def down? char - char == char.downcase - end - - def underscore(input) - output = input[0].downcase - (1...(input.length - 1)).each do |iter| - if down?(input[iter]) && up?(input[iter + 1]) - output += "#{input[iter].downcase}_" - elsif up?(input[iter - 1]) && up?(input[iter]) && down?(input[iter + 1]) - output += "_#{input[iter].downcase}" - else - output += input[iter].downcase - end - end - output += input[-1].downcase unless input.length == 1 - output - end - end - end -=end + # module ComponentHelper + # class <<self + # def up? char + # char == char.upcase + # end + # + # def down? char + # char == char.downcase + # end + # + # def underscore(input) + # output = input[0].downcase + # (1...(input.length - 1)).each do |iter| + # if down?(input[iter]) && up?(input[iter + 1]) + # output += "#{input[iter].downcase}_" + # elsif up?(input[iter - 1]) && up?(input[iter]) && down?(input[iter + 1]) + # output += "_#{input[iter].downcase}" + # else + # output += input[iter].downcase + # end + # end + # output += input[-1].downcase unless input.length == 1 + # output + # end + # end + # end end end diff --git a/deprecated/systems/00_update_levels.rb b/deprecated/systems/00_update_levels.rb index 6f3a056..5805123 100644 --- a/deprecated/systems/00_update_levels.rb +++ b/deprecated/systems/00_update_levels.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Systems class UpdateLevels @co = Components::Overworld @@ -6,7 +8,7 @@ class Systems @co.data[:add].delete(id) if !(Components::Sprite.id & Entity.signatures[id]).zero? @co.data[:grid][@co.data[id].x][@co.data[id].y] = {} if @co.data[:grid][@co.data[id].x][@co.data[id].y].nil? - #@co.data[:grid][@co.data[id].x][@co.data[id].y].merge!({ player: true }) + # @co.data[:grid][@co.data[id].x][@co.data[id].y].merge!({ player: true }) puts @co.data[:grid][@co.data[id].x][@co.data[id].y].inspect elsif !(Components::Map.id & Entity.signatures[id]).zero? if Components::Map.data[id].json['tilesets'].last['source'].split('/').last.delete('\\').delete_suffix('.tsx') == 'hitbox' diff --git a/deprecated/systems/10_player.rb b/deprecated/systems/10_player.rb index 307731a..ae8564d 100644 --- a/deprecated/systems/10_player.rb +++ b/deprecated/systems/10_player.rb @@ -1,39 +1,41 @@ +# frozen_string_literal: true + class Systems class Player @co = Components::Overworld def self.run Components::PlayerControl.data.each do |id, data| - puts6 "Right: #{@co.data[:grid][@co.data[id].x+1][@co.data[id].y]}" - puts6 "Left #{@co.data[:grid][@co.data[id].x-1][@co.data[id].y]}" - puts6 "Down #{@co.data[:grid][@co.data[id].x][@co.data[id].y+1]}" - puts6 "Up #{@co.data[:grid][@co.data[id].x][@co.data[id].y-1]}" - #puts6 @co.data[:grid][@co.data[id].x + 1][@co.data[id].y][:hitbox].nil? + puts6 "Right: #{@co.data[:grid][@co.data[id].x + 1][@co.data[id].y]}" + puts6 "Left #{@co.data[:grid][@co.data[id].x - 1][@co.data[id].y]}" + puts6 "Down #{@co.data[:grid][@co.data[id].x][@co.data[id].y + 1]}" + puts6 "Up #{@co.data[:grid][@co.data[id].x][@co.data[id].y - 1]}" + # puts6 @co.data[:grid][@co.data[id].x + 1][@co.data[id].y][:hitbox].nil? - if !(Components::Sprite.id & Entity.signatures[id]).zero? - if $gtk.args.inputs.keyboard.key_down.send(data.north) &&\ - (@co.data[:grid][@co.data[id].x][@co.data[id].y - 1].nil? ||\ - @co.data[:grid][@co.data[id].x][@co.data[id].y - 1][:hitbox].nil?) + unless (Components::Sprite.id & Entity.signatures[id]).zero? + if $gtk.args.inputs.keyboard.key_down.send(data.north) && \ + (@co.data[:grid][@co.data[id].x][@co.data[id].y - 1].nil? || \ + @co.data[:grid][@co.data[id].x][@co.data[id].y - 1][:hitbox].nil?) Components::Sprite.data[id].y -= 64 @co.data[id].y -= 1 - elsif $gtk.args.inputs.keyboard.key_down.send(data.south) &&\ - (@co.data[:grid][@co.data[id].x][@co.data[id].y + 1].nil? ||\ - @co.data[:grid][@co.data[id].x][@co.data[id].y + 1][:hitbox].nil?) + elsif $gtk.args.inputs.keyboard.key_down.send(data.south) && \ + (@co.data[:grid][@co.data[id].x][@co.data[id].y + 1].nil? || \ + @co.data[:grid][@co.data[id].x][@co.data[id].y + 1][:hitbox].nil?) Components::Sprite.data[id].y += 64 @co.data[id].y += 1 - elsif $gtk.args.inputs.keyboard.key_down.send(data.east) &&\ - (@co.data[:grid][@co.data[id].x + 1][@co.data[id].y].nil? ||\ - @co.data[:grid][@co.data[id].x + 1][@co.data[id].y][:hitbox].nil?) + elsif $gtk.args.inputs.keyboard.key_down.send(data.east) && \ + (@co.data[:grid][@co.data[id].x + 1][@co.data[id].y].nil? || \ + @co.data[:grid][@co.data[id].x + 1][@co.data[id].y][:hitbox].nil?) Components::Sprite.data[id].x += 64 @co.data[id].x += 1 - elsif $gtk.args.inputs.keyboard.key_down.send(data.west) &&\ - (@co.data[:grid][@co.data[id].x - 1][@co.data[id].y].nil? || @co.data[:grid][@co.data[id].x - 1][@co.data[id].y][:hitbox].nil?) + elsif $gtk.args.inputs.keyboard.key_down.send(data.west) && \ + (@co.data[:grid][@co.data[id].x - 1][@co.data[id].y].nil? || @co.data[:grid][@co.data[id].x - 1][@co.data[id].y][:hitbox].nil?) Components::Sprite.data[id].x -= 64 @co.data[id].x -= 1 end - #Components::Sprite.data[id].y -= 64 if $gtk.args.inputs.keyboard.key_down.send(data.north) - #Components::Sprite.data[id].y += 64 if $gtk.args.inputs.keyboard.key_down.send(data.south) - #Components::Sprite.data[id].x += 64 if $gtk.args.inputs.keyboard.key_down.send(data.east) - #Components::Sprite.data[id].x -= 64 if $gtk.args.inputs.keyboard.key_down.send(data.west) + # Components::Sprite.data[id].y -= 64 if $gtk.args.inputs.keyboard.key_down.send(data.north) + # Components::Sprite.data[id].y += 64 if $gtk.args.inputs.keyboard.key_down.send(data.south) + # Components::Sprite.data[id].x += 64 if $gtk.args.inputs.keyboard.key_down.send(data.east) + # Components::Sprite.data[id].x -= 64 if $gtk.args.inputs.keyboard.key_down.send(data.west) end end end diff --git a/deprecated/systems/99_render.rb b/deprecated/systems/99_render.rb index c71c6fc..dc1092e 100644 --- a/deprecated/systems/99_render.rb +++ b/deprecated/systems/99_render.rb @@ -1,7 +1,9 @@ +# frozen_string_literal: true + class Systems class Render def self.run - Components::Renderable.data.sort_by { |v| v[1].z }.each do |key, data| + Components::Renderable.data.sort_by { |v| v[1].z }.each do |key, _data| if !(Components::Sprite.id & Entity.signatures[key]).zero? $gtk.args.outputs.sprites << Components::Sprite.data[key].set elsif !(Components::Label.id & Entity.signatures[key]).zero? @@ -11,21 +13,29 @@ class Systems layer['chunks'].each do |chunk| chunk['data'].each_slice(chunk['width']).with_index do |row, row_index| row.each_with_index do |tile, column_index| - unless tile.zero? - iter = 0 - loop do - tile = Helper.get_tile(json_name: Components::Map.data[key].json['tilesets'][iter]['source'].split('/').last.delete('\\').delete_suffix('.tsx'), tile_index: tile) - break if tile.is_a?(Hash) - raise Exception.new "#{Components::Map.data[key].json['json_name']} not valid map, exceeded tile range" if (iter += 1) >= Components::Map.data[key].json['tilesets'].count - end - unless tile.empty? - tile[:x] = Components::Map.data[key].x + (Components::Map.data[key].tilewidth * column_index) + chunk['x'] - tile[:y] = Components::Map.data[key].y + (Components::Map.data[key].tileheight * row_index) + chunk['y'] - tile[:w] = Components::Map.data[key].tilewidth - tile[:h] = Components::Map.data[key].tileheight - $gtk.args.outputs.sprites << tile + next if tile.zero? + + iter = 0 + loop do + tile = Helper.get_tile( + json_name: Components::Map.data[key].json['tilesets'][iter]['source'].split('/').last.delete('\\').delete_suffix('.tsx'), tile_index: tile + ) + break if tile.is_a?(Hash) + + if (iter += 1) >= Components::Map.data[key].json['tilesets'].count + raise StandardError, + "#{Components::Map.data[key].json["json_name"]} not valid map, exceeded tile range" end end + next if tile.empty? + + tile[:x] = + Components::Map.data[key].x + (Components::Map.data[key].tilewidth * column_index) + chunk['x'] + tile[:y] = + Components::Map.data[key].y + (Components::Map.data[key].tileheight * row_index) + chunk['y'] + tile[:w] = Components::Map.data[key].tilewidth + tile[:h] = Components::Map.data[key].tileheight + $gtk.args.outputs.sprites << tile end end end |
