当前位置: 首页>>代码示例>>Python>>正文


Python graphics.EbGraphicTileset类代码示例

本文整理汇总了Python中coilsnake.model.eb.graphics.EbGraphicTileset的典型用法代码示例。如果您正苦于以下问题:Python EbGraphicTileset类的具体用法?Python EbGraphicTileset怎么用?Python EbGraphicTileset使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了EbGraphicTileset类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

    def __init__(self):
        super(TitleScreenModule, self).__init__()

        # Background data (includes the central "B", the copyright
        # notice and the glow around the letters)
        self.bg_tileset = EbGraphicTileset(
            num_tiles=BG_NUM_TILES, tile_width=TILE_WIDTH,
            tile_height=TILE_HEIGHT
        )
        self.bg_arrangement = EbTileArrangement(
            width=BG_ARRANGEMENT_WIDTH, height=BG_ARRANGEMENT_HEIGHT
        )
        self.bg_anim_palette = EbPalette(
            num_subpalettes=BG_NUM_ANIM_SUBPALETTES,
            subpalette_length=ANIM_SUBPALETTE_LENGTH
        )
        self.bg_palette = EbPalette(
            num_subpalettes=NUM_SUBPALETTES,
            subpalette_length=BG_SUBPALETTE_LENGTH
        )

        # Characters data (the title screen's animated letters)
        self.chars_tileset = EbGraphicTileset(
            num_tiles=CHARS_NUM_TILES, tile_width=TILE_WIDTH,
            tile_height=TILE_HEIGHT
        )
        self.chars_anim_palette = EbPalette(
            num_subpalettes=CHARS_NUM_ANIM_SUBPALETTES,
            subpalette_length=ANIM_SUBPALETTE_LENGTH
        )
        self.chars_palette = EbPalette(
            num_subpalettes=NUM_SUBPALETTES,
            subpalette_length=CHARS_SUBPALETTE_LENGTH
        )
        self.chars_layouts = [[] for _ in range(NUM_CHARS)]
开发者ID:LittleCube13,项目名称:CoilSnake,代码行数:35,代码来源:TitleScreenModule.py

示例2: __init__

    def __init__(self):
        super(WindowGraphicsModule, self).__init__()
        self.graphics_1 = EbGraphicTileset(num_tiles=416, tile_width=8, tile_height=8)
        self.graphics_2 = EbGraphicTileset(num_tiles=7, tile_width=8, tile_height=8)

        self.flavor_palettes = [EbPalette(8, 4) for i in range(7)]
        self.flavor_names = dict()
开发者ID:LittleCube13,项目名称:CoilSnake,代码行数:7,代码来源:WindowGraphicsModule.py

示例3: test_to_block_4bpp

 def test_to_block_4bpp(self):
     tileset = EbGraphicTileset(num_tiles=1, tile_width=8, tile_height=8)
     tileset.tiles = [None]
     tileset.tiles[0] = [
         [8, 1, 12, 9, 6, 5, 3, 2],
         [11, 5, 8, 14, 1, 7, 15, 0],
         [8, 13, 3, 7, 2, 0, 2, 3],
         [10, 0, 4, 14, 7, 10, 11, 9],
         [8, 8, 12, 9, 13, 12, 2, 6],
         [11, 14, 14, 4, 14, 4, 10, 7],
         [12, 2, 12, 8, 4, 15, 12, 14],
         [10, 13, 12, 1, 10, 11, 11, 2],
     ]
     block = Block()
     block.from_list([0] * 32)
     tileset.to_block(block, 0, 4)
     assert_list_equal(
         block.to_list(),
         [
             0b01010110,
             0b00001011,
             0b11001110,
             0b10010110,
             0b01110001,
             0b00111011,
             0b00001011,
             0b10011110,
             0b00011000,
             0b00000011,
             0b10000001,
             0b11101011,
             0b00000100,
             0b01000101,
             0b01010110,
             0b10001111,
             0b00101100,
             0b10110000,
             0b01010110,
             0b10110010,
             0b01010000,
             0b11000000,
             0b00111000,
             0b10010111,
             0b00101101,
             0b11111100,
             0b01111101,
             0b11101010,
             0b10101111,
             0b10110111,
             0b01100000,
             0b11101110,
         ],
     )
