예제 #1
0
    def test_export_namespace(self):
        try:
            os.remove('/tmp/level.png')
        except:
            pass

        self.assertFileNotExists('/tmp/level.png')
        image.export_nametable(
            'fixtures/nerdynights/scrolling/SMBlevel.bin',
            'fixtures/nerdynights/scrolling/mario.chr',
            '/tmp/level.png')
        self.assertFileExists('/tmp/level.png')

        img = Image.open('/tmp/level.png')
        sprs, indexes = image.acquire_chr(img, optimize_repeated=False)
        sprite.length(sprs)
        self.assertEquals(1024, sprite.length(sprs))
        return  # TODO why?!
        nt_file = open('fixtures/nerdynights/scrolling/SMBlevel.bin')
        nt = nt_file.read()
        nt_file.close()
        nts = [ord(n) for n in nt]
        mario = sprite.load_sprites('fixtures/nerdynights/scrolling/mario.chr')
        for i in range(32):
            for j in range(32):
                self.assertSpriteEquals(
                    sprite.get_sprite(nts[i * j] + 256, mario),
                    sprite.get_sprite(i * j, sprs)
                )
        os.remove('/tmp/level.png')
예제 #2
0
    def test_export_namespace(self):
        try:
            os.remove('/tmp/level.png')
        except:
            pass

        self.assertFileNotExists('/tmp/level.png')
        image.export_nametable(
            'fixtures/nerdynights/scrolling/SMBlevel.bin',
            'fixtures/nerdynights/scrolling/mario.chr',
            '/tmp/level.png')
        self.assertFileExists('/tmp/level.png')
        
        img = Image.open('/tmp/level.png')
        sprs, indexes = image.acquire_chr(img, optimize_repeated=False)
        sprite.length(sprs)
        self.assertEquals(1024,sprite.length(sprs))
        return #TODO why?!
        nt_file = open('fixtures/nerdynights/scrolling/SMBlevel.bin')
        nt = nt_file.read()
        nt_file.close()
        nts = [ord(n) for n in nt]
        mario = sprite.load_sprites('fixtures/nerdynights/scrolling/mario.chr')
        for i in range(32):
            for j in range(32):
                self.assertSpriteEquals(
                    sprite.get_sprite(nts[i*j] + 256, mario),
                    sprite.get_sprite(i*j, sprs)
                )
        os.remove('/tmp/level.png')
예제 #3
0
def show_sprites(sprs):
    ENDC = '\033[0m'
    length = sprite.length(sprs)
    tiles = []
    for i in range(length):
        spr = get_printable_sprite(sprite.get_sprite(i, sprs))
        tiles.append(spr)
        if len(tiles) % 8 == 0:
            out = ''
            for t in tiles:
                for l in t:
                    out += l + ENDC
                out += '\n'
            tiles = []
            print out
예제 #4
0
파일: __init__.py 프로젝트: BmanisKing/Mine
def show_sprites(sprs):
    ENDC = '\033[0m'
    length = sprite.length(sprs)
    tiles = []
    for i in range(length):
        spr = get_printable_sprite(sprite.get_sprite(i, sprs))
        tiles.append(spr)
        if len(tiles) % 8 == 0:
            out = ''
            for t in tiles:
                for l in t:
                    out += l + ENDC
                out += '\n'
            tiles = []
            print (out)
예제 #5
0
 def test_sprite_length(self):
     length = sprite.length(self.bin)
     self.assertEquals(512, length)