コード例 #1
0
ファイル: logic.py プロジェクト: cflavio/yorg
 def sign_cb(parent):
     text = '\n\n'.join(ThanksNames.get_thanks(3, 4))
     txt = OnscreenText(text, parent=parent, scale=.2, fg=(0, 0, 0, 1),
                        pos=(.245, 0))
     bounds = lambda: txt.get_tight_bounds()
     while bounds()[1].x - bounds()[0].x > .48:
         scale = txt.getScale()[0]
         # NB getScale is OnscreenText's meth; it doesn't have swizzle
         txt.setScale(scale - .01, scale - .01)
     bounds = txt.get_tight_bounds()
     height = bounds[1].z - bounds[0].z
     txt.set_z(.06 + height / 2)
コード例 #2
0
ファイル: logic.py プロジェクト: b2220333/yorg
 def sign_cb(parent):
     text = '\n\n'.join(ThanksNames.get_thanks(3, 4))
     txt = OnscreenText(text, parent=parent, scale=.2, fg=(0, 0, 0, 1),
                        pos=(.245, 0))
     bounds = lambda: txt.get_tight_bounds()
     while bounds()[1].x - bounds()[0].x > .48:
         scale = txt.getScale()[0]
         # NB getScale is OnscreenText's meth; it doesn't have swizzle
         txt.setScale(scale - .01, scale - .01)
     bounds = txt.get_tight_bounds()
     height = bounds[1].z - bounds[0].z
     txt.set_z(.06 + height / 2)
コード例 #3
0
    async def get_hit(self, bullet_type=None):
        if not self.root:
            return

        self.hp -= 1
        if self.hp < 0:
            # Score gain flies off.
            scale = math.sqrt(self.score_gain) / 25.0
            base.add_score(self.score_gain)
            text = OnscreenText(str(self.score_gain),
                                font=base.gui.font,
                                parent=base.render,
                                scale=scale,
                                fg=(1, 1, 1, 1))
            text.set_light_off(True)
            text.set_z(10)
            text.set_pos(self.root.get_pos())
            text.set_depth_test(False)
            dir = base.player.root.get_x() - self.root.get_x()
            if dir == 0:
                dir = choice((-1, 1))
            if dir < 5:
                dir *= 5 / abs(dir)
            text.posInterval(
                1.0,
                self.root.get_pos() +
                (-dir, base.player.speed.y * 0.6, 0)).start()
            text.scaleInterval(1.0, scale * 2).start()
            text.set_transparency(1)
            Sequence(Wait(0.25),
                     text.colorScaleInterval(0.75, (1, 0, 0, 0))).start()
            self.die()
        else:
            self.root.set_color_scale((1, 0, 0, 1))
            await WaitInterval(0.1)
            if self.root:
                self.root.clear_color_scale()