开发者ID:,项目名称:,代码行数:53,代码来源:

示例4: test_from_block_4bpp

 def test_from_block_4bpp(self):
     block = Block()
     block.from_list(
         [
             0b01010110,
             0b00001011,
             0b11001110,
             0b10010110,
             0b01110001,
             0b00111011,
             0b00001011,
             0b10011110,
             0b00011000,
             0b00000011,
             0b10000001,
             0b11101011,
             0b00000100,
             0b01000101,
             0b01010110,
             0b10001111,
             0b00101100,
             0b10110000,
             0b01010110,
             0b10110010,
             0b01010000,
             0b11000000,
             0b00111000,
             0b10010111,
             0b00101101,
             0b11111100,
             0b01111101,
             0b11101010,
             0b10101111,
             0b10110111,
             0b01100000,
             0b11101110,
         ]
     )
     tileset = EbGraphicTileset(num_tiles=1, tile_width=8, tile_height=8)
     tileset.from_block(block, offset=0, bpp=4)
     assert_list_equal(
         tileset[0],
         [
             [8, 1, 12, 9, 6, 5, 3, 2],
             [11, 5, 8, 14, 1, 7, 15, 0],
             [8, 13, 3, 7, 2, 0, 2, 3],
             [10, 0, 4, 14, 7, 10, 11, 9],
             [8, 8, 12, 9, 13, 12, 2, 6],
             [11, 14, 14, 4, 14, 4, 10, 7],
             [12, 2, 12, 8, 4, 15, 12, 14],
             [10, 13, 12, 1, 10, 11, 11, 2],
         ],
     )
开发者ID:,项目名称:,代码行数:53,代码来源:

示例5: test_from_block_1bpp

 def test_from_block_1bpp(self):
     block = Block()
     block.from_list(
         [
             0b00000011,
             0b01110000,
             0b01001001,
             0b11110000,
             0b01001010,
             0b11001000,
             0b01110001,
             0b00000001,
             0b00100000,
             0b00110000,
             0b00101000,
             0b00101000,
             0b01100000,
             0b11100000,
             0b11000000,
             0b00000001,
         ]
     )
     tileset = EbGraphicTileset(num_tiles=2, tile_width=8, tile_height=8)
     tileset.from_block(block, offset=0, bpp=1)
     assert_list_equal(
         tileset[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],
         ],
     )
     assert_list_equal(
         tileset[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],
         ],
     )
开发者ID:,项目名称:,代码行数:50,代码来源:

示例6: EbCreditsFont

class EbCreditsFont(object):
    def __init__(self):
        self.tileset = EbGraphicTileset(num_tiles=192, tile_width=8, tile_height=8)
        self.palette = EbPalette(num_subpalettes=2, subpalette_length=4)

    def from_block(self, block, tileset_asm_pointer_offset, palette_offset):
        with EbCompressibleBlock() as compressed_block:
            compressed_block.from_compressed_block(block=block, offset=from_snes_address(
                read_asm_pointer(block=block, offset=tileset_asm_pointer_offset)))
            self.tileset.from_block(block=compressed_block, bpp=2)
        self.palette.from_block(block=block, offset=palette_offset)

    def to_block(self, block, tileset_asm_pointer_offset, palette_offset):
        tileset_block_size = self.tileset.block_size(bpp=2)
        with EbCompressibleBlock(tileset_block_size) as compressed_block:
            self.tileset.to_block(block=compressed_block, offset=0, bpp=2)
            compressed_block.compress()
            tileset_offset = block.allocate(data=compressed_block)
            write_asm_pointer(block=block, offset=tileset_asm_pointer_offset, pointer=to_snes_address(tileset_offset))
        self.palette.to_block(block=block, offset=palette_offset)

    def to_files(self, image_file, image_format="png"):
        image = _CREDITS_PREVIEW_ARRANGEMENT.image(self.tileset, self.palette)
        image.save(image_file, image_format)
        del image

    def from_files(self, image_file, image_format="png"):
        image = open_indexed_image(image_file)
        self.palette.from_image(image)
        self.tileset.from_image(image, _CREDITS_PREVIEW_ARRANGEMENT, self.palette)
        del image
