class Smalruby3::DXRubyToSmalruby

Constants

SCREEN_BOTTOM
SCREEN_LEFT

Attributes

scale[R]

Public Class Methods

new(options = {}) click to toggle source
# File lib/smalruby3/dxruby_to_smalruby.rb, line 10
def initialize(options = {})
  defaults = {
    scale: 1,
  }
  opts = Util.process_options(options, defaults)
  opts.each do |k, v|
    send("#{k}=", v)
  end
end

Public Instance Methods

position(pos_x, pos_y) click to toggle source
# File lib/smalruby3/dxruby_to_smalruby.rb, line 32
def position(pos_x, pos_y)
  [x(pos_x), y(pos_y)]
end
scale=(val) click to toggle source
# File lib/smalruby3/dxruby_to_smalruby.rb, line 20
def scale=(val)
  @scale = val.to_f
end
x(pos_x) click to toggle source
# File lib/smalruby3/dxruby_to_smalruby.rb, line 24
def x(pos_x)
  (pos_x / @scale + SCREEN_LEFT).ceil
end
y(pos_y) click to toggle source
# File lib/smalruby3/dxruby_to_smalruby.rb, line 28
def y(pos_y)
  -(pos_y / @scale + SCREEN_BOTTOM).ceil
end