本文整理匯總了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()