本文整理汇总了Python中Map.draw方法的典型用法代码示例。如果您正苦于以下问题:Python Map.draw方法的具体用法?Python Map.draw怎么用?Python Map.draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Map
的用法示例。
在下文中一共展示了Map.draw方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1:
# 需要导入模块: import Map [as 别名]
# 或者: from Map import draw [as 别名]
continuer = 0
if event.type == MOUSEBUTTONDOWN:
posx,posy = event.pos
x = posx // grid.gridSize
y = posy // grid.gridSize
commandMap.change_state(x,y)
if event.type == KEYDOWN:
if event.key == K_DOWN:
for t in commandMap.tiles:
for ti in t:
if ti.state == 0:
ti.state = 1
elif ti.state== 1:
ti.state =0
flotte_1.tilt()
elif event.key == K_UP:
position_perso = position_perso.move((0,-3))
elif event.key == K_LEFT:
position_perso = position_perso.move((-3,0))
elif event.key == K_RIGHT:
position_perso = position_perso.move((3,0))
#dessin du fond, puis des cases, ensuite actualisation
grid.draw(window)
commandMap.draw(window, tile_set)
flotte_1.draw(window, tile_set)
pygame.display.flip()
示例2: Game
# 需要导入模块: import Map [as 别名]
# 或者: from Map import draw [as 别名]
class Game():
def __init__(self):
self.window = pyglet.window.Window(640, 320)
self.window.set_caption("Pedometer")
self.window.set_icon(pyglet.image.load("../res/graphics/icons/020-Accessory05.png"))
self.window.on_key_press = self.keyDown
self.window.on_key_release = self.keyUp
self.window.on_draw = self.render
self.fps = pyglet.clock.ClockDisplay()
self.map = Map()
pygame.init()
pygame.mixer.music.load("../res/audio/music/001-Battle01.mid")
pygame.mixer.music.play(-1, 0.0)
self.background = pyglet.image.load("../res/graphics/battlebacks/001-Grassland01.jpg")
self.character = Character(self, 0, 0)
self.steps = 0
self.label = pyglet.text.Label("Steps: 0", font_name = "Helvetica", font_size = 12, x = 10, y = self.window.height - 10, anchor_x = "left", anchor_y = "top", bold = True)
pyglet.gl.glEnable(pyglet.gl.GL_BLEND)
pyglet.gl.glBlendFunc(pyglet.gl.GL_SRC_ALPHA, pyglet.gl.GL_ONE_MINUS_SRC_ALPHA)
pyglet.clock.schedule_interval(self.update, 0.1 / 32)
pyglet.app.run()
def keyDown(self, symbol, modifiers):
if symbol == pyglet.window.key.UP:
self.character.startMoving(0)
elif symbol == pyglet.window.key.RIGHT:
self.character.startMoving(1)
elif symbol == pyglet.window.key.DOWN:
self.character.startMoving(3)
elif symbol == pyglet.window.key.LEFT:
self.character.startMoving(2)
def keyUp(self, symbol, modifiers):
if symbol == pyglet.window.key.UP:
if self.character.direction == 0:
self.character.stopMoving()
elif symbol == pyglet.window.key.RIGHT:
if self.character.direction == 1:
self.character.stopMoving()
elif symbol == pyglet.window.key.DOWN:
if self.character.direction == 3:
self.character.stopMoving()
elif symbol == pyglet.window.key.LEFT:
if self.character.direction == 2:
self.character.stopMoving()
def update(self, dt):
self.character.update()
self.label.text = "Steps: " + str(self.steps)
def render(self):
self.window.clear()
self.background.blit(0, 0)
self.map.draw()
self.character.render()
self.label.draw()
self.fps.draw()