Exemple #1
0
def draw_surface_on_fdd(surface: pygame.Surface, flipdotdisplay):
    """Draw the surface onto the display. You need to invoke show()
    afterwards to make it visible. Black pixels (rgb 0,0,0) are considered
    black and turned off, other colors are considered pixels turned on.
    The clipping area of the  surface can be modified to draw only part
    of the surface. A demo application is available in
    demos.PygameSurfaceDemo."""
    cx, cy, cw, ch = surface.get_clip()
    for y in range(ch):
        for x in range(cw):
            r, g, b, a = surface.get_at((cx + x, cy + y))
            ison = not (r == g == b == 0)
            flipdotdisplay.px(x, y, ison)
Exemple #2
0
    def draw(self, screen: pygame.Surface, view_rect):
        # pygame seems to just set coordinates to 0 if rect is outside of screen and you try and blit it?
        # so ensure only visible portion of window onscreen is drawn
        r = screen.get_rect().clip(self.rect)

        smart_draw(
            screen, self.background
            if not self._mouseover else self.background_mouseover, r)

        # don't let children draw outside of bounds
        clipping_rect = screen.get_clip()
        screen.set_clip(r)

        # draw children
        super().draw(screen, view_rect)

        # restore screen as we found it
        screen.set_clip(clipping_rect)
Exemple #3
0
    def draw(self, destination: pg.Surface):
        center_x, center_y = self.center.ints()
        self.board_texture.draw(destination, center_x, center_y)
        coords = self.get_current_coords()
        x, y = coords.ints()

        prev_clip = destination.get_clip()
        destination.set_clip(self.get_rect())

        if self._can_hit_player():
            self.heart_texture.draw(destination, x, y)
        else:
            self.hit_heart_texture.draw(destination, x, y)

        with self.sprites:
            for sprite in self.sprites:
                sprite.draw(destination)
        destination.set_clip(prev_clip)
        with self.unrestricted_sprites:
            for sprite in self.unrestricted_sprites:
                sprite.draw(destination)