models.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:kivy_rpg 作者: spinningD20 项目源码 文件源码
def add_image(self, base_path, file):
        if not os.path.exists(file):
            file = os.path.join(base_path, file)
        texture = Image(source=file).texture
        print('loading', file)
        texture.mag_filter = 'nearest'
        if texture is None:
            sys.exit('failed to locate image file %r' % file)

        id = self.firstgid
        th = self.tile_height + self.spacing
        tw = self.tile_width + self.spacing
        for j in range(texture.height // th):
            for i in range(texture.width // tw):
                x = (i * tw) + self.margin
                # convert the y coordinate to OpenGL (0 at bottom of texture)
                y = texture.height - ((j + 1) * th)
                tile = texture.get_region(x, y, self.tile_width, self.tile_height)
                self.tiles.append(Tile(id, tile, self))
                id += 1
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号