summaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorTom Black <[email protected]>2017-02-17 00:26:00 -0500
committerTom Black <[email protected]>2017-02-17 00:26:00 -0500
commit88dec9d773e7960a525df8f0b7b9d09a180ac8c7 (patch)
tree969f182cdf479d124b807232f0390d85b6fe5905 /lib
parentfd919d5b52b26a88c3aee3d91756c1bcc6e9d1e3 (diff)
downloadruby2d-88dec9d773e7960a525df8f0b7b9d09a180ac8c7.tar.gz
ruby2d-88dec9d773e7960a525df8f0b7b9d09a180ac8c7.zip
Add an `add` method for drawable objects
Diffstat (limited to 'lib')
-rw-r--r--lib/ruby2d/image.rb11
-rw-r--r--lib/ruby2d/quad.rb11
-rw-r--r--lib/ruby2d/rectangle.rb5
-rw-r--r--lib/ruby2d/sprite.rb7
-rw-r--r--lib/ruby2d/square.rb5
-rw-r--r--lib/ruby2d/text.rb11
-rw-r--r--lib/ruby2d/triangle.rb11
7 files changed, 37 insertions, 24 deletions
diff --git a/lib/ruby2d/image.rb b/lib/ruby2d/image.rb
index 0546db5..cf5e00e 100644
--- a/lib/ruby2d/image.rb
+++ b/lib/ruby2d/image.rb
@@ -15,16 +15,19 @@ module Ruby2D
@type_id = 3
@x, @y, @path = x, y, path
@color = Color.new([1, 1, 1, 1])
-
- if Module.const_defined? :DSL
- Application.add(self)
- end
+ add
end
def color=(c)
@color = Color.new(c)
end
+ def add
+ if Module.const_defined? :DSL
+ Application.add(self)
+ end
+ end
+
def remove
if Module.const_defined? :DSL
Application.remove(self)
diff --git a/lib/ruby2d/quad.rb b/lib/ruby2d/quad.rb
index f17aa5c..13e2b6e 100644
--- a/lib/ruby2d/quad.rb
+++ b/lib/ruby2d/quad.rb
@@ -19,10 +19,7 @@ module Ruby2D
@x1, @y1, @x2, @y2, @x3, @y3, @x4, @y4 = x1, y1, x2, y2, x3, y3, x4, y4
@color = c
update_color(c)
-
- if Module.const_defined? :DSL
- Application.add(self)
- end
+ add
end
def color=(c)
@@ -30,6 +27,12 @@ module Ruby2D
update_color(c)
end
+ def add
+ if Module.const_defined? :DSL
+ Application.add(self)
+ end
+ end
+
def remove
if Module.const_defined? :DSL
Application.remove(self)
diff --git a/lib/ruby2d/rectangle.rb b/lib/ruby2d/rectangle.rb
index d6ec46c..25f73b1 100644
--- a/lib/ruby2d/rectangle.rb
+++ b/lib/ruby2d/rectangle.rb
@@ -10,10 +10,7 @@ module Ruby2D
@x, @y, @width, @height, @color = x, y, w, h, c
update_coords(x, y, w, h)
update_color(c)
-
- if Module.const_defined? :DSL
- Application.add(self)
- end
+ add
end
def x=(x)
diff --git a/lib/ruby2d/sprite.rb b/lib/ruby2d/sprite.rb
index c04614a..d69d409 100644
--- a/lib/ruby2d/sprite.rb
+++ b/lib/ruby2d/sprite.rb
@@ -48,6 +48,13 @@ module Ruby2D
@current_animation = nil
end
+ # TODO: Sprite already has an `add` method, have to reconsile
+ # def add
+ # if Module.const_defined? :DSL
+ # Application.add(self)
+ # end
+ # end
+
def remove
if Module.const_defined? :DSL
Application.remove(self)
diff --git a/lib/ruby2d/square.rb b/lib/ruby2d/square.rb
index a4b8151..cc9ba21 100644
--- a/lib/ruby2d/square.rb
+++ b/lib/ruby2d/square.rb
@@ -11,10 +11,7 @@ module Ruby2D
@width = @height = @size = s
update_coords(x, y, s, s)
update_color(c)
-
- if Module.const_defined? :DSL
- Application.add(self)
- end
+ add
end
def size=(s)
diff --git a/lib/ruby2d/text.rb b/lib/ruby2d/text.rb
index 68e8ba3..06128cf 100644
--- a/lib/ruby2d/text.rb
+++ b/lib/ruby2d/text.rb
@@ -18,10 +18,7 @@ module Ruby2D
@x, @y, @size = x, y, size
@text = text
@color = Color.new(c)
-
- if Module.const_defined? :DSL
- Application.add(self)
- end
+ add
end
def color=(c)
@@ -31,6 +28,12 @@ module Ruby2D
def text=(t)
@text = t
end
+
+ def add
+ if Module.const_defined? :DSL
+ Application.add(self)
+ end
+ end
def remove
if Module.const_defined? :DSL
diff --git a/lib/ruby2d/triangle.rb b/lib/ruby2d/triangle.rb
index ac7d67a..91e9fb2 100644
--- a/lib/ruby2d/triangle.rb
+++ b/lib/ruby2d/triangle.rb
@@ -15,10 +15,7 @@ module Ruby2D
@x3, @y3 = x3, y3
@color = c
update_color(c)
-
- if Module.const_defined? :DSL
- Application.add(self)
- end
+ add
end
def color=(c)
@@ -26,6 +23,12 @@ module Ruby2D
@color = c
end
+ def add
+ if Module.const_defined? :DSL
+ Application.add(self)
+ end
+ end
+
def remove
if Module.const_defined? :DSL
Application.remove(self)