Class: Smalruby3::DXRubyToSmalruby
- Inherits:
-
Object
- Object
- Smalruby3::DXRubyToSmalruby
- Defined in:
- lib/smalruby3/dxruby_to_smalruby.rb
Constant Summary collapse
- SCREEN_BOTTOM =
-180- SCREEN_LEFT =
-240
Instance Attribute Summary collapse
-
#scale ⇒ Object
Returns the value of attribute scale.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ DXRubyToSmalruby
constructor
A new instance of DXRubyToSmalruby.
- #position(pos_x, pos_y) ⇒ Object
- #x(pos_x) ⇒ Object
- #y(pos_y) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ DXRubyToSmalruby
Returns a new instance of DXRubyToSmalruby.
10 11 12 13 14 15 16 17 18 |
# File 'lib/smalruby3/dxruby_to_smalruby.rb', line 10 def initialize( = {}) defaults = { scale: 1, } opts = Util.(, defaults) opts.each do |k, v| send("#{k}=", v) end end |
Instance Attribute Details
#scale ⇒ Object
Returns the value of attribute scale.
8 9 10 |
# File 'lib/smalruby3/dxruby_to_smalruby.rb', line 8 def scale @scale end |
Instance Method Details
#position(pos_x, pos_y) ⇒ Object
32 33 34 |
# File 'lib/smalruby3/dxruby_to_smalruby.rb', line 32 def position(pos_x, pos_y) [x(pos_x), y(pos_y)] end |
#x(pos_x) ⇒ Object
24 25 26 |
# File 'lib/smalruby3/dxruby_to_smalruby.rb', line 24 def x(pos_x) (pos_x / @scale + SCREEN_LEFT).ceil end |
#y(pos_y) ⇒ Object
28 29 30 |
# File 'lib/smalruby3/dxruby_to_smalruby.rb', line 28 def y(pos_y) -(pos_y / @scale + SCREEN_BOTTOM).ceil end |