Example #1
0
    def draw(self, surface: ut.Image) -> None:
        """Draw Explosion object on the surface"""
        if self.duration[0] <= 2:
            img_to_draw = self.img[self.duration[0]]
        elif self.duration[1] - self.duration[0] <= 3:
            img_to_draw = self.img[self.duration[0] - self.duration[1]]
        else:
            img_to_draw = self.img[3 + self.duration[0] % 2]

        if self.etype is ut.ExplosionType.CROSS:
            for x in range(self.esizex[0], self.esizex[1] + 1):
                if self.fbounds == ut.FieldBounds.RECT:
                    if x < 0 or x >= ut.BSIZE[0]:
                        continue
                elif self.fbounds == ut.FieldBounds.TORUS:
                    x = (x + ut.BSIZE[0]) % ut.BSIZE[0]
                draw_pos = (x * ut.TILE, self.pos[1] * ut.TILE)
                surface.blit(img_to_draw, draw_pos)

            for y in range(self.esizey[0], self.esizey[1] + 1):
                if self.fbounds == ut.FieldBounds.RECT:
                    if y < 0 or y >= ut.BSIZE[1]:
                        continue
                elif self.fbounds == ut.FieldBounds.TORUS:
                    y = (y + ut.BSIZE[0]) % ut.BSIZE[0]
                draw_pos = (self.pos[0] * ut.TILE, y * ut.TILE)
                surface.blit(img_to_draw, draw_pos)
        elif self.etype is ut.ExplosionType.CIRCLE:
            pass
Example #2
0
 def draw(self, surface: ut.Image) -> None:
     """Draw Spikes object on the surface"""
     draw_pos = (self.pos[0] * ut.TILE, self.pos[1] * ut.TILE)
     if self.is_activated:
         surface.blit(self.img[0], draw_pos)
     else:
         surface.blit(self.dimg[0], draw_pos)
Example #3
0
 def draw(self, surface: ut.Image) -> None:
     """Draw player on the surface"""
     draw_pos = (self.pos[0] * ut.TILE, self.pos[1] * ut.TILE)
     if self.bonus is None:
         surface.blit(self.img[int(self.draw_count)], draw_pos)
     else:
         # TODO: process player sprites correctly according to bonus
         surface.blit(self.limg[int(self.draw_count)], draw_pos)
     self.draw_count = (self.draw_count + ut.ANIMATION_ITER) % 2
Example #4
0
 def draw(self,
          surface: ut.Image,
          mouse_pos: ut.Coord,
          triggers: Optional[List[ut.Trigger]] = None) -> None:
     """Draw textbox on the given surface"""
     if self.is_pressed:
         text_surface = self.font.render(self.text, True, self.color_p)
     if self.includes(mouse_pos):
         text_surface = self.font.render(self.text, True, self.color_s)
     else:
         text_surface = self.font.render(self.text, True, self.color)
     surface.blit(text_surface, self.pos)
Example #5
0
    def draw(self, screen: ut.Image) -> None:
        """Draw all GUI objects"""
        mouse_pos = pygame.mouse.get_pos()
        screen.blit(self.back_img, (0, 0))
        screen.blit(self.menu_img, self.menu_pos)
        if self.gui:
            for gui in self.gui:
                gui.draw(screen, mouse_pos, self.triggers)

        screen.blit(self.cursor_img, mouse_pos)
Example #6
0
 def draw(self,
          surface: ut.Image,
          mouse_pos: ut.Coord,
          triggers: Optional[List[ut.Trigger]] = None) -> None:
     """Draw Button element on the given surface"""
     if self.is_pressed:
         if self.image_pressed:
             surface.blit(self.image_pressed, self.pos)
         else:
             surface.blit(self.image, self.pos)
     else:
         surface.blit(self.image, self.pos)
     if self.text:
         self.text.draw(surface, mouse_pos, triggers)
Example #7
0
    def draw(self, screen: ut.Image) -> None:
        """Draw all GUI objects"""
        mouse_pos = pygame.mouse.get_pos()
        screen.blit(self.back_img, (0, 0))
        screen.blit(self.menu_img, self.menu_pos)
        self.title_box.draw(screen, mouse_pos, self.triggers)

        for page_element in self.help_pages[self.triggers[0][1]]:
            page_element.draw(screen, mouse_pos, self.triggers)

        if self.triggers[0][1] > 0:
            self.button_prev.draw(screen, mouse_pos, self.triggers)
        if self.triggers[0][1] < self.triggers[0][2] - 1:
            self.button_next.draw(screen, mouse_pos, self.triggers)
        self.button_quit.draw(screen, mouse_pos, self.triggers)

        screen.blit(self.cursor_img, mouse_pos)
Example #8
0
 def init(self, screen: ut.Image) -> None:
     """What to do when entering this mode"""
     self.back_img = screen.copy()
Example #9
0
 def init(self, screen: ut.Image) -> None:
     """What to do when entering this mode"""
     pygame.mouse.set_visible(False)
     self.back_img = screen.copy()
Example #10
0
 def draw(self,
          surface: ut.Image,
          mouse_pos: ut.Coord,
          triggers: Optional[List[ut.Trigger]] = None) -> None:
     """Draw FixedImage on the given surface"""
     surface.blit(self.image, self.pos)
Example #11
0
 def draw(self, screen: ut.Image) -> None:
     """Draw game objects"""
     if self.back_img:
         screen.blit(self.back_img, (0, 0))
Example #12
0
 def draw(self, surface: ut.Image) -> None:
     """Draw object on the surface"""
     draw_pos = (self.pos[0] * ut.TILE, self.pos[1] * ut.TILE)
     surface.blit(self.img[int(self.draw_count)], draw_pos)
     self.draw_count = (self.draw_count + ut.ANIMATION_ITER) % len(self.img)
Example #13
0
 def draw(self, surface: ut.Image) -> None:
     """Draw Wall object on the surface"""
     draw_pos = (self.pos[0] * ut.TILE, self.pos[1] * ut.TILE)
     surface.blit(self.img[0], draw_pos)