diff options
| author | _Tradam <[email protected]> | 2021-05-26 02:12:54 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-05-26 02:12:54 -0400 |
| commit | 41f574c04c70e6327cb1861fac01664bd3f3f7ba (patch) | |
| tree | 34a184ff4fd182a8823f416fd87b4d546e1e250f /app/lib/systems | |
| parent | f97a9ca95e464e728bba9337b579bc380c33bc7d (diff) | |
| parent | a5bbcbf5d78005746fb64c51a779f830d7667a57 (diff) | |
| download | typemon-code-41f574c04c70e6327cb1861fac01664bd3f3f7ba.tar.gz typemon-code-41f574c04c70e6327cb1861fac01664bd3f3f7ba.zip | |
split off FelFlame
Diffstat (limited to 'app/lib/systems')
| -rw-r--r-- | app/lib/systems/00_update_levels.rb | 34 | ||||
| -rw-r--r-- | app/lib/systems/10_player.rb | 41 | ||||
| -rw-r--r-- | app/lib/systems/99_render.rb | 37 |
3 files changed, 0 insertions, 112 deletions
diff --git a/app/lib/systems/00_update_levels.rb b/app/lib/systems/00_update_levels.rb deleted file mode 100644 index 6f3a056..0000000 --- a/app/lib/systems/00_update_levels.rb +++ /dev/null @@ -1,34 +0,0 @@ -class Systems - class UpdateLevels - @co = Components::Overworld - def self.run - @co.data[:add].each do |id| - @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 }) - 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' - Components::Map.data[id].json['layers'].each do |layer| - 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| - if tile.to_i == Components::Map.data[id].json['tilesets'].last['firstgid'].to_i - @co.data[:grid][column_index][row_index] = {} if @co.data[:grid][column_index][row_index].nil? - @co.data[:grid][column_index][row_index].merge!({ hitbox: true }) - end - end - end - end - end - end - end - puts @co.data[:grid] - end - Components::Overworld.data[:remove].each do |id| - Components::Overworld.data[:remove].delete(id) - end - end - end -end diff --git a/app/lib/systems/10_player.rb b/app/lib/systems/10_player.rb deleted file mode 100644 index 307731a..0000000 --- a/app/lib/systems/10_player.rb +++ /dev/null @@ -1,41 +0,0 @@ -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? - - 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?) - 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?) - 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?) - 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?) - 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) - end - end - end - end -end diff --git a/app/lib/systems/99_render.rb b/app/lib/systems/99_render.rb deleted file mode 100644 index c71c6fc..0000000 --- a/app/lib/systems/99_render.rb +++ /dev/null @@ -1,37 +0,0 @@ -class Systems - class Render - def self.run - 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? - $gtk.args.outputs.labels << Components::Label.data[key].set - elsif !(Components::Map.id & Entity.signatures[key]).zero? - Components::Map.data[key].json['layers'].each do |layer| - 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 - end - end - end - end - end - end - end - end - end - end -end |
