Ejemplo n.º 1
0
 def draw(self):
     super(EngineBlock, self).draw()
     if self._active and not off_screen(self._body.position):
         offset = Vec2d(0, -BLOCK_SIZE)
         offset.rotate(self._body.angle + float(self.direction) / 2 * math.pi)
         points = [p + offset for p in self._shape.get_vertices()]
         draw_rect(ENGINE_FIRE.id, points, direction=self.direction)
Ejemplo n.º 2
0
 def draw(self):
     if off_screen(self._body.position):
         return
     if self.damage >= self.health:
         tex = self.img_destroyed.id
     elif self.damage > 0:
         tex = self.img_damaged.id
     else:
         tex = self.img.id
     draw_rect(tex, self._shape.get_vertices(), direction=self.direction)
Ejemplo n.º 3
0
    def draw(self):
        # TODO: Let's use particles. And lighting! Way more fun.

        p = adjust_for_cam(self._body.position)

        if off_screen(self._body.position):
            return

        gl.glEnable(gl.GL_TEXTURE_2D) # enables texturing, without it everything is white
        gl.glBindTexture(gl.GL_TEXTURE_2D, EXPLOSION_ANIM.id)
        gl.glEnable(gl.GL_BLEND)
        gl.glBlendFunc(gl.GL_SRC_ALPHA,gl.GL_ONE_MINUS_SRC_ALPHA);

        # TODO: more optimized to draw as one large batch
        gl.glBegin(gl.GL_QUADS)

        r = (self.radius + BLOCK_SIZE) * SPACE.scale
        for i, vert in enumerate([Vec2d(p.x - r, p.y - r),
                                  Vec2d(p.x + r, p.y - r),
                                  Vec2d(p.x + r, p.y + r),
                                  Vec2d(p.x - r, p.y + r),]):

            # TODO: This is really ugly, and a lot of shared code with the
            #       blocks. Let's write a draw_rect function to handle this
            #       with an optional animation option.

            x = (i // 2)
            if x == 0:
                x = FRAME_POSITIONS[int((20 - self.ticks) / 20. * ANIM_FRAMES)][0]
            else:
                x = FRAME_POSITIONS[int((20 - self.ticks) / 20. * ANIM_FRAMES)][0] + 1 / ANIM_COLUMNS
            y = ((i + 1) // 2) % 2
            if y == 0:
                y = FRAME_POSITIONS[int((20 - self.ticks) / 20. * ANIM_FRAMES)][1]
            else:
                y = FRAME_POSITIONS[int((20 - self.ticks) / 20. * ANIM_FRAMES)][1] + 1 / ANIM_ROWS

            gl.glTexCoord2f(x, y)
            gl.glVertex3f(vert.x, vert.y, 0)

        gl.glEnd()
Ejemplo n.º 4
0
 def draw(self):
     super(TractorBlock, self).draw()
     if self._active and not off_screen(self._tractor_body.position):
         draw_large_point(SHIELD_IMAGE.id, self._tractor_body.position, self.radius)