当前位置: 首页>>代码示例>>Python>>正文


Python Background.init方法代码示例

本文整理汇总了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)
开发者ID:CoderDojoZH,项目名称:workshops,代码行数:45,代码来源:the_app.py

示例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)
开发者ID:mateusKoppe,项目名称:space-battle,代码行数:33,代码来源:spaceBattle.py


注:本文中的background.Background.init方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。