Class: Plane
- Inherits:
-
Object
- Object
- Plane
- Defined in:
- lib/openrgss/plane.rb
Overview
# The Plane class. Planes are special sprites that tile bitmap patterns across the entire screen and are used to display parallax backgrounds and so on.
Instance Attribute Summary collapse
-
#ox ⇒ Object
The x-coordinate of the plane’s starting point.
-
#oy ⇒ Object
The y-coordinate of the plane’s starting point.
Instance Method Summary collapse
- #bitmap ⇒ Object
- #bitmap=(arg_bmp) ⇒ Object
-
#dispose ⇒ Object
Frees the plane.
-
#disposed? ⇒ Boolean
Returns TRUE if the plane has been freed.
-
#initialize(arg_viewport = nil) ⇒ Plane
constructor
Creates a Plane object.
- #method_missing(symbol, *args) ⇒ Object
Constructor Details
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(symbol, *args) ⇒ Object
98 99 100 |
# File 'lib/openrgss/plane.rb', line 98 def method_missing(symbol, *args) @sprite.method(symbol).call(*args) end |
Instance Attribute Details
#ox ⇒ Object
The x-coordinate of the plane’s starting point. Change this value to scroll the plane.
19 20 21 |
# File 'lib/openrgss/plane.rb', line 19 def ox @ox end |
#oy ⇒ Object
The y-coordinate of the plane’s starting point. Change this value to scroll the plane.
22 23 24 |
# File 'lib/openrgss/plane.rb', line 22 def oy @oy end |
Instance Method Details
#bitmap ⇒ Object
72 73 74 |
# File 'lib/openrgss/plane.rb', line 72 def bitmap @src_bitmap end |
#bitmap=(arg_bmp) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/openrgss/plane.rb', line 77 def bitmap=(arg_bmp) vp_width = @sprite..nil? ? \ Graphics.width : @sprite..rect.width vp_height = @sprite..nil? ? \ Graphics.height : @sprite..rect.height x_steps = [(vp_width / arg_bmp.width).ceil, 1].max * 2 y_steps = [(vp_height / arg_bmp.height).ceil, 1].max * 2 bmp_width = x_steps * arg_bmp.width bmp_height = y_steps * arg_bmp.height @src_bitmap = arg_bmp @sprite.bitmap.dispose unless @sprite.bitmap.nil? or @sprite.bitmap.disposed? @sprite.bitmap = Bitmap.new(bmp_width, bmp_height) x_steps.times { |ix| y_steps.times { |iy| @sprite.bitmap.blt(ix * arg_bmp.width, iy * arg_bmp.height, @src_bitmap, @src_bitmap.rect) } } end |
#dispose ⇒ Object
Frees the plane. If the plane has already been freed, does nothing.
50 51 52 53 |
# File 'lib/openrgss/plane.rb', line 50 def dispose @sprite.bitmap.dispose unless @sprite.bitmap.nil? or @sprite.bitmap.disposed? @sprite.dispose unless @sprite.nil? or @sprite.disposed? end |
#disposed? ⇒ Boolean
Returns TRUE if the plane has been freed.
57 58 59 |
# File 'lib/openrgss/plane.rb', line 57 def disposed? @sprite.nil? or @sprite.disposed? end |