本文整理汇总了Python中background.Background.setSpeed方法的典型用法代码示例。如果您正苦于以下问题:Python Background.setSpeed方法的具体用法?Python Background.setSpeed怎么用?Python Background.setSpeed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类background.Background
的用法示例。
在下文中一共展示了Background.setSpeed方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from background import Background [as 别名]
# 或者: from background.Background import setSpeed [as 别名]
#.........这里部分代码省略.........
# Number of Player Health
self.health = self.spaceship.getHitPoints()
# Kill Points
self.kills = 0
# Display the health
self.health_color = (255,255,255)
self.health_x = self.width/2
self.health_y = self.height - 30
# Display the Score
self.score_color = (0,150,0)
self.score_x = 20
self.score_y = 50
return
def evolve(self, keys, newkeys, buttons, newbuttons, mouse_position):
self.bg.update() # Update Background
if pygame.K_w in keys:
self.spaceship.setHitPoints(10)
self.spaceship.setWidth(225)
self.spaceship.setHeight(75)
self.spaceship.setImage('pelican_250x99.png')
self.spaceship.setName('Pelican')
self.spaceship_speed = 15
self.health = self.spaceship.getHitPoints()
self.bullet_sound = self.pelican_shoot
self.bg.setSpeed(-20)
if pygame.K_LEFT in keys:
self.spaceship.moveLeft(self.spaceship_speed)
if pygame.K_RIGHT in keys:
self.spaceship.moveRight(self.spaceship_speed,self.upper_limit)
if pygame.K_UP in keys:
self.spaceship.moveUp(self.spaceship_speed)
if pygame.K_DOWN in keys:
self.spaceship.moveDown(self.spaceship_speed,self.height)
if self.spaceship.getAlive() == True: # If space ship is alive, then
# it can fire.
if pygame.K_SPACE in newkeys:
self.bullet_sound.play()
self.bullets.append(self.spaceship.fire(self.bullet_width,
self.bullet_height,
self.bullet_color))
if pygame.K_q in newkeys:
print "PRESSED Q"
pygame.quit()
return
if pygame.K_r in keys:
print "GAME RESTARTED"
self.__init__(1024, 768, 30)
return
if random.randint(1, self.frame_rate/2) == 1: