Beispiel #1
0
    def __init__(self,
                 size,
                 offset,
                 border=1,
                 border_color='#FFFFFF',
                 color='#111111',
                 protected=False):
        super().__init__()
        self.protected = protected
        self.is_active = False

        self.text = ''
        self.font = pygame.font.Font('./fonts/space_invaders.ttf', 24)
        self.text_label = self.font.render(self.text, 1, (255, 255, 255))

        self.border = border
        self.bottom_image = pygame.Surface(size)
        self.bottom_image.fill(pygame.Color(border_color))

        width, height = size
        self.top_image = pygame.Surface(
            (width - 2 * border, height - 2 * border))
        self.top_image.fill(pygame.Color(color))

        self.rect = pygame.Rect(*offset, *size)
 def run(self):
     pygame.init()
     pygame.display.set_caption('Space Invaders')
     self.screen = pygame.display.set_mode(GAME_CONFIG['DISPLAY_SIZE'],
                                           pygame.DOUBLEBUF, 32)
     flags = pygame.SRCALPHA if USING_SDL2 else 0
     self.background = pygame.Surface(GAME_CONFIG['DISPLAY_SIZE'], flags)
     self.background.fill(pygame.Color(GAME_CONFIG['BACKGROUND_COLOR']))
Beispiel #3
0
   def load(self):
      child = im.cache.get(self.image)

      try:
         renpy.display.render.blit_lock.acquire()
         rv = child.convert()
         rv.set_colorkey(pygame.Color(self.key_color), pygame.RLEACCEL)
         rv = renpy.display.pgrender.copy_surface(rv, alpha=True)
      finally:
         renpy.display.render.blit_lock.release()

      return rv
    def __init__(self, size, offset, color=None):
        super().__init__()
        self.health = None

        # If color exists - create Surface
        if color is not None:
            self.image = pygame.Surface(size)
            self.image.fill(pygame.Color(color))
        else:
            self.image = None

        self.rect = pygame.Rect(*offset, *size)
Beispiel #5
0
    def addstr(self, y, x, text, attr=None):
        color = (255, 255, 31) if bool(attr) else (255, 255, 255)
        text_key = (text, color)

        text_render = self._font_render_cache.get(text_key, None)
        if not text_render:
            text_render = self.font.render(text, False, color, (0, 0, 0))
            self._font_render_cache[text_key] = text_render

        x1, y1 = self.ux * x, self.uy * y
        w, h = text_render.get_size()
        self.screen.fill(pygame.Color("black"), (x1, y1, w, h))
        self.screen.blit(text_render, (x1, y1))
Beispiel #6
0
    def __init__(self, websocket):

        self.websocket = websocket

        pygame.init()
        pygame.font.init()

        self.screen = pygame.display.set_mode((600, 480))
        self.background = pygame.Surface((600, 480))
        self.background.fill(pygame.Color('#111111'))
        pygame.display.set_caption('Authorization')

        self.create_objects()
Beispiel #7
0
 def erase(self):
     self.screen.fill(pygame.Color("black"))