Class: InteractiveTerm::Sprite

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#bitmapObject

Returns the value of attribute bitmap.



122
123
124
# File 'lib/interactive_term.rb', line 122

def bitmap
  @bitmap
end

#xObject

Returns the value of attribute x.



122
123
124
# File 'lib/interactive_term.rb', line 122

def x
  @x
end

#yObject

Returns the value of attribute y.



122
123
124
# File 'lib/interactive_term.rb', line 122

def y
  @y
end

Instance Method Details

#heightObject



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

#widthObject



143
144
145
# File 'lib/interactive_term.rb', line 143

def width
  @width || @bitmap.first.size
end