Class: Smalruby3::SmalrubyToDXRuby
- Inherits:
-
Object
- Object
- Smalruby3::SmalrubyToDXRuby
- 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
-
#fps ⇒ Object
Returns the value of attribute fps.
-
#scale ⇒ Object
Returns the value of attribute scale.
-
#window_height ⇒ Object
readonly
Returns the value of attribute window_height.
-
#window_width ⇒ Object
readonly
Returns the value of attribute window_width.
Instance Method Summary collapse
- #angle(direction) ⇒ Object
-
#initialize(options = {}) ⇒ SmalrubyToDXRuby
constructor
A new instance of SmalrubyToDXRuby.
- #position(pos_x, pos_y) ⇒ Object
- #screen_height ⇒ Object
- #screen_width ⇒ Object
- #x(pos_x) ⇒ Object
- #y(pos_y) ⇒ Object
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( = {}) defaults = { scale: 1, fps: 15, } opts = Util.(, defaults) opts.each do |k, v| send("#{k}=", v) end end |
Instance Attribute Details
#fps ⇒ Object
Returns the value of attribute fps.
11 12 13 |
# File 'lib/smalruby3/smalruby_to_dxruby.rb', line 11 def fps @fps end |
#scale ⇒ Object
Returns the value of attribute scale.
10 11 12 |
# File 'lib/smalruby3/smalruby_to_dxruby.rb', line 10 def scale @scale end |
#window_height ⇒ Object (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_width ⇒ Object (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_height ⇒ Object
48 49 50 |
# File 'lib/smalruby3/smalruby_to_dxruby.rb', line 48 def screen_height SCREEN_TOP - SCREEN_BOTTOM end |
#screen_width ⇒ Object
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 |