本文整理汇总了Python中Button.Button.update方法的典型用法代码示例。如果您正苦于以下问题:Python Button.update方法的具体用法?Python Button.update怎么用?Python Button.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Button.Button
的用法示例。
在下文中一共展示了Button.update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1:
# 需要导入模块: from Button import Button [as 别名]
# 或者: from Button.Button import update [as 别名]
#pygame.display.toggle_fullscreen()
pygame.display.quit()
pygame.display.init()
if fullscreen:
screen_size = last_size
screen = pygame.display.set_mode(screen_size, RESIZABLE)
else:
last_size = screen_size
screen_size = (screen_info.current_w, screen_info.current_h)
screen = pygame.display.set_mode(screen_size, FULLSCREEN)
fullscreen = not fullscreen
root.resize(width=screen_size[0], height=screen_size[1])
root.update_screen(screen)
else:
button.update(event)
widget1.update(event)
widget2.update(event)
widget3.update(event)
widget4.update(event)
"""
button1.update(event)
button2.update(event)
button3.update(event)
button4.update(event)
button5.update(event)
button6.update(event)
button7.update(event)
button8.update(event)
button9.update(event)
button10.update(event)
示例2: load
# 需要导入模块: from Button import Button [as 别名]
# 或者: from Button.Button import update [as 别名]
def load(self):
print 'Successfully loaded game'
self.window.clock.tick(30)
self.gameLoaded = True
while self.gameLoaded:
events = pygame.event.get()
for event in events:
if event.type == QUIT:
self.gameLoaded = False
self.Player.update(event)
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_s:
shop = Shop(self.window, self.Player).load()
self.click = pygame.mouse.get_pressed()
if self.Player.x > Localizer.dispWidth - 64:
self.Player.x += -5
elif self.Player.x < 0:
self.Player.x += 5
else:
self.Player.x += self.Player.velX
if self.Player.y > Localizer.dispHeight - 64:
self.Player.y += -5
elif self.Player.y < 0:
self.Player.y += 5
else:
self.Player.y += self.Player.velY
if self.Player.numCoins >= self.Player.maxCoins:
shop = Shop(self.window, self.Player).load()
self.window.gameDisplay.fill(Localizer.blue)
coinCollision = self.detectCollisions(self.yellowCoin.x,self.yellowCoin.y,self.yellowCoin.widthHeight[0],self.yellowCoin.widthHeight[1],self.Player.x,self.Player.y,self.Player.widthHeight[0],self.Player.widthHeight[1])
enemyCollision = self.detectCollisions(self.Enemy.x,self.Enemy.y,self.Enemy.widthHeight[0],self.Enemy.widthHeight[1],self.Player.x,self.Player.y,self.Player.widthHeight[0],self.Player.widthHeight[1])
if enemyCollision:
enemyCollide = self.Player.checkCollision(0, coinCollision, enemyCollision)
if enemyCollide:
self.Enemy.changePos()
else:
coinCollide = self.Player.checkCollision(self.yellowCoin.coinValue,coinCollision, enemyCollision)
if coinCollide:
self.yellowCoin.changePos()
self.yellowCoin.createObject(self.window.gameDisplay)
self.Enemy.createObject(self.window.gameDisplay)
self.Player.createObject(self.window.gameDisplay)
self.Enemy.update(self.Player.x, self.Player.y)
if self.Player.lives <= 0:
gameOver = Button("Game Over!", Localizer.dispWidth - 570, 250, 300, 60, Localizer.green, Localizer.bright_green, "exit")
self.Enemy.velInc = 0
self.Enemy.maxVel = 0
self.Enemy.minVel = 0
self.Player.maxVelX = 0
self.Player.maxVelY = 0
self.Player.minVelX = 0
self.Player.minVelY = 0
gameOver.update(self.window.gameDisplay)
if self.click[0] == 1:
if gameOver.hovering == True and gameOver.action == "exit":
self.gameLoaded = False
#Message("Player: " + Player.name,20,30,16)
Message("Coins: " + str(self.Player.numCoins),20,30,16,self.window.gameDisplay)
Message("Lives: " + str(self.Player.lives),20,50,16,self.window.gameDisplay)
pygame.display.flip()