Class: InteractiveTerm::Sprite
- Inherits:
-
Object
- Object
- InteractiveTerm::Sprite
- Defined in:
- lib/interactive_term.rb
Instance Attribute Summary collapse
-
#bitmap ⇒ Object
Returns the value of attribute bitmap.
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
Instance Method Summary collapse
- #height ⇒ Object
-
#initialize(x, y, bitmap) ⇒ Sprite
constructor
bitmap is an array of strings.
- #iterate(&block) ⇒ Object
- #set_screen_dimensions(screen_width, screen_height) ⇒ Object
- #width ⇒ Object
Constructor Details
#initialize(x, y, bitmap) ⇒ Sprite
bitmap is an array of strings. (x,y) is the position of the first character. each string represents the next line. newlines in bitmap is undefined behavior.
128 129 130 131 132 |
# File 'lib/interactive_term.rb', line 128 def initialize(x, y, bitmap) @x = x @y = y @bitmap = bitmap end |
Instance Attribute Details
#bitmap ⇒ Object
Returns the value of attribute bitmap.
122 123 124 |
# File 'lib/interactive_term.rb', line 122 def bitmap @bitmap end |
#x ⇒ Object
Returns the value of attribute x.
122 123 124 |
# File 'lib/interactive_term.rb', line 122 def x @x end |
#y ⇒ Object
Returns the value of attribute y.
122 123 124 |
# File 'lib/interactive_term.rb', line 122 def y @y end |
Instance Method Details
#height ⇒ Object
147 148 149 |
# File 'lib/interactive_term.rb', line 147 def height @height || @bitmap.size end |
#iterate(&block) ⇒ Object
139 140 141 |
# File 'lib/interactive_term.rb', line 139 def iterate(&block) Bitmap.iterate(@bitmap, &block) end |
#set_screen_dimensions(screen_width, screen_height) ⇒ Object
134 135 136 137 |
# File 'lib/interactive_term.rb', line 134 def set_screen_dimensions(screen_width, screen_height) @screen_width = screen_width @screen_height = screen_height end |
#width ⇒ Object
143 144 145 |
# File 'lib/interactive_term.rb', line 143 def width @width || @bitmap.first.size end |