summaryrefslogtreecommitdiffhomepage
path: root/app/lib/components
diff options
context:
space:
mode:
authorrealtradam <[email protected]>2021-05-20 05:04:21 -0400
committerrealtradam <[email protected]>2021-05-20 05:04:21 -0400
commitf97a9ca95e464e728bba9337b579bc380c33bc7d (patch)
treedd45a6e615e6e873cee15cb41daaca24b3357ea6 /app/lib/components
parentfee80f42f0889f2d484e25f4366f14b68c65ba70 (diff)
downloadtypemon-code-f97a9ca95e464e728bba9337b579bc380c33bc7d.tar.gz
typemon-code-f97a9ca95e464e728bba9337b579bc380c33bc7d.zip
implemented hitboxes
Diffstat (limited to 'app/lib/components')
-rw-r--r--app/lib/components/00_renderable.rb16
-rw-r--r--app/lib/components/01_sprite.rb44
-rw-r--r--app/lib/components/02_label.rb27
-rw-r--r--app/lib/components/03_player_control.rb21
-rw-r--r--app/lib/components/04_map.rb21
-rw-r--r--app/lib/components/05_interactable.rb16
-rw-r--r--app/lib/components/06_collidable.rb22
-rw-r--r--app/lib/components/07_battle.rb4
-rw-r--r--app/lib/components/07_indoor.rb4
-rw-r--r--app/lib/components/07_overworld.rb16
-rw-r--r--app/lib/components/debug_singleton.rb13
11 files changed, 204 insertions, 0 deletions
diff --git a/app/lib/components/00_renderable.rb b/app/lib/components/00_renderable.rb
new file mode 100644
index 0000000..3971c8c
--- /dev/null
+++ b/app/lib/components/00_renderable.rb
@@ -0,0 +1,16 @@
+class Components
+ # If an entity can be rendered on screen
+ class Renderable < Helper::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
diff --git a/app/lib/components/01_sprite.rb b/app/lib/components/01_sprite.rb
new file mode 100644
index 0000000..8d30cdf
--- /dev/null
+++ b/app/lib/components/01_sprite.rb
@@ -0,0 +1,44 @@
+class Components
+ # If an entity can be rendered on screen
+ class Sprite < Helper::BaseComponent
+
+ attr_accessor :x, :y, :w, :h, :path, :angle, :a, :r, :g, :b,
+ :source_x, :source_y, :source_w, :source_h,
+ :tile_x, :tile_y, :tile_w, :tile_h,
+ :flip_horizontally, :flip_vertically,
+ :angle_anchor_x, :angle_anchor_y
+
+ def set(x: @x, y: @y, w: @w, h: @h, path: @path, angle: @angle, a: @a, r: @r, g: @g, b: @b,
+ source_x: @source_x, source_y: @source_y, source_w: @source_w, source_h: @source_h,
+ tile_x: @tile_x, tile_y: @tile_y, tile_w: @tile_w, tile_h: @tile_h,
+ flip_horizontally: @flip_horizontally, flip_vertically: @flip_vertically,
+ angle_anchor_x: @angle_anchor_x, angle_anchor_y: @angle_anchor_y)
+ {x: @x = x,
+ y: @y = y,
+ w: @w = w,
+ h: @h = h,
+ path: @path = path,
+ angle: @angle = angle,
+ a: @a = a,
+ r: @r = r,
+ g: @g = g,
+ b: @b = b,
+ source_x: @source_x = source_x,
+ source_y: @source_y = source_y,
+ source_w: @source_w = source_w,
+ source_h: @source_h = source_h,
+ tile_x: @tile_x = tile_x,
+ tile_y: @tile_y = tile_y,
+ tile_w: @tile_w = tile_w,
+ tile_h: @tile_h = tile_h,
+ flip_horizontally: @flip_horizontally = flip_horizontally,
+ flip_vertically: @flip_vertically = flip_vertically,
+ angle_anchor_x: @angle_anchor_x = angle_anchor_x,
+ angle_anchor_y: @angle_anchor_y = angle_anchor_y}
+ end
+
+ def primative_marker
+ :sprite
+ end
+ end
+end
diff --git a/app/lib/components/02_label.rb b/app/lib/components/02_label.rb
new file mode 100644
index 0000000..13544b7
--- /dev/null
+++ b/app/lib/components/02_label.rb
@@ -0,0 +1,27 @@
+class Components
+ # A dragonruby label wrapper
+ class Label < Helper::BaseComponent
+
+ attr_accessor :x, :y, :text, :size_enum, :alignment_enum,
+ :a, :r, :g, :b, :font, :vertical_alignment_enum
+
+ 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 = 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
+ :label
+ end
+ end
+end
diff --git a/app/lib/components/03_player_control.rb b/app/lib/components/03_player_control.rb
new file mode 100644
index 0000000..d5d8f7a
--- /dev/null
+++ b/app/lib/components/03_player_control.rb
@@ -0,0 +1,21 @@
+class Components
+ # Gives control(keyboard or otherwise) over an object
+ class PlayerControl < Helper::BaseComponent
+ attr_accessor :north, :south, :east, :west, :interact, :menu
+
+ def initialize
+ @north = 'up'
+ @south = 'down'
+ @east = 'right'
+ @west = 'left'
+ @interact = 'space'
+ @menu = 'enter'
+ end
+
+ def set(**opts)
+ opts.each do |key, value|
+ send "#{key}=", value
+ end
+ end
+ end
+end
diff --git a/app/lib/components/04_map.rb b/app/lib/components/04_map.rb
new file mode 100644
index 0000000..7700e9f
--- /dev/null
+++ b/app/lib/components/04_map.rb
@@ -0,0 +1,21 @@
+class Components
+ # dragonruby label wrapper
+ class Map < Helper::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/lib/components/05_interactable.rb b/app/lib/components/05_interactable.rb
new file mode 100644
index 0000000..636a216
--- /dev/null
+++ b/app/lib/components/05_interactable.rb
@@ -0,0 +1,16 @@
+class Components
+ # If an entity can be rendered on screen
+ class Interactable < Helper::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/lib/components/06_collidable.rb b/app/lib/components/06_collidable.rb
new file mode 100644
index 0000000..76ce51e
--- /dev/null
+++ b/app/lib/components/06_collidable.rb
@@ -0,0 +1,22 @@
+class Components
+ # If an entity can be rendered on screen
+ class Collidable < Helper::BaseComponent
+ class <<self
+ def add(entity_id)
+ super(entity_id)
+ #add to grid?
+ end
+ end
+ attr_accessor :grid
+
+ def initialize
+ @grid = [[]]
+ end
+
+ def set(**opts)
+ opts.each do |key, value|
+ self.send "#{key}=", value
+ end
+ end
+ end
+end
diff --git a/app/lib/components/07_battle.rb b/app/lib/components/07_battle.rb
new file mode 100644
index 0000000..b4ef622
--- /dev/null
+++ b/app/lib/components/07_battle.rb
@@ -0,0 +1,4 @@
+class Components
+ class Battle < Helper::Level
+ end
+end
diff --git a/app/lib/components/07_indoor.rb b/app/lib/components/07_indoor.rb
new file mode 100644
index 0000000..e409da8
--- /dev/null
+++ b/app/lib/components/07_indoor.rb
@@ -0,0 +1,4 @@
+class Components
+ class Indoor < Helper::Level
+ end
+end
diff --git a/app/lib/components/07_overworld.rb b/app/lib/components/07_overworld.rb
new file mode 100644
index 0000000..55ab38a
--- /dev/null
+++ b/app/lib/components/07_overworld.rb
@@ -0,0 +1,16 @@
+class Components
+ class Overworld < Helper::Level
+ attr_accessor :x, :y
+
+ def initialize
+ @x = 0
+ @y = 0
+ end
+
+ def set(**opts)
+ opts.each do |key, value|
+ self.send "#{key}=", value
+ end
+ end
+ end
+end
diff --git a/app/lib/components/debug_singleton.rb b/app/lib/components/debug_singleton.rb
new file mode 100644
index 0000000..f298172
--- /dev/null
+++ b/app/lib/components/debug_singleton.rb
@@ -0,0 +1,13 @@
+class Components
+ # If an entity can be rendered on screen
+ class DebugSingleton
+ class <<self
+ @data = false
+ attr_accessor :data
+
+ def id
+ 0
+ end
+ end
+ end
+end