summaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorTom Black <[email protected]>2018-09-04 00:36:52 -0700
committerTom Black <[email protected]>2018-09-12 15:35:16 -0700
commit6acf6c8bd0cd8051bdb6cb6ec75fb7d67959e47b (patch)
tree28c87e64f1b17e64194c335145fc4ab0748fb5c9 /lib
parent8e8755972a55b75b7f38f2da503c40e12dd4a344 (diff)
downloadruby2d-6acf6c8bd0cd8051bdb6cb6ec75fb7d67959e47b.tar.gz
ruby2d-6acf6c8bd0cd8051bdb6cb6ec75fb7d67959e47b.zip
Add ability to rotate textures
Includes images, sprites, and text.
Diffstat (limited to 'lib')
-rw-r--r--lib/ruby2d/image.rb3
-rw-r--r--lib/ruby2d/sprite.rb4
-rw-r--r--lib/ruby2d/text.rb4
3 files changed, 6 insertions, 5 deletions
diff --git a/lib/ruby2d/image.rb b/lib/ruby2d/image.rb
index 3ac705d..5490d53 100644
--- a/lib/ruby2d/image.rb
+++ b/lib/ruby2d/image.rb
@@ -4,8 +4,8 @@ module Ruby2D
class Image
include Renderable
- attr_accessor :x, :y, :width, :height, :data
attr_reader :path, :color
+ attr_accessor :x, :y, :width, :height, :rotate, :data
def initialize(opts = {})
@path = opts[:path]
@@ -21,6 +21,7 @@ module Ruby2D
@z = opts[:z] || 0
@width = opts[:width] || nil
@height = opts[:height] || nil
+ @rotate = 0
self.color = opts[:color] || 'white'
diff --git a/lib/ruby2d/sprite.rb b/lib/ruby2d/sprite.rb
index f2d7075..68b6ace 100644
--- a/lib/ruby2d/sprite.rb
+++ b/lib/ruby2d/sprite.rb
@@ -4,8 +4,8 @@ module Ruby2D
class Sprite
include Renderable
- attr_accessor :x, :y, :width, :height, :loop,
- :clip_x, :clip_y, :clip_width, :clip_height, :data
+ attr_reader :x, :y, :width, :height
+ attr_accessor :rotate, :loop, :clip_x, :clip_y, :clip_width, :clip_height, :data
def initialize(path, opts = {})
diff --git a/lib/ruby2d/text.rb b/lib/ruby2d/text.rb
index 87fe4d3..9a66b6d 100644
--- a/lib/ruby2d/text.rb
+++ b/lib/ruby2d/text.rb
@@ -4,8 +4,8 @@ module Ruby2D
class Text
include Renderable
- attr_accessor :x, :y, :data
attr_reader :text, :size, :width, :height, :font, :color
+ attr_accessor :x, :y, :rotate, :data
def initialize(opts = {})
@x = opts[:x] || 0
@@ -13,7 +13,7 @@ module Ruby2D
@z = opts[:z] || 0
@text = (opts[:text] || "Hello World!").to_s
@size = opts[:size] || 20
-
+ @rotate = 0
@font = opts[:font]
unless RUBY_ENGINE == 'opal'