コード例 #1
0
 def _draw_line(self, text, p, alpha):
     """Draw a menu line"""
     self._font.draw(text,
                     position=p,
                     color=gloss.Color(1, 1, 1, alpha),
                     letterspacing=0,
                     linespacing=0)
コード例 #2
0
 def draw(self):
     """Draw on screen"""
     angle = getattr(self, '_angle', 0.0)
     gloss.Sprite.draw(self,
                       scale=self._raw_scale * game.zoom,
                       rotation=angle,
                       origin=None,
                       color=gloss.Color(1, 1, 1, self._alpha))
コード例 #3
0
 def _draw_bottom_right_text(self, text, y):
     """Draw gray metrics"""
     self._font.draw(text,
                     scale=1,
                     position=self._presolution - PVector(y, 15),
                     color=gloss.Color(1, 1, 1, .5),
                     letterspacing=0,
                     linespacing=-25)
コード例 #4
0
 def draw(self):
     """Draw on screen"""
     gloss.Gloss.draw_box(
         position=(0, 0),
         width=game.resolution[0],
         height=game.resolution[1],
         color=gloss.Color(0, 0, 0, 1),
     )
コード例 #5
0
    def load_content(self):
        """Load images, create game objects"""
        self._font = gloss.SpriteFont(
            '/usr/share/fonts/truetype/freefont/FreeSans.ttf', 10)

        self._background_tiles = Tiles()
        self.orbit = Orbit()
        self._suns = [
            Sun(gcenter=GVector(100, -100)),
        ]
        self._satellites = [Satellite() for x in xrange(10)]
        for s in self._satellites:
            s.place_in_orbit(self._suns[0])
        self._circles = [
            Circle(),
        ]
        self._circles = []
        self._particles = []
        self._ship = Starship(GVector(-100, 100))
        self._ship.place_in_orbit(self._suns[0])
        self._ship_reflexes = [
            ShipReflex(self._ship, n, angle) for n, angle in (
                ('l', 90),
                ('t', 0),
                ('b', 180),
                ('r', -90),
            )
        ]

        self._bars = [
            HBar(self._ship,
                 'propellent',
                 .05,
                 gloss.Color(0, 1, 0, .6),
                 vmax=1500),
            HBar(self._ship,
                 'hull_temperature',
                 .40,
                 gloss.Color(1, 0, 0, .6),
                 vmax=1500),
        ]
        self._black_overlay = BlackOverlay()
        self._black_overlay.set_to_black()
        self._black_overlay.fade_in()
コード例 #6
0
 def _plot_vector(self, start, arrow, alpha=.5):
     """Plot a vector on the screen, applied to a starting position"""
     arrow *= 100
     end = start + arrow
     tip_r = arrow.orthonormal() - arrow.normalized()
     tip_l = arrow.orthonormal() * -1 - arrow.normalized()
     tip_r += end
     tip_l += end
     e = end.on_screen
     gloss.Gloss.draw_lines(
         [start.on_screen, e, tip_r.on_screen, e, tip_l.on_screen],
         color=gloss.Color(0, 1, 1, alpha),
         width=1,
         join=False)
コード例 #7
0
 def _plot_cross(self, start, alpha=.1):
     """Plot a cross on the screen"""
     size = 4
     nodes = (
         start,
         start + GVector(size, 0),
         start + GVector(-size, 0),
         start,
         start + GVector(0, size),
         start + GVector(0, -size),
     )
     gloss.Gloss.draw_lines([n.on_screen for n in nodes],
                            color=gloss.Color(1, 1, 0, alpha),
                            width=1,
                            join=False)
コード例 #8
0
    def update(self):

        alpha = self._alpha_animator.next()
        self._color = gloss.Color(1, 1, 1, alpha)
コード例 #9
0
 def __init__(self):
     self.gcenter = GVector(0, 0)
     self._orbit = ()
     self._color = gloss.Color(1, 1, 1, .2)
     self._alpha_animator = animator_directional(maxv=.2, step=.01)
     self._alpha_animator.next()