本文整理汇总了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()
示例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()
示例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)
示例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)