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/helpers/00_tileset.rb | |
| parent | b535a6b1bd8019dbeba17f3853b338383208c9b3 (diff) | |
| download | FelECS-a0f792d8feadf919290b8349dbc0eac143545927.tar.gz FelECS-a0f792d8feadf919290b8349dbc0eac143545927.zip | |
See Changelog
Diffstat (limited to 'deprecated/helpers/00_tileset.rb')
| -rw-r--r-- | deprecated/helpers/00_tileset.rb | 28 |
1 files changed, 15 insertions, 13 deletions
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('\\'), |
