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


Python Maze.create方法代码示例

本文整理汇总了Python中maze.Maze.create方法的典型用法代码示例。如果您正苦于以下问题:Python Maze.create方法的具体用法?Python Maze.create怎么用?Python Maze.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在maze.Maze的用法示例。


在下文中一共展示了Maze.create方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from maze import Maze [as 别名]
# 或者: from maze.Maze import create [as 别名]
def main():
    win = Window(fullscreen=True, visible=False)
    camera = Camera(win.width, win.height, (0, 0), 100)
    renderer = Renderer()
    maze = Maze()
    maze.create(50, 30, 300)
    keyboard = Keyboard()
    keyboard.key_handlers[key.ESCAPE] = win.close
    keyboard.key_handlers.update(camera.key_handlers)
    clock.schedule(maze.update)
    win.on_draw = lambda: renderer.on_draw(maze, camera, win.width, win.height)
    win.on_key_press = keyboard.on_key_press
    keyboard.print_handlers()
    win.set_visible()
    app.run()
开发者ID:msarch,项目名称:py,代码行数:17,代码来源:run.py

示例2: MazeOfKindred

# 需要导入模块: from maze import Maze [as 别名]
# 或者: from maze.Maze import create [as 别名]
class MazeOfKindred ():

	def __init__ (self, width, height, tile_size):
		
		self.width = width
		self.height = height
		self.tile_size = tile_size
		
		self.player = None
		self.maze = None
		
		self.enable_graphics = common.ENABLE_GRAPHICS
		self.enable_sound = common.ENABLE_SOUND

		self.fade_timer = None
		
		self.castle = None
		self.torches = None
		self.lights = None
		
	def load (self):
		
		pygame.display.set_caption('Maze of Kindred')
		
		self.screen = pygame.display.set_mode((common.GAME_WIDTH, common.GAME_HEIGHT))
		self.screen.convert_alpha()
		
		Loader.image('assets/opengameart/liberated pixel cup/castle.png', 'castle')
		Loader.image('assets/opengameart/nathanLovatoArt/sound.png', 'sound')
		Loader.image('assets/opengameart/nathanLovatoArt/no_sound.png', 'nosound')
		Loader.image('assets/opengameart/nathanLovatoArt/restart.png', 'restart')
		
		Loader.tileset('assets/opengameart/liberated pixel cup/princess.png', 'princess', 4, 9, 64, 64)
		Loader.tileset('assets/opengameart/liberated pixel cup/torch.png', 'torch', 1, 9, 48, 48)
		Loader.tileset('assets/opengameart/liberated pixel cup/flame.png', 'flame', 1, 12, 24, 36)
		Loader.tileset('assets/foundtimegames/dither_circle.png', 'light', 1, 5, 224, 224)
		Loader.tileset('assets/opengameart/liberated pixel cup/cement.png', 'maze_cement', 6, 3, 32, 32)
		Loader.tileset('assets/opengameart/liberated pixel cup/castlefloors_outside.png', 'maze_floor', 5, 4, 32, 32)
		
		Loader.audio('assets/opengameart/tozan/longbust.ogg', 'music')
		
	def create (self):
		
		self.player = Player(self.width/2, self.height - 2)
		self.player.offset_x = - 16
		self.player.offset_y = - 32
		
		self.maze = Maze(self.width, self.height, self.tile_size)
		self.maze.create()
		
		self.music = Loader.get('music')
		self.music.play(-1)
		
		if self.enable_sound:
			self.music.set_volume(0.2)
			
		else:
			self.music.set_volume(0)

		# black screen fade out
		self.fade_timer = Timer(2000)
		
		self.castle = Sprite(0, -16, 'castle')
		
		self.torches = []
		self.torches.append(Sprite(336, 80, 'torch'))
		self.torches.append(Sprite(480, 80, 'torch'))
		self.torches.append(Sprite(83, 140, 'flame'))
		
		self.lights = []
		self.lights.append(Sprite(240, 0, 'light'))
		self.lights.append(Sprite(384, 0, 'light'))
		self.lights.append(Sprite(-13, 58, 'light'))
		
		for t in self.torches:
			t.play('default', loop=True)
			
		for l in self.lights:
			l.play('default', loop=True)
		
		self.sound = Sprite(common.GAME_WIDTH - 80, 10, 'sound')
		self.nosound = Sprite(common.GAME_WIDTH - 80, 14, 'nosound')
		self.restart = Sprite(common.GAME_WIDTH - 70, 15, 'restart')
		
		self.fog = pygame.Surface((self.maze.image.get_width(), self.maze.image.get_height()))
		self.fog.set_colorkey((255, 0, 255))
		
	def draw (self):
		
		surface = self.maze.image.copy()
		self.fog.fill((0, 0, 0))
		
		x = common.GAME_WIDTH * 0.5 - self.player.x
		y = common.GAME_HEIGHT * 0.8 - self.player.y

		# normalize x and y
		if x > 0: x = 0
		elif x < -320: x = -320
		
		if y > 0: y = 0
#.........这里部分代码省略.........
开发者ID:thiagojobson,项目名称:Maze-Of-Kindred,代码行数:103,代码来源:main.py


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