本文整理汇总了Python中background.Background.init方法的典型用法代码示例。如果您正苦于以下问题:Python Background.init方法的具体用法?Python Background.init怎么用?Python Background.init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类background.Background
的用法示例。
在下文中一共展示了Background.init方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TheApp
# 需要导入模块: from background import Background [as 别名]
# 或者: from background.Background import init [as 别名]
class TheApp(cocos.layer.Layer):
# If you want that your layer receives events
# you must set this variable to 'True',
# otherwise it won't receive any event.
is_event_handler = True
def __init__(self):
super(TheApp, self).__init__()
self.image = pyglet.resource.image('terrain_4.png')
self._background = Background()
self._objects = []
enemy = Enemy()
self._objects.append(enemy)
self._player = Player()
self._objects.append(self._player)
# call the "step" method every frame when the layer is active
self.schedule(self.step)
def on_enter(self):
super(TheApp, self).on_enter()
self._background.init()
for ob in self._objects:
ob.init()
def draw(self):
super(TheApp, self).draw()
self._background.draw()
for ob in self._objects:
ob.draw()
def step(self, dt):
for ob in self._objects:
ob.update(dt)
def on_key_press(self, symbol, modifiers):
if symbol == key.RIGHT:
self._player.setXVelocity(10)
if symbol == key.LEFT:
self._player.setXVelocity(-10)
def on_key_release(self, key, modifiers):
self._player.setXVelocity(0)
示例2: handle_speed
# 需要导入模块: from background import Background [as 别名]
# 或者: from background.Background import init [as 别名]
def handle_speed():
global actualLevel
time = pygame.time.get_ticks() // 1000
steep = time // gameConfigs["timeToIncreaseSpeed"]
print(steep)
if steep > actualLevel:
actualLevel += 1
if (Ship.speed <= gameConfigs["maxSpeed"]):
Ship.speedUp()
Enemy.speedUp()
Projectile.speedUp()
player = Player(screen)
EnemiesList.randomSpawn(screen)
Background.init(screen)
while run:
clock.tick(60)
screen.fill((0, 0, 0))
if len(EnemiesList.enemies)<=0:
screen.blit(fontLarge.render("Venceu!", True, (255,255,255)), (gameConfigs["width"]/2 - 240, gameConfigs["height"]/2 - 100))
elif player.lifes<=0:
pygame.mixer.music.load("assets/audios/gunshot2.ogg")
pygame.mixer.music.play()
screen.blit(fontLarge.render("Perdeu!", True, (255,255,255)), (gameConfigs["width"]/2 - 240, gameConfigs["height"]/2 - 100))
else:
Background.update(screen)