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/systems | |
| parent | b535a6b1bd8019dbeba17f3853b338383208c9b3 (diff) | |
| download | FelECS-4.0.0.tar.gz FelECS-4.0.0.zip | |
See Changelog
Diffstat (limited to 'deprecated/systems')
| -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 |
3 files changed, 50 insertions, 36 deletions
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 |