开发者ID:LittleCube13,项目名称:CoilSnake,代码行数:31,代码来源:fonts.py

示例7: read_from_rom

    def read_from_rom(self, rom):
        self.bg_table.from_block(block=rom, offset=from_snes_address(BACKGROUND_TABLE_OFFSET))
        self.scroll_table.from_block(block=rom, offset=from_snes_address(SCROLL_TABLE_OFFSET))
        self.distortion_table.from_block(block=rom, offset=from_snes_address(DISTORTION_TABLE_OFFSET))
        self.graphics_pointer_table.from_block(
            block=rom,
            offset=from_snes_address(read_asm_pointer(block=rom,
                                                      offset=GRAPHICS_POINTER_TABLE_ASM_POINTER_OFFSETS[0])))
        self.arrangement_pointer_table.from_block(
            block=rom,
            offset=from_snes_address(read_asm_pointer(block=rom,
                                                      offset=ARRANGEMENT_POINTER_TABLE_ASM_POINTER_OFFSETS[0])))
        self.palette_pointer_table.from_block(
            block=rom,
            offset=from_snes_address(read_asm_pointer(block=rom,
                                                      offset=PALETTE_POINTER_TABLE_ASM_POINTER_OFFSETS[0])))

        self.backgrounds = [None for i in range(self.graphics_pointer_table.num_rows)]
        self.palettes = [None for i in range(self.palette_pointer_table.num_rows)]
        for i in range(self.bg_table.num_rows):
            graphics_id = self.bg_table[i][0]
            color_depth = self.bg_table[i][2]
            if self.backgrounds[graphics_id] is None:
                # Max tiles used in rom: 421 (2bpp) 442 (4bpp)
                tileset = EbGraphicTileset(num_tiles=512, tile_width=8, tile_height=8)
                with EbCompressibleBlock() as compressed_block:
                    compressed_block.from_compressed_block(
                        block=rom,
                        offset=from_snes_address(self.graphics_pointer_table[graphics_id][0]))
                    tileset.from_block(compressed_block, offset=0, bpp=color_depth)

                arrangement = EbTileArrangement(width=32, height=32)
                with EbCompressibleBlock() as compressed_block:
                    compressed_block.from_compressed_block(
                        block=rom,
                        offset=from_snes_address(self.arrangement_pointer_table[graphics_id][0]))
                    arrangement.from_block(block=compressed_block, offset=0)

                self.backgrounds[graphics_id] = (tileset, color_depth, arrangement)
                
            palette_id = self.bg_table[i][1]
            if self.palettes[palette_id] is None:
                palette = EbPalette(num_subpalettes=1, subpalette_length=16)
                palette.from_block(block=rom, offset=from_snes_address(self.palette_pointer_table[palette_id][0]))
                self.palettes[palette_id] = palette
开发者ID:Lyrositor,项目名称:CoilSnake,代码行数:45,代码来源:BattleBgModule.py

