From 24524ad0b1c7a2aeea0bad28092e946cef8026fa Mon Sep 17 00:00:00 2001 From: realtradam Date: Sat, 15 May 2021 03:47:15 -0400 Subject: working ECS --- app/ECS/systems/00_movement.rb | 25 ------------------------- app/ECS/systems/00_player.rb | 17 +++++++++++++++++ app/ECS/systems/01_flying.rb | 19 ------------------- app/ECS/systems/99_render.rb | 16 ++++++++++++++++ 4 files changed, 33 insertions(+), 44 deletions(-) delete mode 100644 app/ECS/systems/00_movement.rb create mode 100644 app/ECS/systems/00_player.rb delete mode 100644 app/ECS/systems/01_flying.rb create mode 100644 app/ECS/systems/99_render.rb (limited to 'app/ECS/systems') diff --git a/app/ECS/systems/00_movement.rb b/app/ECS/systems/00_movement.rb deleted file mode 100644 index 9d8029a..0000000 --- a/app/ECS/systems/00_movement.rb +++ /dev/null @@ -1,25 +0,0 @@ -class ECS - class Systems - class Movement - def self.run - ECS::Components::TestComponent.data.each do |key, data| - unless (ECS::Components::Based.id - ECS::Entity.signatures[key]).zero? - unless (ECS::Components::Based.id & ECS::Entity.signatures[key]).zero? - #puts "Based Data: " - #puts "eks: #{ECS::Components::Based.data[key].x += 2}" - #puts "why: #{ECS::Components::Based.data[key].y += 2}" - ECS::Components::Based.data[key].x += 2 - ECS::Components::Based.data[key].y += 2 - end - end - #puts "Movement:" - #puts "x: #{data.x += 1}" - #puts "y: #{data.y += 1}" - data.x += 1 - data.y += 1 - #puts "---" - end - end - end - end -end diff --git a/app/ECS/systems/00_player.rb b/app/ECS/systems/00_player.rb new file mode 100644 index 0000000..a78137a --- /dev/null +++ b/app/ECS/systems/00_player.rb @@ -0,0 +1,17 @@ +class ECS + class Systems + class Player + def self.run + ECS::Components::PlayerControl.data.each do |id, data| + if !(ECS::Components::Renderable.id & ECS::Entity.signatures[id]).zero? + ECS::Components::Sprite.data[id].y += 10 if $gtk.args.inputs.keyboard.key_held.send(data.north) + ECS::Components::Sprite.data[id].y -= 10 if $gtk.args.inputs.keyboard.key_held.send(data.south) + ECS::Components::Sprite.data[id].x += 10 if $gtk.args.inputs.keyboard.key_held.send(data.east) + ECS::Components::Sprite.data[id].x -= 10 if $gtk.args.inputs.keyboard.key_held.send(data.west) + #$gtk.args.outputs.labels << ECS::Components::Label.data[id].vars + end + end + end + end + end +end diff --git a/app/ECS/systems/01_flying.rb b/app/ECS/systems/01_flying.rb deleted file mode 100644 index 799398b..0000000 --- a/app/ECS/systems/01_flying.rb +++ /dev/null @@ -1,19 +0,0 @@ -class ECS - class Systems - class Based - def self.run - ECS::Components::Based.data.each do |key, data| - if ECS::Components::Based.id == ECS::Entity.signatures[key] - #puts "Entity ID: #{key}" - #puts "ONLY Based Data: " - #puts "eks: #{ECS::Components::Based.data[key].x += 3}" - #puts "why: #{ECS::Components::Based.data[key].y += 3}" - #puts "---" - data.x += 3 - data.y += 3 - end - end - end - end - end -end diff --git a/app/ECS/systems/99_render.rb b/app/ECS/systems/99_render.rb new file mode 100644 index 0000000..0751bc2 --- /dev/null +++ b/app/ECS/systems/99_render.rb @@ -0,0 +1,16 @@ +class ECS + class Systems + class Render + def self.run + ECS::Components::Renderable.data.sort_by { |v| v[1].z }.each do |key, data| + if !(ECS::Components::Sprite.id & ECS::Entity.signatures[key]).zero? + #ECS::Components::Based.data[key].x += 2 + $gtk.args.outputs.sprites << ECS::Components::Sprite.data[key].set + elsif !(ECS::Components::Label.id & ECS::Entity.signatures[key]).zero? + $gtk.args.outputs.labels << ECS::Components::Label.data[key].set + end + end + end + end + end +end -- cgit v1.2.3