當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。