本文整理汇总了Python中Map.Map.update方法的典型用法代码示例。如果您正苦于以下问题:Python Map.update方法的具体用法?Python Map.update怎么用?Python Map.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Map.Map
的用法示例。
在下文中一共展示了Map.update方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Game
# 需要导入模块: from Map import Map [as 别名]
# 或者: from Map.Map import update [as 别名]
class Game(object):
def __init__(self):
self.TITLE = "TEST (by zeeisl)"
self.WIDTH = 800
self.HEIGHT = 600
self.controller = Controller()
# game things
self.char = Player("res//hero.png")
self.map = Map()
self.char1 = Character("res//hero.png", 100, 100, 32, 32)
def key_input(self, event):
self.controller.getButtonStates(event)
self.char.key_input(event)
def update(self, delta):
self.map.update()
self.char.update(self.char1)
self.char1.update()
def render(self, screen):
self.map.render(screen)
self.char.render(screen)
self.char1.render(screen)
示例2: OpenAnt
# 需要导入模块: from Map import Map [as 别名]
# 或者: from Map.Map import update [as 别名]
class OpenAnt(QApplication):
def __init__(self):
QApplication.__init__(self, sys.argv)
# Set the default background color to a darker grey.
self.setPalette(QPalette(self.palette().button().color(), QColor(192, 192, 192)))
self.window = MainWindow()
self.window.show()
self.window.start()
self.window.setWindowTitle('OpenAnt')
# Game timer, used in the gameloop FPS calculations.
self.game_timer = QTime()
self.game_timer.start()
# Draw map, set view to ground.
self.map = Map()
Globals.view = self.map.generateMap()
self.map.spawnAnts()
# Start the main loop.
self.gameLoop()
def gameLoop(self):
TICKS_PER_SECOND = 20
SKIP_TICKS = 1000 / TICKS_PER_SECOND
MAX_FRAMESKIP = 5
next_game_tick = self.getTickCount()
Globals.game_is_running = True
while Globals.game_is_running:
loops = 0
while self.getTickCount() > next_game_tick and loops < MAX_FRAMESKIP:
self.updateGame()
next_game_tick += SKIP_TICKS
loops += 1
interpolation = float(self.getTickCount() + SKIP_TICKS - next_game_tick) / float(SKIP_TICKS)
self.updateDisplay(interpolation)
def updateDisplay(self, interpolation):
#lerp away
if not 'nolerp' in sys.argv:
if self.map.yellowAnt.moving:
self.map.yellowAnt.lerpMoveSimple(interpolation)
Globals.glwidget.updateGL()
self.processEvents() # Let Qt process its events.
def getTickCount(self):
return self.game_timer.elapsed()
def updateGame(self):
self.map.update()
示例3: GameScene
# 需要导入模块: from Map import Map [as 别名]
# 或者: from Map.Map import update [as 别名]
class GameScene(Scene):
def _start(self):
self.map = Map("firstMap.map")
self.map.start(self.display)
def _draw(self, dt):
self.display.fill((255,255,255))
self.map.draw()
def _event(self, event):
self.map.event(event)
def _update(self, dt):
self.map.update(dt)
#Класс редактора карт
示例4: Map
# 需要导入模块: from Map import Map [as 别名]
# 或者: from Map.Map import update [as 别名]
gameover = False
map = Map(screen)
init_players(2, map.getRects())
while not gameover:
for event in pygame.event.get():
if event.type == pygame.QUIT:
gameover = True
if event.type == pygame.KEYDOWN:
keydown_players(event.key)
if event.type == pygame.KEYUP:
keyup_players(event.key)
screen.fill(black)
map.update(screen)
move_players(screen)
pygame.display.flip()
pygame.quit()
示例5: __init__
# 需要导入模块: from Map import Map [as 别名]
# 或者: from Map.Map import update [as 别名]
class World:
def __init__(self, mapdict):
self.mapdef = mapdict
self.cellmap = Map(mapdict)
self.gemgos = []
for gemgo in MGO.GEMGOTYPES:
self.gemgos += gemgo.place(self.cellmap)
def insertgeplayer(self, geplayer):
if geplayer not in self.gemgos:
self.gemgos.append(geplayer)
geplayer.updatevisible()
self.rendervisible(geplayer)
def removegeplayer(self, geplayer):
self.gemgos.remove(geplayer)
def rendervisible(self, geplayer, extrasprites=[]):
sprites = []
sprites += extrasprites
for gemgo in self.gemgos:
sprite = gemgo.sprite(geplayer)
if sprite is not None:
sprites.append(sprite)
visibleranges = ([],[])
for axis in [0, 1]:
if 2*geplayer.visibility + 5 >= self.cellmap.size[axis]:
visibleranges[axis].append((0, self.cellmap.size[axis]))
else:
rmin = (geplayer.position[axis] - geplayer.visibility - 2) % self.cellmap.size[axis]
rmax = (geplayer.position[axis] + geplayer.visibility + 2) % self.cellmap.size[axis]
if rmin < rmax:
visibleranges[axis].append((rmin, rmax))
else:
visibleranges[axis].append((rmin, self.cellmap.size[axis]))
visibleranges[axis].append((0, rmax))
surface = geplayer.surface
for rx in visibleranges[0]:
for ry in visibleranges[1]:
surface.set_clip(
rx[0]*TILESIZE, ry[0]*TILESIZE,
(rx[1]-rx[0])*TILESIZE, (ry[1]-ry[0])*TILESIZE)
regionsprites = sprites
for ix in range(rx[0]-1, rx[1]+1):
for iy in range(ry[0]-1, ry[1]+1):
regionsprites += self.cellmap.sprites((ix, iy))
if coords.mod((ix, iy), self.cellmap.size) not in geplayer.visibletiles:
sprites.append((images.NonVisible, coords.sum(coords.mul((ix, iy), TILESIZE), (-4,-4)), 100))
regionsprites.sort(key=lambda x: x[2])
for sprite in regionsprites:
surface.blit(*sprite[:2])
def update(self, geplayer):
"""Move the player by (x, y), move other fauna, update world surface around player"""
self.cellmap.update()
geplayer.updatevisible()
self.players = filter(lambda x: isinstance(x, MGO.GEPlayer), self.gemgos)
gemgosprites = []
for gemgo in self.gemgos:
gemgo.update(self)
self.rendervisible(geplayer, gemgosprites)
if geplayer.position in self.cellmap.burningtiles:
geplayer.score[collectables.CHOCOLATE] -= Map.CELLBURNINGCOST