當前位置: 首頁>>代碼示例>>Python>>正文


Python Spider.getSprite方法代碼示例

本文整理匯總了Python中spider.Spider.getSprite方法的典型用法代碼示例。如果您正苦於以下問題:Python Spider.getSprite方法的具體用法?Python Spider.getSprite怎麽用?Python Spider.getSprite使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在spider.Spider的用法示例。


在下文中一共展示了Spider.getSprite方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from spider import Spider [as 別名]
# 或者: from spider.Spider import getSprite [as 別名]
	def __init__(self, _engine):
		super(Scene, 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._actual = []
		self._level = utils.loadLevel('data/level.dat')
		self._map = Map(_engine, self, self._level)
		self._minimap = Minimap(_engine, self._map)
		self._cursor = Cursor(_engine, self._map)
		self._creatureLayer = CreatureLayer(self._map, self._cursor) # Warstwa potworów
		self._map.addLayer('Creatures', 2, self._creatureLayer)
		self._map.addLayer('Missiles', 3, MissilesLayer(self._map)) # Warstwa pocisków(strzał, kuli ognia itp.)
		self._shadow = ShadowLayer(self._map)
		self._map.addLayer('Shadow', 5, self._shadow) # Mgła wojny
		self._monsters = []
		self._freeobjects = pygame.sprite.Group() # Wolne obiekty na scenie
		_counter = 0
		_start = 0
		# szukanie bohatera w lochu
		for l, storey in enumerate(self._level):
			for row in storey:
				for cell in row:
					if cell.getModifier() & field.MODIFIER_HERO:
						self._hero = hero.Hero(self._map, cell.getGrid() + (l,))
						self._hero.move((0, 0, 0))
						self._map.switchStorey(l)
						_start = l
						self._creatureLayer.add('hero', self._hero.getSprite(self._creatureLayer, 'hero'))
						break

		# szukanie potworów
		for l, storey in enumerate(self._level):
			for row in storey:
				for cell in row:
					if cell.getModifier() & field.MODIFIER_SPIDER:
						_monster = Spider(self._map, cell.getGrid() + (l,))
						self._monsters.append(('spider', _monster))
						if l == _start:
							self._creatureLayer.add('spider_' + str(_counter), _monster.getSprite(self._creatureLayer, 'spider_' + str(_counter)))
							self._actual.append(('spider_' + str(_counter), _monster))
							_monster.move((0, 0, 0))
							_counter += 1

					elif cell.getModifier() & field.MODIFIER_SKELETON:
						_monster = Skeleton(self._map, cell.getGrid() + (l,))
						self._monsters.append(('skeleton', _monster))
						if l == _start:
							self._creatureLayer.add('skeleton_' + str(_counter), _monster.getSprite(self._creatureLayer, 'skeleton_' + str(_counter)))
							self._actual.append(('skeleton_' + str(_counter), _monster))
							_monster.move((0, 0, 0))
							_counter += 1

					elif cell.getModifier() & field.MODIFIER_MAGE:
						_monster = Mage(self._map, cell.getGrid() + (l,))
						self._monsters.append(('mage', _monster))
						if l == _start:
							self._creatureLayer.add('mage_' + str(_counter), _monster.getSprite(self._creatureLayer, 'mage_' + str(_counter)))
							self._actual.append(('mage_' + str(_counter), _monster))
							_monster.move((0, 0, 0))
							_counter += 1

					elif cell.getModifier() & field.MODIFIER_TROLL:
						_monster = Troll(self._map, cell.getGrid() + (l,))
						self._monsters.append(('troll', _monster))
						if l == _start:
							self._creatureLayer.add('troll_' + str(_counter), _monster.getSprite(self._creatureLayer, 'troll_' + str(_counter)))
							self._actual.append(('troll_' + str(_counter), _monster))
							_monster.move((0, 0, 0))
							_counter += 1

		if not self._hero:
			raise Exception('Brak bohatera w lochu!?')

		self._statusbar = StatusBar(_engine, self._hero) # pasek życia/many itp. / statusu
		self.inventory = Inventory(_engine, self._hero, self._hero.inventory, self._freeobjects)
		self.chestitems = ChestItems(_engine, self._hero, self._freeobjects)
		self._submodules = (self._map, self._minimap, self._statusbar, self.inventory, self.chestitems, self._cursor)
		self._play = True
		self._refresh = True
開發者ID:Neverous,項目名稱:ii-python11,代碼行數:83,代碼來源:scene.py


注:本文中的spider.Spider.getSprite方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。