示例8: test_from_image_8x8_1bpp

    def test_from_image_8x8_1bpp(self):
        palette = EbPalette(1, 2)
        palette[0, 0].from_tuple((0xFF, 0xFF, 0xFF))
        palette[0, 1].from_tuple((0x0, 0x0, 0x0))

        arrangement = EbTileArrangement(width=2, height=2)
        arrangement[0, 0].tile = 0
        arrangement[1, 0].tile = 2
        arrangement[0, 1].tile = 1
        arrangement[1, 1].tile = 3

        tileset = EbGraphicTileset(num_tiles=4, tile_width=8, tile_height=8)
        tileset.from_image(self.tile_8x8_2bpp_img, arrangement=arrangement, palette=palette)
        assert_list_equal(tileset[0], [[0] * 8] * 8)
        assert_list_equal(tileset[2], [[1] * 8] * 8)
        assert_list_equal(
            tileset[1],
            [
                [0, 0, 0, 0, 0, 0, 0, 0],
                [0, 0, 0, 0, 0, 0, 0, 0],
                [0, 0, 1, 1, 1, 1, 0, 0],
                [0, 0, 1, 1, 1, 1, 0, 0],
                [0, 0, 1, 1, 1, 1, 0, 0],
                [0, 0, 1, 1, 1, 1, 0, 0],
                [0, 0, 0, 0, 0, 0, 0, 0],
                [0, 0, 0, 0, 0, 0, 0, 0],
            ],
        )
        assert_list_equal(
            tileset[3],
            [
                [0, 1, 1, 1, 1, 1, 1, 1],
                [0, 1, 1, 1, 1, 1, 1, 1],
                [0, 1, 0, 0, 0, 0, 1, 1],
                [1, 1, 0, 0, 1, 0, 1, 1],
                [1, 1, 0, 1, 0, 0, 1, 1],
                [1, 1, 0, 0, 0, 0, 1, 1],
                [1, 1, 1, 1, 1, 1, 1, 1],
                [1, 1, 1, 1, 1, 1, 1, 0],
            ],
        )
开发者ID:,项目名称:,代码行数:41,代码来源:

示例9: EbFont

class EbFont(object):
    def __init__(self, num_characters=96, tile_width=16, tile_height=8):
        self.num_characters = num_characters
        self.tileset = EbGraphicTileset(num_tiles=num_characters, tile_width=tile_width, tile_height=tile_height)
        self.character_widths = None

    def from_block(self, block, tileset_offset, character_widths_offset):
        self.tileset.from_block(block=block, offset=tileset_offset, bpp=1)
        self.character_widths = block[character_widths_offset:character_widths_offset + self.num_characters].to_list()

    def to_block(self, block, tileset_offset, character_widths_offset):
        self.tileset.to_block(block=block, offset=tileset_offset, bpp=1)
        block[character_widths_offset:character_widths_offset + self.num_characters] = self.character_widths

    def to_files(self, image_file, widths_file, image_format="png", widths_format="yml"):
        image = _FONT_IMAGE_ARRANGEMENT.image(self.tileset, _FONT_IMAGE_PALETTE)
        image.save(image_file, image_format)
        del image

        character_widths_dict = dict(enumerate(self.character_widths))
        if widths_format == "yml":
            yml_dump(character_widths_dict, widths_file, default_flow_style=False)

    def from_files(self, image_file, widths_file, image_format="png", widths_format="yml"):
        image = open_indexed_image(image_file)
        self.tileset.from_image(image, _FONT_IMAGE_ARRANGEMENT, _FONT_IMAGE_PALETTE)
        del image

        if widths_format == "yml":
            widths_dict = yml_load(widths_file)
            self.character_widths = map(lambda i: widths_dict[i], range(self.tileset.num_tiles_maximum))
开发者ID:soycamo,项目名称:CoilSnake,代码行数:31,代码来源:fonts.py

示例10: __init__

    def __init__(self):
        super(DeathScreenModule, self).__init__()

        self.tileset = EbGraphicTileset(
            num_tiles=NUM_TILES, tile_width=TILE_WIDTH, tile_height=TILE_HEIGHT
        )
        self.arrangement = EbTileArrangement(
            width=ARRANGEMENT_WIDTH, height=ARRANGEMENT_HEIGHT
        )
        self.palette = EbPalette(
            num_subpalettes=NUM_SUBPALETTES,
            subpalette_length=SUBPALETTE_LENGTH
        )
开发者ID:LittleCube13,项目名称:CoilSnake,代码行数:13,代码来源:DeathScreenModule.py

示例11: test_add_tile

    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)
开发者ID:,项目名称:,代码行数:50,代码来源:

示例12: test_to_block_1bpp

 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,
         ],
     )
开发者ID:,项目名称:,代码行数:47,代码来源:

示例13: SoundStoneModule

