Class: Smalruby3::SmalrubyToDXRuby

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

Constant Summary collapse

SCREEN_TOP =
180
SCREEN_BOTTOM =
-180
SCREEN_LEFT =
-240
SCREEN_RIGHT =
240

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ SmalrubyToDXRuby



15
16
17
18
19
20
21
22
23
24
# 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

Instance Attribute Details

#fpsObject

Returns the value of attribute fps.



11
12
13
# File 'lib/smalruby3/smalruby_to_dxruby.rb', line 11

def fps
  @fps
end

#scaleObject

Returns the value of attribute scale.



10
11
12
# File 'lib/smalruby3/smalruby_to_dxruby.rb', line 10

def scale
  @scale
end

#window_heightObject (readonly)

Returns the value of attribute window_height.



13
14
15
# File 'lib/smalruby3/smalruby_to_dxruby.rb', line 13

def window_height
  @window_height
end

#window_widthObject (readonly)

Returns the value of attribute window_width.



12
13
14
# File 'lib/smalruby3/smalruby_to_dxruby.rb', line 12

def window_width
  @window_width
end

Instance Method Details

#angle(direction) ⇒ Object



52
53
54
# File 'lib/smalruby3/smalruby_to_dxruby.rb', line 52

def angle(direction)
  (direction - 90) % 360
end

#position(pos_x, pos_y) ⇒ Object



40
41
42
# File 'lib/smalruby3/smalruby_to_dxruby.rb', line 40

def position(pos_x, pos_y)
  [x(pos_x), y(pos_y)]
end

#screen_heightObject



48
49
50
# File 'lib/smalruby3/smalruby_to_dxruby.rb', line 48

def screen_height
  SCREEN_TOP - SCREEN_BOTTOM
end

#screen_widthObject



44
45
46
# File 'lib/smalruby3/smalruby_to_dxruby.rb', line 44

def screen_width
  SCREEN_RIGHT - SCREEN_LEFT
end

#x(pos_x) ⇒ Object



32
33
34
# File 'lib/smalruby3/smalruby_to_dxruby.rb', line 32

def x(pos_x)
  ((pos_x - SCREEN_LEFT) * @scale).ceil
end

#y(pos_y) ⇒ Object



36
37
38
# File 'lib/smalruby3/smalruby_to_dxruby.rb', line 36

def y(pos_y)
  ((-pos_y - SCREEN_BOTTOM) * @scale).ceil
end