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


Python Transform.sectorize方法代码示例

本文整理汇总了Python中Transform.sectorize方法的典型用法代码示例。如果您正苦于以下问题:Python Transform.sectorize方法的具体用法?Python Transform.sectorize怎么用?Python Transform.sectorize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Transform的用法示例。


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

示例1: __init__

# 需要导入模块: import Transform [as 别名]
# 或者: from Transform import sectorize [as 别名]
    def __init__(self):

        self.log = l.getLogger('model')

        self.conf = EC.EngineConfig.Instance()

        # A Batch is a collection of vertex lists for batched rendering.
        self.batch = pyglet.graphics.Batch()

        # Mapping from sector to a list of positions inside that sector.
        self.sectors = {}

        # Simple function queue implementation. The queue is populated with
        # _show_block() and _hide_block() calls
        self.queue = deque()

        self._materialFactory = Materials.MaterialFactory.Instance()

        # all shown blocks.
        self.visibleWorld = {}

        # This defines all the blocks that are currently in the world.
        try:
            (self.world, self.player) = Savegame.Savegame.load()
            # make blocks visible after loading
            for position in self.world.getBlockPositions():
                # sectorize blocks
                self.sectors.setdefault(Transform.sectorize(position, self.conf.getConfValue('sectorSize')), []).append(position)
                self.show_sector(0)
        except Exception, e:
            self.log.debug("Couldn't load a savegame. Creating new world ...")
            self.world = World.World()
            self.player = Player.Player()
            self.visibleWorld = {}
            self._initialize()
开发者ID:gentoomaniac,项目名称:Minecraft,代码行数:37,代码来源:Model.py

示例2: remove_block

# 需要导入模块: import Transform [as 别名]
# 或者: from Transform import sectorize [as 别名]
    def remove_block(self, position, immediate=True):
        """ Remove the block at the given `position`.

        Parameters
        ----------
        position : tuple of len 3
            The (x, y, z) position of the block to remove.
        immediate : bool
            Whether or not to immediately remove block from canvas.

        """
        
        # if block is dead hide it and remove it
        if not self.world.getBlock(position).isAlive():
            transparent = self._materialFactory.getMaterial(self.world.getBlock(position).getMaterial()).transparent
            if immediate:
                self.hide_block(position)
                
            self.world.removeBlock(position)
            self.sectors[Transform.sectorize(position, self.conf.getConfValue('sectorSize'))].remove(position)

            # show newly exposed blocks
            self.check_neighbors(position, transparent)

        else:
            self.world.getBlock(position).decreaseLife()
开发者ID:gentoomaniac,项目名称:Minecraft,代码行数:28,代码来源:Model.py

示例3: update

# 需要导入模块: import Transform [as 别名]
# 或者: from Transform import sectorize [as 别名]
    def update(self, dt):
        """ This method is scheduled to be called repeatedly by the pyglet
        clock.

        Parameters
        ----------
        dt : float
            The change in time since the last call.

        """
        self.model.process_queue()
        sector = Transform.sectorize(self._player.position, self.conf.getConfValue('sectorSize'))
        if sector != self.sector:
            self.model.change_sectors(self.sector, sector)
            if self.sector is None:
                self.model.process_entire_queue()
            self.sector = sector
        m = 8
        dt = min(dt, 0.2)
        for _ in xrange(m):
            self._update(dt / m)
开发者ID:gentoomaniac,项目名称:Minecraft,代码行数:23,代码来源:engine.py

示例4: add_block

# 需要导入模块: import Transform [as 别名]
# 或者: from Transform import sectorize [as 别名]
    def add_block(self, position, material, immediate=True):
        """ Add a block with the given `texture` and `position` to the world.

        Parameters
        ----------
        position : tuple of len 3
            The (x, y, z) position of the block to add.
        texture : list of len 3
            The coordinates of the texture squares. Use `tex_coords()` to
            generate.
        immediate : bool
            Whether or not to draw the block immediately.

        """
        self.world.addBlock(position, material)
        self.sectors.setdefault(Transform.sectorize(position, self.conf.getConfValue('sectorSize')), []).append(position)
        
        # hide newly hidden blocks
        transparent = self._materialFactory.getMaterial(self.world.getBlock(position).getMaterial()).transparent
        self.check_neighbors(position, transparent)
        
        if immediate:
            if self.exposed(position):
                self.show_block(position)
开发者ID:gentoomaniac,项目名称:Minecraft,代码行数:26,代码来源:Model.py


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