summaryrefslogtreecommitdiffhomepage
path: root/app/ECS/components
diff options
context:
space:
mode:
authorrealtradam <[email protected]>2021-05-19 02:23:17 -0400
committerrealtradam <[email protected]>2021-05-19 02:23:17 -0400
commit490b20123c75cf8eb5de7039993cb704e3d7a0c8 (patch)
tree302caf2be626efd0ac14baed36b8201bc49d0795 /app/ECS/components
parent120b693ffd02bc5c7f41ff2b9657facc7117daae (diff)
downloadtypemon-code-490b20123c75cf8eb5de7039993cb704e3d7a0c8.tar.gz
typemon-code-490b20123c75cf8eb5de7039993cb704e3d7a0c8.zip
working json to sprite conversion
Diffstat (limited to 'app/ECS/components')
-rw-r--r--app/ECS/components/00_renderable.rb8
-rw-r--r--app/ECS/components/02_label.rb22
-rw-r--r--app/ECS/components/03_player_control.rb23
-rw-r--r--app/ECS/components/04_map.rb21
-rw-r--r--app/ECS/components/05_map_object.rb16
-rw-r--r--app/ECS/components/06_grid_singleton.rb16
6 files changed, 83 insertions, 23 deletions
diff --git a/app/ECS/components/00_renderable.rb b/app/ECS/components/00_renderable.rb
index 18017cc..270e5f9 100644
--- a/app/ECS/components/00_renderable.rb
+++ b/app/ECS/components/00_renderable.rb
@@ -3,8 +3,14 @@ class Components
class Renderable < BaseComponent
attr_accessor :z
- def initialize(z: 0)
+ def initialize
@z = z
end
+
+ def set(**opts)
+ opts.each do |key, value|
+ self.send "#{key}=", value
+ end
+ end
end
end
diff --git a/app/ECS/components/02_label.rb b/app/ECS/components/02_label.rb
index 2483d57..aed00ed 100644
--- a/app/ECS/components/02_label.rb
+++ b/app/ECS/components/02_label.rb
@@ -7,17 +7,17 @@ class Components
def set(x: @x, y: @y, text: @text, size_enum: @size_enum, alignment_enum: @alignment_enum,
a: @a, r: @r, g: @g, b: @b, font: @font, vertical_alignment_enum: @vertical_alignment_enum)
- [@x = x,
- @y = y,
- @text = text,
- @size_enum = size_enum,
- @alignment_enum = alignment_enum,
- @r = r,
- @g = g,
- @b = b,
- @a = a,
- @font = font,
- @vertical_alignment_enum = vertical_alignment_enum]
+ {x: @x = x,
+ y: @y = y,
+ text: @text = text,
+ size_enum: @size_enum = size_enum,
+ alignment_enum: @alignment_enum = alignment_enum,
+ r: @r = r,
+ g: @g = g,
+ b: @b = b,
+ a: @a = a,
+ font: @font = font,
+ vertical_alignment_enum: @vertical_alignment_enum = vertical_alignment_enum }
end
def primative_marker
diff --git a/app/ECS/components/03_player_control.rb b/app/ECS/components/03_player_control.rb
index 22bc458..58d0102 100644
--- a/app/ECS/components/03_player_control.rb
+++ b/app/ECS/components/03_player_control.rb
@@ -1,20 +1,21 @@
class Components
# Gives control(keyboard or otherwise) over an object
class PlayerControl < BaseComponent
- attr_accessor :north, :south, :east, :west
+ attr_accessor :north, :south, :east, :west, :interact, :menu
- def initialize(north: 'w', south: 's', east: 'd', west: 'a')
- @north = north
- @south = south
- @east = east
- @west = west
+ def initialize
+ @north = 'w'
+ @south = 's'
+ @east = 'd'
+ @west = 'a'
+ @interact = 'space'
+ @menu = 'enter'
end
- def set(north: 'w', south: 's', east: 'd', west: 'a')
- @north = north
- @south = south
- @east = east
- @west = west
+ def set(**opts)
+ opts.each do |key, value|
+ send "#{key}=", value
+ end
end
end
end
diff --git a/app/ECS/components/04_map.rb b/app/ECS/components/04_map.rb
new file mode 100644
index 0000000..804fc02
--- /dev/null
+++ b/app/ECS/components/04_map.rb
@@ -0,0 +1,21 @@
+class Components
+ # dragonruby label wrapper
+ class Map < BaseComponent
+
+ attr_accessor :json_name, :json, :x, :y, :tilewidth, :tileheight, :a, :r, :g, :b
+
+ def set(json_name: @json_name, x: @x, y: @y, tilewidth: @tilewidth,
+ tileheight: @tileheight, a: @a, r: @r, g: @g, b: @b)
+ { json_name: @json_name = json_name,
+ json: @json = Helper.get_json_tiles(json_name),
+ x: @x = x,
+ y: @y = y,
+ tilewidth: @tilewidth = tilewidth,
+ tileheight: @tileheight = tileheight,
+ r: @r = r,
+ g: @g = g,
+ b: @b = b,
+ a: @a = a }
+ end
+ end
+end
diff --git a/app/ECS/components/05_map_object.rb b/app/ECS/components/05_map_object.rb
new file mode 100644
index 0000000..270e5f9
--- /dev/null
+++ b/app/ECS/components/05_map_object.rb
@@ -0,0 +1,16 @@
+class Components
+ # If an entity can be rendered on screen
+ class Renderable < BaseComponent
+ attr_accessor :z
+
+ def initialize
+ @z = z
+ end
+
+ def set(**opts)
+ opts.each do |key, value|
+ self.send "#{key}=", value
+ end
+ end
+ end
+end
diff --git a/app/ECS/components/06_grid_singleton.rb b/app/ECS/components/06_grid_singleton.rb
new file mode 100644
index 0000000..392d770
--- /dev/null
+++ b/app/ECS/components/06_grid_singleton.rb
@@ -0,0 +1,16 @@
+class Components
+ # If an entity can be rendered on screen
+ class GridSingleton < BaseComponent
+ attr_accessor :z
+
+ def initialize
+ @z = 0
+ end
+
+ def set(**opts)
+ opts.each do |key, value|
+ self.send "#{key}=", value
+ end
+ end
+ end
+end