本文整理汇总了Python中background.Background.changeBackground方法的典型用法代码示例。如果您正苦于以下问题:Python Background.changeBackground方法的具体用法?Python Background.changeBackground怎么用?Python Background.changeBackground使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类background.Background
的用法示例。
在下文中一共展示了Background.changeBackground方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from background import Background [as 别名]
# 或者: from background.Background import changeBackground [as 别名]
#.........这里部分代码省略.........
self.player1.update(elapsedTime, self.background.group, self.background.exitGroup, self.background.damageGroup, self.background.groupList)
self.backgroundXMovementManager(self.player1, self.player2)
self.backgroundYMovementManager(self.player1, self.player2)
for torreta in self.background.levelMaker.torretas:
torreta.update(elapsedTime,self.background.group,[self.player1.X,self.player1.Y],self.background.xAdvance, self.background.yAdvance, self.player1, self.screenSize)
self.background.update(elapsedTime, self.player1.X, self.player1.Y)
"""
# DISTANCIA PERSONAJES (TEMPORAL)
if abs(self.player1.X - self.player2.X) >= self.screenSize[0]:
self.player2.X = self.player1.X
self.player2.Y = self.player1.Y
if abs(self.player1.Y - self.player2.Y) >= self.screenSize[1]:
self.player2.X = self.player1.X
self.player2.Y = self.player1.Y
#"""
#######PAUSA(con joystick)##################################
button = self.joystickList[0].get_button(8) #or self.joystickList[1].get_button(7)##
#button2 = self.joystickList[1].get_button(9) #or self.joystickList[1].get_button(7)##
if button:
self.pauseGame = True
pressedKey = pygame.key.get_pressed()
if pressedKey[K_TAB]:
self.pauseGame = True
#if button2:
# self.gameOver = True
###########CAMBIO_DE_ETAPA##################################
if self.player1.exitStage or self.player2.exitStage:
self.player1.exitStage = False
self.player2.exitStage = False
self.background.changeBackground()
self.player1.X = self.background.levelMaker.startXPosition
self.player1.Y = self.background.levelMaker.startYPosition
self.player2.X = self.background.levelMaker.startXPosition
self.player2.Y = self.background.levelMaker.startYPosition
#################GAME_OVER##################################
if self.player1.dead or self.player2.dead:
self.gameOver = True
# Dibuja en pantalla los sprites y el escenario
def render(self):
# Instancia de la ventana de pygame
screen = pygame.display.get_surface()
# Render a las instancias del nivel
self.background.render()
self.player2.render() #-----------------#
self.player1.render()
for torreta in self.background.levelMaker.torretas:
torreta.render()
# Brujula que apunta a otro player
if self.horizontalCompassNeeded or self.P1horizontalCompassNeeded:
if self.player2.Y <= -50 or self.player1.Y <= -50:
self.compass.image = self.compassImageUp
if self.player2.Y <= -50:
screen.blit(self.compass.image, (self.player2.X, 0))
else:
screen.blit(self.compass.image, (self.player1.X, 0))
if self.player2.Y >= self.screenSize[1] or self.player1.Y >= self.screenSize[1]:
示例2: __init__
# 需要导入模块: from background import Background [as 别名]
# 或者: from background.Background import changeBackground [as 别名]
#.........这里部分代码省略.........
# sprite.activada = True
# if (pygame.sprite.collide_rect(sprite,self.player2.sprite)):
# if(self.player2.color == sprite.color):
# sprite.activada = True
for sprite in self.background.group:
sprite.activada = False
self.player2.update(elapsedTime, self.background.group, self.background.exitGroup, self.background.damageGroup, self.background.itemsGroup, self.background.zGroup, self.background.groupList)#-----------------#
self.player1.update(elapsedTime, self.background.group, self.background.exitGroup, self.background.damageGroup, self.background.itemsGroup, self.background.zGroup, self.background.groupList)
self.backgroundXMovementManager(self.player1, self.player2)
self.backgroundYMovementManager(self.player1, self.player2)
for torreta in self.background.levelMaker.torretas:
torreta.update(elapsedTime,self.background.group,self.background.xAdvance, self.background.yAdvance, self.player1, self.player2,self.screenSize)
self.background.update(elapsedTime, self.player1.X, self.player1.Y)
"""
# DISTANCIA PERSONAJES (TEMPORAL)
if abs(self.player1.X - self.player2.X) >= self.screenSize[0]:
self.player2.X = self.player1.X
self.player2.Y = self.player1.Y
if abs(self.player1.Y - self.player2.Y) >= self.screenSize[1]:
self.player2.X = self.player1.X
self.player2.Y = self.player1.Y
#"""
###########CAMBIO_DE_ETAPA##################################
if self.player1.exitStage or self.player2.exitStage:
self.player1.exitStage = False
self.player2.exitStage = False
self.background.changeBackground()
self.backgroundImage = self.container.imageDictionary[self.background.backgroundKey]
self.backgroundImage = pygame.transform.scale(self.backgroundImage, (self.screenSize[0], self.screenSize[1]))
self.player1.X = self.background.levelMaker.startXPosition
self.player1.Y = self.background.levelMaker.startYPosition
self.player2.X = self.background.levelMaker.startXPosition
self.player2.Y = self.background.levelMaker.startYPosition
#################GAME_OVER##################################
if self.player1.dead or self.player2.dead:
self.gameOver = True
if self.player1.dead:
self.deadMessage = self.player1.deadMessage
else:
self.deadMessage = self.player2.deadMessage
# Dibuja en pantalla los sprites y el escenario
def render(self):
# Instancia de la ventana de pygame
screen = pygame.display.get_surface()
# Render a las instancias del nivel
screen.blit(self.backgroundImage, (0,0))
self.player1.render()
self.player2.render()
self.background.render()
for torreta in self.background.levelMaker.torretas:
torreta.render()