class SoundStoneModule(EbModule):
    NAME = "Sound Stone"
    FREE_RANGES = [(0x0EDD5D, 0x0EF805)]  # Sound stone graphics

    def __init__(self):
        super(SoundStoneModule, self).__init__()
        self.tileset = EbGraphicTileset(num_tiles=352, tile_width=8, tile_height=8)
        self.palette = EbPalette(num_subpalettes=6, subpalette_length=16)

    def read_from_rom(self, rom):
        graphics_offset = from_snes_address(read_asm_pointer(
            block=rom, offset=GRAPHICS_ASM_POINTER_OFFSET))
        with EbCompressibleBlock() as compressed_block:
            compressed_block.from_compressed_block(block=rom, offset=graphics_offset)
            self.tileset.from_block(block=compressed_block, bpp=4)
        self.palette.from_block(block=rom, offset=PALETTE_OFFSET)

    def write_to_rom(self, rom):
        tileset_block_size = self.tileset.block_size(bpp=4)
        with EbCompressibleBlock(tileset_block_size) as compressed_block:
            self.tileset.to_block(block=compressed_block, offset=0, bpp=4)
            compressed_block.compress()
            tileset_offset = rom.allocate(data=compressed_block)
            write_asm_pointer(block=rom, offset=GRAPHICS_ASM_POINTER_OFFSET, pointer=to_snes_address(tileset_offset))
        self.palette.to_block(block=rom, offset=PALETTE_OFFSET)

    def read_from_project(self, resource_open):
        with resource_open("Logos/SoundStone", "png") as image_file:
            image = open_indexed_image(image_file)
            self.palette.from_image(image)
            self.tileset.from_image(image, SOUND_STONE_ARRANGEMENT, self.palette)

    def write_to_project(self, resource_open):
        image = SOUND_STONE_ARRANGEMENT.image(self.tileset, self.palette)
        with resource_open("Logos/SoundStone", "png") as image_file:
            image.save(image_file, "png")

    def upgrade_project(self, old_version, new_version, rom, resource_open_r, resource_open_w, resource_delete):
        if old_version < 8:
            self.read_from_rom(rom)
            self.write_to_project(resource_open_w)
开发者ID:LittleCube13,项目名称:CoilSnake,代码行数:41,代码来源:SoundStoneModule.py

示例14: WindowGraphicsModule

