本文整理汇总了Python中map.Map.getStorey方法的典型用法代码示例。如果您正苦于以下问题:Python Map.getStorey方法的具体用法?Python Map.getStorey怎么用?Python Map.getStorey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类map.Map
的用法示例。
在下文中一共展示了Map.getStorey方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Scene
# 需要导入模块: from map import Map [as 别名]
# 或者: from map.Map import getStorey [as 别名]
#.........这里部分代码省略.........
if submodule == self._map and event.type == MOUSEBUTTONUP and event.button == 1 and _pos: # upuszczanie przedmiotu
_field = self._map.getLayer('Fields').get(_pos, True)
if _field:
_field = _field.getLogic()
if _field and utils.distance(_field.getGrid()[:2], self._hero.getGrid()[:2]) <= 1:
for _obj in self._freeobjects:
if not _obj.attach(_field):
_obj.attach(_obj.getAttached())
else:
for _obj in self._freeobjects:
_obj.attach(_obj.getAttached())
if submodule == self.inventory and event.type == MOUSEBUTTONUP and event.button == 1 and _pos: # ↑
for _obj in self._freeobjects:
if not _obj.attach(self.inventory.getCell(_pos)):
_obj.attach(_obj.getAttached())
if submodule == self.chestitems and event.type == MOUSEBUTTONUP and event.button == 1 and _pos: # ↑
for _obj in self._freeobjects:
if not self.chestitems.opened or not _obj.attach(self.chestitems.getCell(_pos)):
_obj.attach(_obj.getAttached())
for _obj in self._freeobjects:
_obj.mouseEvent(event)
if event.type == MOUSEBUTTONDOWN and event.button == 3 and self._map.getRectangle().collidepoint(event.pos): # rzucanie czaru
self._hero.castSpell()
if event.type == MOUSEBUTTONDOWN and event.button == 1 and self._map.getRectangle().collidepoint(event.pos): # atak
self._hero.punch()
if self._hero.getGrid()[2] != self._map.getStorey(): # zmiana poziomu lochu
self._map.removeLayer('Missiles')
self._map.addLayer('Missiles', 3, MissilesLayer(self._map))
self._map.switchStorey(self._hero.getGrid()[2] - self._map.getStorey())
self._shadow.clear()
for _id, _ in self._actual:
self._creatureLayer.remove(_id)
self._actual = []
_counter = 0
_storey = self._map.getStorey()
for _name, _monster in self._monsters:
if _monster.getGrid()[2] == _storey:
self._creatureLayer.add(_name + '_' + str(_counter), _monster.getSprite(self._creatureLayer, _name + '_' + str(_counter)))
self._actual.append((_name + '_' + str(_counter), _monster))
_monster.move((0, 0, 0))
_counter += 1
else:
for key in hero.DIRECTION_KEYS:
if pygame.key.get_pressed()[key]:
self._hero.move(hero.KEY_MAP[key])
if self._hero.getDestination(): # przesuwanie mapy za bohaterem
x, y = self._hero.getPos()
_, _, w, h = self._map.getRectangle()
self._map.setShift((w / 2 - x, h / 2 - y))
if not self._hero.getLife(): # przegrana
utils.drawText(self.surface, "Game Over", 40, (255, 255, 255), (self._resx / 2, self._resy / 2))
self._play = False
self._engine.show(self.surface)
time.sleep(3)
示例2: Editor
# 需要导入模块: from map import Map [as 别名]
# 或者: from map.Map import getStorey [as 别名]
class Editor(engine.Module):
"""Edytor lochów."""
def __init__(self, _engine):
super(Editor, self).__init__(_engine)
self.side = utils.loadImage('data/gfx/side.png')
self._background = pygame.Surface((self._resx, self._resy))
self._background.blit(self.side, (self._resx - 232, self._resy - 1500))
self.surface = self._background.copy()
self._level = utils.loadLevel('data/level.dat') or [[[Field((x, y)) for x in xrange(MAP_SIZE)] for y in xrange(MAP_SIZE)]]
self._map = Map(_engine, self, self._level, True)
self._cursor = Cursor(_engine, self._map)
self._minimap = Minimap(_engine, self._map)
self._tiles = TilesGrid(_engine, self, self._map)
self._menu = EditorMenu(_engine, self)
self._submodules = (self._map, self._minimap, self._tiles, self._menu, self._cursor)
self._refresh = True
def screenUpdated(self):
"""Aktualizuje obrazy tła i submoduły."""
super(Editor, self).screenUpdated()
self._refresh = True
self._background = pygame.Surface((self._resx, self._resy))
self._background.blit(self.side, (self._resx - 232, self._resy - 1500))
self.surface = pygame.transform.smoothscale(self.surface, (self._resx, self._resy))
for submodule in self._submodules:
submodule.screenUpdated()
def setField(self, _l, _x, _y, _new):
"""Ustawia pole w pozycji (_x, _y, _l) [_l to poziom lochu] na _new."""
self._level[_l][_y][_x] = _new
self._map.getLayer('Fields').set((_x, _y), _new.getSprite(True))
def saveLevel(self):
"""Zapisuje poziom na dysku."""
return utils.saveLevel('data/level.dat', self._level)
def clearLevel(self):
"""Tworzy pusty poziom."""
self._level = [[[Field((x, y)) for x in xrange(MAP_SIZE)] for y in xrange(MAP_SIZE)]]
self._map = Map(self._engine, self, self._level, True)
self._cursor = Cursor(self._engine, self._map)
self._minimap = Minimap(self._engine, self._map)
self._tiles = TilesGrid(self._engine, self, self._map)
self._menu = EditorMenu(self._engine, self)
self._submodules = (self._map, self._minimap, self._tiles, self._menu, self._cursor)
self._refresh = True
def show(self):
"""Wyświetla edytor poziomów."""
try:
while self._engine.tick():
self.events = self._engine.events()
for event in self.events:
if event.type == QUIT:
raise engine.EngineQuit()
if event.type == KEYUP and event.key == K_ESCAPE:
self._engine.previousModule()
raise EditorQuit()
if event.type in (MOUSEMOTION, MOUSEBUTTONDOWN, MOUSEBUTTONUP):
if event.type == MOUSEBUTTONDOWN and event.button in (4, 5): # zmiana poziomów kółkiem myszy, dodawanie w razie potrzeby
_step = 0
if event.button == 4:
if self._map.getStorey() == 0 and len(self._level) < LEVEL_LIMIT:
self._level.insert(0, [[Field((x, y)) for x in xrange(MAP_SIZE)] for y in xrange(MAP_SIZE)])
self._map.updateLevel(self._level)
_step += 1
else:
if self._map.getStorey() + 1 == self._map.getStoreys() and utils.emptyStorey(self._level[-1]):
del self._level[-1]
self._map.updateLevel(self._level)
while len(self._level) > 1 and utils.emptyStorey(self._level[0]):
del self._level[0]
self._map.updateLevel(self._level)
_step -= 1
elif event.button == 5:
if self._map.getStorey() + 1 == self._map.getStoreys() and len(self._level) < LEVEL_LIMIT:
self._level.append([[Field((x, y)) for x in xrange(MAP_SIZE)] for y in xrange(MAP_SIZE)])
self._map.updateLevel(self._level)
else:
if self._map.getStorey() == 0 and utils.emptyStorey(self._level[0]):
del self._level[0]
self._map.updateLevel(self._level)
_step -= 1
while len(self._level) > 1 and utils.emptyStorey(self._level[-1]):
del self._level[-1]
self._map.updateLevel(self._level)
#.........这里部分代码省略.........