Method: Sabrina::Sprite#generate_bytes

Defined in:
lib/sabrina/sprite.rb

#generate_bytesString

TODO:

Some breakage with number 360, is this the culprit?

Converts the internal representation to a GBA-compatible stream of bytes.

Returns:

  • (String)

See Also:



168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# File 'lib/sabrina/sprite.rb', line 168

def generate_bytes
  in_array = []
  present.join('').scan(/(.)(.)/) { |x, y| in_array += [y, x] }

  column_num = @width / 8
  out_array = []

  loop do
    break if in_array.empty?
    columns = [[]] * column_num

    until columns[0].length == 8 * 8
      column_num.times { |i| columns[i] += in_array.slice!(0, 8) }
    end # Filled one block

    out_array += columns.slice!(0) until columns.empty?
  end

  Bytestream.from_hex(out_array.join('')).to_b
end