本文整理匯總了Python中coilsnake.model.eb.graphics.EbGraphicTileset.add_tile方法的典型用法代碼示例。如果您正苦於以下問題:Python EbGraphicTileset.add_tile方法的具體用法?Python EbGraphicTileset.add_tile怎麽用?Python EbGraphicTileset.add_tile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類coilsnake.model.eb.graphics.EbGraphicTileset
的用法示例。
在下文中一共展示了EbGraphicTileset.add_tile方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_add_tile
# 需要導入模塊: from coilsnake.model.eb.graphics import EbGraphicTileset [as 別名]
# 或者: from coilsnake.model.eb.graphics.EbGraphicTileset import add_tile [as 別名]
def test_add_tile(self):
tileset = EbGraphicTileset(num_tiles=5, tile_width=8, tile_height=8)
tile = [
array("B", [5, 7, 6, 4, 1, 5, 3, 3]),
array("B", [5, 8, 3, 7, 5, 7, 1, 1]),
array("B", [6, 1, 1, 5, 4, 0, 1, 5]),
array("B", [2, 1, 4, 5, 4, 1, 6, 4]),
array("B", [4, 6, 6, 2, 1, 0, 4, 4]),
array("B", [6, 1, 0, 7, 5, 8, 1, 8]),
array("B", [8, 0, 4, 0, 2, 8, 0, 8]),
array("B", [0, 6, 8, 6, 0, 5, 4, 0]),
]
tile1_id, tile1_vflip, tile1_hflip = tileset.add_tile(tile)
tile2_id, tile2_vflip, tile2_hflip = tileset.add_tile(tile)
assert_equal(tile2_id, tile1_id)
assert_equal(tile2_vflip, tile1_vflip)
assert_equal(tile2_hflip, tile1_hflip)
tile.reverse()
tile2_id, tile2_vflip, tile2_hflip = tileset.add_tile(tile)
assert_equal(tile2_id, tile1_id)
assert_equal(tile2_vflip, not tile1_vflip)
assert_equal(tile2_hflip, tile1_hflip)
for row in tile:
row.reverse()
tile2_id, tile2_vflip, tile2_hflip = tileset.add_tile(tile)
assert_equal(tile2_id, tile1_id)
assert_equal(tile2_vflip, not tile1_vflip)
assert_equal(tile2_hflip, not tile1_hflip)
tile.reverse()
tile2_id, tile2_vflip, tile2_hflip = tileset.add_tile(tile)
assert_equal(tile2_id, tile1_id)
assert_equal(tile2_vflip, tile1_vflip)
assert_equal(tile2_hflip, not tile1_hflip)
tile = [
array("B", [1, 2, 3, 4, 1, 5, 3, 3]),
array("B", [5, 8, 3, 7, 5, 7, 1, 1]),
array("B", [6, 1, 1, 5, 4, 0, 1, 5]),
array("B", [2, 1, 4, 5, 4, 1, 6, 4]),
array("B", [4, 6, 6, 2, 1, 0, 4, 4]),
array("B", [6, 1, 0, 7, 5, 8, 1, 8]),
array("B", [8, 0, 4, 0, 2, 8, 0, 8]),
array("B", [0, 6, 8, 6, 0, 5, 4, 0]),
]
tile2_id, tile2_vflip, tile2_hflip = tileset.add_tile(tile)
assert_not_equal(tile2_id, tile1_id)