本文整理汇总了Python中level.Level.start方法的典型用法代码示例。如果您正苦于以下问题:Python Level.start方法的具体用法?Python Level.start怎么用?Python Level.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类level.Level
的用法示例。
在下文中一共展示了Level.start方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Game
# 需要导入模块: from level import Level [as 别名]
# 或者: from level.Level import start [as 别名]
class Game(object):
def next_level(self):
self.current_level = Level(self.current_level.level_num + 1, self)
self.current_level.start()
def main(self, screen):
self.screen = screen
clock = pygame.time.Clock()
pygame.mixer.init()
pygame.mixer.music.load("resources/music/music.mp3")
pygame.mixer.music.set_volume(0.5)
self.current_level = Level(1, self)
self.current_level.start()
pygame.mixer.music.play(-1)
while 1:
dt = clock.tick(30)
for event in pygame.event.get():
if event.type == pygame.QUIT:
return
if (event.type == pygame.KEYDOWN and
event.key == pygame.K_ESCAPE):
return
self.current_level.update(dt / 1000.)
示例2: _get_level_node
# 需要导入模块: from level import Level [as 别名]
# 或者: from level.Level import start [as 别名]
def _get_level_node(self, group_node):
assert self._lock.locked()
name = "level"
if group_node.has_child(name):
return group_node.get_child(name)
# Obviously a level factory based on app id, someday...
level_node = Level()
level_node.pm_lic_register()
level_node.configure({"parent": group_node, "name": name})
level_node.start()
return level_node
示例3: Main
# 需要导入模块: from level import Level [as 别名]
# 或者: from level.Level import start [as 别名]
class Main(ShowBase, DirectObject):
def __init__(self):
ShowBase.__init__(self)
# Set the frame rate lock
# We need to set globalClock rate to 30' because it looks
# like the AI is affected by the frame rate.
# the higher the rate the faster they move depending on
# your pc.
globalClock.setMode(ClockObject.MLimited)
globalClock.setFrameRate(30)
self.win.setClearColor(Vec4(0.12,0.43,0.18,1))
self.disableMouse()
self.player = Player(self)
self.enemyList = []
self.maxEnemyCount = 15
self.itemList = []
self.maxItemCount = 4
self.level = Level()
self.enemyParent = render.attachNewNode("EnemyParent")
self.enemyParent.setH(180)
self.enemyStrength = 0
self.itemParent = render.attachNewNode("ItemParent")
self.mouse = Mouse(self.level.planeNP)
random.seed()
self.gameStarted = False
# Setup Gui
self.mainMenu = MainScreen()
self.mainMenu.show()
self.highscore = Highscore()
# Menu events
self.accept("escape", self.quit)
self.accept("MainMenu_start", self.start)
self.accept("Highscore_show", self.highscore.show)
self.accept("MainMenu_quit", self.quit)
self.accept("Highscore_back", self.mainMenu.show)
# ingame events
self.accept("killEnemy", self.removeEnemy)
self.accept("pickedUpHealth", self.removeItem)
self.accept("pickedUpWeapon", self.removeItem)
# Start everything needed to play the game
def start(self):
self.gameStarted = True
self.level.start()
self.player.start(self.level.startPos, self.mainMenu.getPlayername())
self.taskMgr.add(self.world, "MAIN TASK")
self.accept("escape", self.stop)
self.AiWorld = AIWorld(render)
self.taskMgr.add(self.AIUpdate, "UPDATEAI")
# When the game stops, we do some cleanups
def stop(self):
self.level.stop()
self.highscore.setPoints(self.player.name, self.player.points)
self.player.stop()
tempIDList = []
for enemy in self.enemyList:
tempIDList.append(enemy.id)
for enemyID in tempIDList:
self.removeEnemy(enemyID)
tempIDList = []
for item in self.itemList:
tempIDList.append(item.id)
for itemID in tempIDList:
self.removeItem(itemID)
self.taskMgr.remove("MAIN TASK")
self.mainMenu.show()
self.accept("escape", self.quit)
def quit(self):
if self.appRunner:
self.appRunner.stop()
else:
exit(0)
def spawnEnemy(self):
if len(self.enemyList) > self.maxEnemyCount: return False
enemy = Enemy(self)
x = self.player.model.getX()
y = self.player.model.getY()
while (x > self.player.model.getX() - 4.5 and x < self.player.model.getX() + 4.5):
x = random.uniform(-9, 9)
while (y > self.player.model.getY() - 4.5 and y < self.player.model.getY() + 4.5):
y = random.uniform(-9, 9)
position = VBase2(x, y)
enemy.start(position, self.enemyParent)
enemy.makeAi()
self.player.addEnemyDmgEvent(enemy.id)
self.enemyList.append(enemy)
return True
def removeEnemy(self, enemyID):
#.........这里部分代码省略.........