summaryrefslogtreecommitdiffhomepage
path: root/app/ECS/systems
diff options
context:
space:
mode:
authorrealtradam <[email protected]>2021-05-15 03:47:15 -0400
committerrealtradam <[email protected]>2021-05-15 03:47:15 -0400
commit24524ad0b1c7a2aeea0bad28092e946cef8026fa (patch)
tree93282c6e5250a23d1829f52c40c5bbde05c69046 /app/ECS/systems
parent1bf39aaa0d736b1976a32030fd1c18e0eedf1781 (diff)
downloadtypemon-code-24524ad0b1c7a2aeea0bad28092e946cef8026fa.tar.gz
typemon-code-24524ad0b1c7a2aeea0bad28092e946cef8026fa.zip
working ECS
Diffstat (limited to 'app/ECS/systems')
-rw-r--r--app/ECS/systems/00_movement.rb25
-rw-r--r--app/ECS/systems/00_player.rb17
-rw-r--r--app/ECS/systems/01_flying.rb19
-rw-r--r--app/ECS/systems/99_render.rb16
4 files changed, 33 insertions, 44 deletions
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