Class: Smalruby3::DXRubyToSmalruby

Inherits:
Object
  • Object
show all
Defined in:
lib/smalruby3/dxruby_to_smalruby.rb

Constant Summary collapse

SCREEN_BOTTOM =
-180
SCREEN_LEFT =
-240

Instance Attribute Summary collapse

Instance Method Summary collapse

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(options = {})
  defaults = {
    scale: 1,
  }
  opts = Util.process_options(options, defaults)
  opts.each do |k, v|
    send("#{k}=", v)
  end
end

Instance Attribute Details

#scaleObject

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