class Smalruby3::SmalrubyToDXRuby
Constants
- SCREEN_BOTTOM
- SCREEN_LEFT
- SCREEN_RIGHT
- SCREEN_TOP
Attributes
fps[RW]
scale[R]
window_height[R]
window_width[R]
Public Class Methods
new(options = {})
click to toggle source
# File lib/smalruby3/smalruby_to_dxruby.rb, line 15 def initialize(options = {}) defaults = { scale: 1, fps: 15, } opts = Util.process_options(options, defaults) opts.each do |k, v| send("#{k}=", v) end end
Public Instance Methods
angle(direction)
click to toggle source
# File lib/smalruby3/smalruby_to_dxruby.rb, line 52 def angle(direction) (direction - 90) % 360 end
position(pos_x, pos_y)
click to toggle source
# File lib/smalruby3/smalruby_to_dxruby.rb, line 40 def position(pos_x, pos_y) [x(pos_x), y(pos_y)] end
scale=(val)
click to toggle source
# File lib/smalruby3/smalruby_to_dxruby.rb, line 26 def scale=(val) @scale = val.to_f @window_width = (screen_width * @scale).ceil @window_height = (screen_height * @scale).ceil end
screen_height()
click to toggle source
# File lib/smalruby3/smalruby_to_dxruby.rb, line 48 def screen_height SCREEN_TOP - SCREEN_BOTTOM end
screen_width()
click to toggle source
# File lib/smalruby3/smalruby_to_dxruby.rb, line 44 def screen_width SCREEN_RIGHT - SCREEN_LEFT end
x(pos_x)
click to toggle source
# File lib/smalruby3/smalruby_to_dxruby.rb, line 32 def x(pos_x) ((pos_x - SCREEN_LEFT) * @scale).ceil end
y(pos_y)
click to toggle source
# File lib/smalruby3/smalruby_to_dxruby.rb, line 36 def y(pos_y) ((-pos_y - SCREEN_BOTTOM) * @scale).ceil end