本文整理匯總了Python中coilsnake.model.eb.graphics.EbGraphicTileset.tiles[1]方法的典型用法代碼示例。如果您正苦於以下問題:Python EbGraphicTileset.tiles[1]方法的具體用法?Python EbGraphicTileset.tiles[1]怎麽用?Python EbGraphicTileset.tiles[1]使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類coilsnake.model.eb.graphics.EbGraphicTileset
的用法示例。
在下文中一共展示了EbGraphicTileset.tiles[1]方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_to_block_1bpp
# 需要導入模塊: from coilsnake.model.eb.graphics import EbGraphicTileset [as 別名]
# 或者: from coilsnake.model.eb.graphics.EbGraphicTileset import tiles[1] [as 別名]
def test_to_block_1bpp(self):
tileset = EbGraphicTileset(num_tiles=2, tile_width=8, tile_height=8)
tileset.tiles = [None, None]
tileset.tiles[0] = [
[0, 0, 0, 0, 0, 0, 1, 1],
[0, 1, 1, 1, 0, 0, 0, 0],
[0, 1, 0, 0, 1, 0, 0, 1],
[1, 1, 1, 1, 0, 0, 0, 0],
[0, 1, 0, 0, 1, 0, 1, 0],
[1, 1, 0, 0, 1, 0, 0, 0],
[0, 1, 1, 1, 0, 0, 0, 1],
[0, 0, 0, 0, 0, 0, 0, 1],
]
tileset.tiles[1] = [
[0, 0, 1, 0, 0, 0, 0, 0],
[0, 0, 1, 1, 0, 0, 0, 0],
[0, 0, 1, 0, 1, 0, 0, 0],
[0, 0, 1, 0, 1, 0, 0, 0],
[0, 1, 1, 0, 0, 0, 0, 0],
[1, 1, 1, 0, 0, 0, 0, 0],
[1, 1, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 1],
]
block = Block()
block.from_list([0] * 16)
tileset.to_block(block, 0, 1)
assert_list_equal(
block.to_list(),
[
0b00000011,
0b01110000,
0b01001001,
0b11110000,
0b01001010,
0b11001000,
0b01110001,
0b00000001,
0b00100000,
0b00110000,
0b00101000,
0b00101000,
0b01100000,
0b11100000,
0b11000000,
0b00000001,
],
)
示例2: test_to_block_2bpp
# 需要導入模塊: from coilsnake.model.eb.graphics import EbGraphicTileset [as 別名]
# 或者: from coilsnake.model.eb.graphics.EbGraphicTileset import tiles[1] [as 別名]
def test_to_block_2bpp(self):
tileset = EbGraphicTileset(num_tiles=2, tile_width=8, tile_height=8)
tileset.tiles = [None, None]
tileset.tiles[0] = [
[2, 1, 2, 3, 2, 1, 2, 1],
[2, 3, 1, 0, 2, 3, 2, 2],
[3, 0, 3, 2, 2, 2, 0, 2],
[1, 3, 3, 0, 2, 0, 2, 3],
[1, 0, 1, 1, 0, 3, 3, 3],
[1, 3, 3, 3, 3, 2, 1, 2],
[2, 2, 3, 1, 2, 2, 1, 0],
[2, 0, 3, 3, 2, 3, 1, 0],
]
tileset.tiles[1] = [
[1, 3, 3, 1, 3, 0, 2, 1],
[3, 2, 2, 3, 3, 2, 2, 2],
[1, 1, 2, 2, 3, 0, 1, 1],
[0, 3, 2, 2, 0, 0, 0, 3],
[3, 3, 0, 0, 1, 0, 1, 0],
[2, 3, 1, 3, 3, 2, 1, 2],
[0, 0, 0, 1, 3, 2, 3, 3],
[2, 2, 3, 2, 0, 0, 0, 1],
]
block = Block()
block.from_list([0] * 32)
tileset.to_block(block, 0, 2)
assert_list_equal(
block.to_list(),
[
0b01010101, # Tile 1
0b10111010,
0b01100100,
0b11001111,
0b10100000,
0b10111101,
0b11100001,
0b01101011,
0b10110111,
0b00000111,
0b11111010,
0b01111101,
0b00110010,
0b11101100,
0b00110110,
0b10111100,
0b11111001, # Tile 2
0b01101010,
0b10011000,
0b11111111,
0b11001011,
0b00111000,
0b01000001,
0b01110001,
0b11001010,
0b11000000,
0b01111010,
0b11011101,
0b00011011,
0b00001111,
0b00100001,
0b11110000,
],
)