当前位置: 首页>>代码示例>>Python>>正文


Python Map.draw方法代码示例

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

开发者ID:Legilmoon,项目名称:Boats,代码行数:31,代码来源:Game.py

示例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()
开发者ID:Harris64,项目名称:Clementine,代码行数:66,代码来源:Game.py


注:本文中的Map.draw方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。