2023-12-06 16:32:40 +10:30
|
|
|
const globals = preload('res://globals.gd') # Make LSP shut up about non-const
|
2023-07-31 23:33:05 +09:30
|
|
|
const INDEX_FORMAT := globals.INDEX_FORMAT
|
|
|
|
|
|
|
|
static func ByteArray(size: int) -> PoolByteArray:
|
|
|
|
var arr := PoolByteArray()
|
|
|
|
arr.resize(size)
|
|
|
|
return arr
|
|
|
|
|
|
|
|
static func _4bpp_to_tile(data: PoolByteArray) -> Image:
|
|
|
|
var tdata := ByteArray(64)
|
|
|
|
for i in range(32):
|
|
|
|
tdata[i*2] = data[i] % 16
|
|
|
|
tdata[i*2+1] = data[i] / 16
|
|
|
|
var tile := Image.new()
|
|
|
|
tile.create_from_data(8, 8, false, INDEX_FORMAT, tdata)
|
|
|
|
return tile
|