class WindowGraphicsModule(EbModule):
    NAME = "Window Graphics"
    FREE_RANGES = [(0x200000, 0x20079f)]  # Graphics

    def __init__(self):
        super(WindowGraphicsModule, self).__init__()
        self.graphics_1 = EbGraphicTileset(num_tiles=416, tile_width=8, tile_height=8)
        self.graphics_2 = EbGraphicTileset(num_tiles=7, tile_width=8, tile_height=8)

        self.flavor_palettes = [EbPalette(8, 4) for i in range(7)]
        self.flavor_names = dict()

    def read_from_rom(self, rom):
        with EbCompressibleBlock() as compressed_block:
            compressed_block.from_compressed_block(
                block=rom,
                offset=from_snes_address(read_asm_pointer(rom, GRAPHICS_1_ASM_POINTER_OFFSET)))
            self.graphics_1.from_block(block=compressed_block, bpp=2)

        with EbCompressibleBlock() as compressed_block:
            compressed_block.from_compressed_block(
                block=rom,
                offset=from_snes_address(read_asm_pointer(rom, GRAPHICS_2_ASM_POINTER_OFFSET)))
            self.graphics_2.from_block(block=compressed_block, bpp=2)

        # Read palettes
        offset = FLAVOR_PALETTES_OFFSET
        for palette in self.flavor_palettes:
            palette.from_block(block=rom, offset=offset)
            offset += 64

        # Read names
        for asm_pointer_offset in FLAVOR_NAME_ASM_POINTER_OFFSETS:
            self.flavor_names[asm_pointer_offset] = FLAVOR_NAME_ENTRY.from_block(
                block=rom,
                offset=from_snes_address(read_asm_pointer(block=rom, offset=asm_pointer_offset)))

    def write_to_rom(self, rom):
        graphics_1_block_size = self.graphics_1.block_size(bpp=2)
        with EbCompressibleBlock(graphics_1_block_size) as compressed_block:
            self.graphics_1.to_block(block=compressed_block, offset=0, bpp=2)
            compressed_block.compress()
            graphics_1_offset = rom.allocate(data=compressed_block)
            write_asm_pointer(block=rom, offset=GRAPHICS_1_ASM_POINTER_OFFSET,
                              pointer=to_snes_address(graphics_1_offset))

        graphics_2_block_size = self.graphics_2.block_size(bpp=2)
        with EbCompressibleBlock(graphics_2_block_size) as compressed_block:
            self.graphics_2.to_block(block=compressed_block, offset=0, bpp=2)
            compressed_block.compress()
            graphics_2_offset = rom.allocate(data=compressed_block)
            write_asm_pointer(block=rom, offset=GRAPHICS_2_ASM_POINTER_OFFSET,
                              pointer=to_snes_address(graphics_2_offset))

        # Write palettes
        offset = FLAVOR_PALETTES_OFFSET
        for palette in self.flavor_palettes:
            palette.to_block(block=rom, offset=offset)
            offset += 64

        # Write names
        for asm_pointer_offset in FLAVOR_NAME_ASM_POINTER_OFFSETS:
            name = self.flavor_names[asm_pointer_offset]
            offset = rom.allocate(size=FLAVOR_NAME_ENTRY.size)
            FLAVOR_NAME_ENTRY.to_block(block=rom, offset=offset, value=name)
            write_asm_pointer(block=rom, offset=asm_pointer_offset, pointer=to_snes_address(offset))

    def write_to_project(self, resource_open):
        for i, palette in enumerate(self.flavor_palettes):
            with resource_open("WindowGraphics/Windows1_" + str(i), "png") as image_file:
                image = ARRANGEMENT_1.image(tileset=self.graphics_1, palette=palette)
                image.save(image_file, "png")
            with resource_open("WindowGraphics/Windows2_" + str(i), "png") as image_file:
                image = ARRANGEMENT_2.image(tileset=self.graphics_2, palette=palette.get_subpalette(7))
                image.save(image_file, "png")

        # Write names
        with resource_open("WindowGraphics/flavor_names", "txt", True) as f:
            for asm_pointer_offset in FLAVOR_NAME_ASM_POINTER_OFFSETS:
                print(self.flavor_names[asm_pointer_offset], file=f)

    def read_from_project(self, resource_open):
        # Read graphics. Just use the first of each image.
        with resource_open("WindowGraphics/Windows1_0", "png") as image_file:
            image = open_indexed_image(image_file)
            self.graphics_1.from_image(image=image,
                                       arrangement=ARRANGEMENT_1,
                                       palette=self.flavor_palettes[0])

        with resource_open("WindowGraphics/Windows2_0", "png") as image_file:
            image = open_indexed_image(image_file)
            self.graphics_2.from_image(image=image,
                                       arrangement=ARRANGEMENT_2,
                                       palette=self.flavor_palettes[0].get_subpalette(7))

        # Read pals from Windows1 of each flavor.
        # Read subpal 7 from Windows2 of each flavor.
        for i, palette in enumerate(self.flavor_palettes):
            # Read all the palette data from Windows1
            with resource_open("WindowGraphics/Windows1_" + str(i), "png") as image_file:
#.........这里部分代码省略.........
开发者ID:LittleCube13,项目名称:CoilSnake,代码行数:101,代码来源:WindowGraphicsModule.py

示例15: __init__

 def __init__(self):
     self.minitiles = EbGraphicTileset(num_tiles=896, tile_width=8, tile_height=8)
     self.arrangements = [None for i in range(1024)]
     self.collisions = [None for i in range(1024)]
     self.palettes = []
开发者ID:Lyrositor,项目名称:CoilSnake,代码行数:5,代码来源:map_tilesets.py


注:本文中的coilsnake.model.eb.graphics.EbGraphicTileset类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。