summaryrefslogtreecommitdiffhomepage
path: root/app
diff options
context:
space:
mode:
authorrealtradam <[email protected]>2021-05-14 20:05:49 -0400
committerrealtradam <[email protected]>2021-05-14 20:05:49 -0400
commit1bf39aaa0d736b1976a32030fd1c18e0eedf1781 (patch)
tree70bc2e70bda09eba2356ed3a67cdbe9efa2b2dd6 /app
parent6a2996ceae968029be26ed7ebae8785dcfe877d2 (diff)
downloadtypemon-code-1bf39aaa0d736b1976a32030fd1c18e0eedf1781.tar.gz
typemon-code-1bf39aaa0d736b1976a32030fd1c18e0eedf1781.zip
incorperating ECS into dragonruby
Diffstat (limited to 'app')
-rw-r--r--app/ECS/component_manager.rb6
-rw-r--r--app/ECS/system_manager.rb3
-rw-r--r--app/ECS/systems/00_movement.rb19
-rw-r--r--app/ECS/systems/01_flying.rb12
-rw-r--r--app/main.rb14
-rw-r--r--app/old/repl.rb (renamed from app/repl.rb)0
-rw-r--r--app/old/sprites.rb (renamed from app/sprites.rb)0
-rw-r--r--app/tick.rb27
8 files changed, 55 insertions, 26 deletions
diff --git a/app/ECS/component_manager.rb b/app/ECS/component_manager.rb
index e64bc21..b07cf79 100644
--- a/app/ECS/component_manager.rb
+++ b/app/ECS/component_manager.rb
@@ -1,5 +1,7 @@
-require_relative './base_component'
-Dir[File.join(__dir__, 'components', '*.rb')].sort.each { |file| require file }
+require 'app/ECS/base_component.rb'
+
+require 'app/ECS/components/00_test_component.rb'
+require 'app/ECS/components/01_based.rb'
class ECS
class Components
diff --git a/app/ECS/system_manager.rb b/app/ECS/system_manager.rb
index 53aa46b..dda8ed7 100644
--- a/app/ECS/system_manager.rb
+++ b/app/ECS/system_manager.rb
@@ -1,4 +1,5 @@
-Dir[File.join(__dir__, 'systems', '*.rb')].sort.each { |file| require file }
+require 'app/ECS/systems/00_movement.rb'
+require 'app/ECS/systems/01_flying.rb'
class ECS
class Systems
diff --git a/app/ECS/systems/00_movement.rb b/app/ECS/systems/00_movement.rb
index ced0343..9d8029a 100644
--- a/app/ECS/systems/00_movement.rb
+++ b/app/ECS/systems/00_movement.rb
@@ -3,18 +3,21 @@ class ECS
class Movement
def self.run
ECS::Components::TestComponent.data.each do |key, data|
- puts "Entity ID: #{key}"
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}"
+ #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}"
- puts "---"
+ #puts "Movement:"
+ #puts "x: #{data.x += 1}"
+ #puts "y: #{data.y += 1}"
+ data.x += 1
+ data.y += 1
+ #puts "---"
end
end
end
diff --git a/app/ECS/systems/01_flying.rb b/app/ECS/systems/01_flying.rb
index 493e999..799398b 100644
--- a/app/ECS/systems/01_flying.rb
+++ b/app/ECS/systems/01_flying.rb
@@ -4,11 +4,13 @@ class ECS
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 "---"
+ #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
diff --git a/app/main.rb b/app/main.rb
index d797a3e..3255af0 100644
--- a/app/main.rb
+++ b/app/main.rb
@@ -1,10 +1,4 @@
-require 'app/sprites.rb'
-def tick args
- args.outputs.labels << [640, 500, 'Hello World!', 5, 1]
- args.outputs.labels << [640, 460, 'Go to docs/docs.html and read it!', 5, 1]
- args.outputs.labels << [640, 420, 'Join the Discord! http://discord.dragonruby.org', 5, 1]
- args.outputs.sprites << [576, 280, 128, 101, 'dragonruby.png']
- @render = Sprite.objects[1] if args.inputs.keyboard.key_held.a
- @render = Sprite.objects[0] if args.inputs.keyboard.key_held.s
- args.outputs.sprites << @render
-end
+require 'app/ECS/entity_manager.rb'
+require 'app/ECS/component_manager.rb'
+require 'app/ECS/system_manager.rb'
+require 'app/tick.rb'
diff --git a/app/repl.rb b/app/old/repl.rb
index 56390c1..56390c1 100644
--- a/app/repl.rb
+++ b/app/old/repl.rb
diff --git a/app/sprites.rb b/app/old/sprites.rb
index 0016436..0016436 100644
--- a/app/sprites.rb
+++ b/app/old/sprites.rb
diff --git a/app/tick.rb b/app/tick.rb
new file mode 100644
index 0000000..072bf48
--- /dev/null
+++ b/app/tick.rb
@@ -0,0 +1,27 @@
+
+=begin
+files = ""
+files = `ls -B1 #{__dir__}`
+
+File.write("#{__dir__}/_", (files.split - ["_"]).map{|file| "require 'lib/#{libname}/#{file}'"}.join("\n"))
+=end
+move = '0001'.to_i(2)
+base = '0010'.to_i(2)
+both = '0011'.to_i(2)
+@thing0 = ECS::Entity.new(move)
+puts @thing0
+ECS::Entity.new(base)
+ECS::Entity.new(both)
+
+def tick args
+ ECS::Systems.constants.each do |constant|
+ ECS::Systems::const_get(constant).run
+ end
+ args.outputs.labels << [640, 500, ECS::Components::TestComponent.data[@thing0.id].x, 5, 1]
+ args.outputs.labels << [640, 460, @thing0, 5, 1]
+ args.outputs.labels << [640, 420, 'Join the Discord! http://discord.dragonruby.org', 5, 1]
+ args.outputs.sprites << [576, 280, 128, 101, 'dragonruby.png']
+ @render = Sprite.objects[1] if args.inputs.keyboard.key_held.a
+ @render = Sprite.objects[0] if args.inputs.keyboard.key_held.s
+ args.outputs.sprites << @render
+end