Ejemplo n.º 1
0
class Sylwester(Scene):
    def __init__(self):
        super(Sylwester, self).__init__()

        anim = Picolo('assets/picolos.png')
        self.callbacks1 = Callbacks1(self)

        self.layer1_init()
        self.layer2_init()

        self.do(
            Repeat(
                CallFunc(self.layer1_reset) + CallFunc(self.layer1_start) +
                Delay(20) + CallFunc(self.layer2_reset) +
                CallFunc(self.layer2_start) + Delay(20)))

    def layer1_init(self):
        w, h = director.get_window_size()

        self.group1 = []
        self.l1 = Layer()
        self.l1.visible = False

        self.xds = Layer()

        for i in range(0, 18):
            xd = Line("xD " * 20, 50, (255, 255, 0, 255), w // 2, h // 2,
                      "November", pyglet.font.Text.CENTER,
                      pyglet.font.Text.CENTER)
            xd.do(Repeat(CallFunc(xd.update_line) + Delay(0.05)))
            self.xds.add(xd)

        # self.xds.do(R_Blink(10, 2))
        self.xds.do(Repeat(RotateBy(-20, 0.4)))
        self.xds.do(R_ScaleFromTo(1.2, 0.9, 0.3))
        self.l1.add(self.xds)

        self.picolos = Layer()

        for i in range(0, 370, 10):
            s = cocos.sprite.Sprite(Picolo.animation,
                                    position=(w // 2, h // 2),
                                    scale=0.8)
            s.rotation = i
            s.position = (w // 2, h // 2)
            if i == 0:
                s.scale = 0.1
            s.visible = i == 0
            self.group1.append(s)
            self.picolos.add(s)

        self.l1.add(self.picolos)

        x, y = 0 - 300, h // 2
        self.wixa1 = get_sprite('wixapol-full.png', x, y)
        self.wixa1.scale = 0.3
        self.wixa1.do(R_Blink(20, 3))
        self.l1.add(self.wixa1)

        x, y = w + 300, h // 2
        self.wixa2 = get_sprite('wixapol-full.png', x, y)
        self.wixa2.scale = 0.3
        self.wixa2.do(R_Blink(20, 3))
        self.l1.add(self.wixa2)

        self.l1.visible = False
        self.add(self.l1)

    def layer1_start(self):
        self.l1.visible = True
        self.l2.visible = False
        self.l1.resume()
        self.l2.pause()

        self.do(
            CallFunc(self.callbacks1.scale_picolo) + Delay(1) +
            CallFunc(self.callbacks1.duplicate_picolo) +
            CallFunc(self.callbacks1.center_logos))

    def layer1_reset(self):
        w, h = director.get_window_size()

        for picolo in self.group1:
            picolo.visible = False

        for k, xd in enumerate(self.xds.get_children()):
            xd.rotation = k * 10

        self.picolos.stop()
        self.picolos.rotation = 0

        self.group1[0].visible = True
        self.group1[0].scale = 0.1

        self.wixa1.position = -300, h // 2
        self.wixa2.position = w + 300, h // 2

        self.wixa1.opacity = self.wixa2.opacity = 255
        self.wixa1.scale = self.wixa2.scale = 0.3

    def layer2_init(self):
        w, h = director.get_window_size()

        self.l2 = Layer()
        self.l2.visible = False

        self.stallone = Layer()

        bg = get_sprite('jungle.jpg', w // 2, h // 2)
        bg.scale = 1.3
        bg.do(R_ScaleFromTo(2, 1.3, 0.1))
        self.stallone.add(bg)

        s = get_sprite('stallone.png', w // 2, h // 2 + 100)
        s.scale = 1.35
        s.do(Repeat(Shaky3D(randrange=2, grid=(32, 24), duration=5)))
        s.do(R_ScaleFromTo(2, 1.3, 0.2))
        self.stallone.add(s)

        self.l2.add(self.stallone)

        txt = Line("TOTALNE           ",
                   100, (255, 255, 0, 255),
                   w // 2,
                   h // 2,
                   "November",
                   anchor_x=pyglet.font.Text.CENTER,
                   anchor_y=pyglet.font.Text.CENTER)
        txt.do(Repeat(CallFunc(txt.update_line) + Delay(0.1)))
        txt.transform_anchor = w // 2, h // 2
        txt.position = -600, 0
        txt.rotation = 60
        self.l2.add(txt)

        txt = Line("ZNISZCZENIE       ",
                   100, (255, 255, 0, 255),
                   w // 2,
                   h // 2,
                   "November",
                   anchor_x=pyglet.font.Text.CENTER,
                   anchor_y=pyglet.font.Text.CENTER)
        txt.do(Repeat(CallFunc(txt.update_line) + Delay(0.1)))
        txt.transform_anchor = w // 2, h // 2
        txt.position = 600, 0
        txt.rotation = -60
        self.l2.add(txt)

        wixa = get_sprite('wixapol-full.png', 200, 250)
        wixa.scale = 0.3
        wixa.do(R_Blink(20, 3))
        self.l2.add(wixa)

        wixa = get_sprite('wixapol-full.png', w - 200, 250)
        wixa.scale = 0.3
        wixa.do(R_Blink(20, 3))
        self.l2.add(wixa)

        self.add(self.l2)

    def layer2_reset(self):
        pass

    def layer2_start(self):
        self.l2.visible = True
        self.l1.visible = False
        self.l1.pause()
        self.l2.resume()