本文整理汇总了Python中map.Map.updateLevel方法的典型用法代码示例。如果您正苦于以下问题:Python Map.updateLevel方法的具体用法?Python Map.updateLevel怎么用?Python Map.updateLevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类map.Map
的用法示例。
在下文中一共展示了Map.updateLevel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Editor
# 需要导入模块: from map import Map [as 别名]
# 或者: from map.Map import updateLevel [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)
#.........这里部分代码省略.........
示例2: main
# 需要导入模块: from map import Map [as 别名]
# 或者: from map.Map import updateLevel [as 别名]
def main(arg):
f = file(arg,'r')
clock = pygame.time.Clock()
bullets = []
#init Map(grid, money, score, lives) depending on level
level = Map(f, 200, 0, 20)
level.popGrid(f)
level.drawMap()
exswitch = False
exswitch2 = False
startswitch = False
helpswitch = False
returnswitch = False
towerArray = []
minions = []
t_minions = 1
# run the game loop
while True:
gswitch = pygame.key.get_pressed()[K_g]
cswitch = pygame.key.get_pressed()[K_c]
pswitch = pygame.key.get_pressed()[K_p]
while level.bool is True and level.lives is not 0:
if(t_minions <= 10):
minions.append(Minions(level))
level.moveX(minions)
t_minions = t_minions + 1
else:
mousex, mousey = pygame.mouse.get_pos()
#print("MOUSE",mousex,mousey)
level.moveX(minions)
#level.live_out()
#level.score_out()
level.updateLevel()
level.updateLives()
level.updateScore()
level.updateMoney()
#level.money_out()
#level.blit_update()
if(not minions):
level.bool = False
level.level = level.level + 1
level.moveX([])
level.updateLevel()
level.updateLives()
level.updateScore()
level.updateMoney()
t_minions = 1
print("success")
for x in range(len(minions)):
print(minions[x].HP)
print('\n')
for x in minions:
for y in towerArray:
if(y.pingTower(x) is True):
level.bulletShoot(x,y)
if(y.damMini(x) is True):
level.score = level.score + x.score
level.updateScore()
#level.score_out()
level.money = level.money + x.value
#level.updateMoney()
try:
minions.remove(x)
except ValueError:
pass
print("LEVELmoney", level.money)
#break
break
level.blit_update()
if(level.lives is 0):
fonts = FontTemplate(('arial', 15))
rect = pygame.Rect(level.screenWidth/2,level.screenHeight/2,300,150)
pygame.draw.rect(level.windowSurface, constants.RED, rect)
fonts.Draw(level.windowSurface, 'arial', 12, 'YOU SUCK!! (Main Menu to return)', rect, constants.WHITE, 'center', 'center', True)
level.blit_update()
if(level.level is 10):
fonts = FontTemplate(('arial', 15))
rect = pygame.Rect(level.screenWidth/2,level.screenHeight/2,300,150)
pygame.draw.rect(level.windowSurface, constants.GREEN, rect)
fonts.Draw(level.windowSurface, 'arial', 12, 'CONGRATS,YOU STILL SUCK! :)', rect, constants.WHITE, 'center', 'center', True)
level.blit_update()
if(gswitch == 1):
level.drawGrid()
level.drawRange(towerArray)
if(cswitch == 1):
thing = True
level.drawMap()
for event in pygame.event.get():
if(exswitch is True and event.type is pygame.MOUSEBUTTONDOWN):
mousex, mousey = pygame.mouse.get_pos()
cord = level.getGridCord(mousex,mousey)
temporary = Tower(1)
#.........这里部分代码省略.........