From 6acf6c8bd0cd8051bdb6cb6ec75fb7d67959e47b Mon Sep 17 00:00:00 2001 From: Tom Black Date: Tue, 4 Sep 2018 00:36:52 -0700 Subject: Add ability to rotate textures Includes images, sprites, and text. --- lib/ruby2d/image.rb | 3 ++- lib/ruby2d/sprite.rb | 4 ++-- lib/ruby2d/text.rb | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) (limited to 'lib') 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' -- cgit v1.2.3