コード例 #1
0
ファイル: main.py プロジェクト: gitter-badger/SKIPY
 def touching_sprite(self, sprite, other):
     mask = self.get_sprite_mask(sprite)
     other_mask = self.get_sprite_mask(other)
     (x, y) = self.pos_to_screen(skip.bounds(sprite).topleft)
     (ox, oy) = self.pos_to_screen(skip.bounds(other).topleft)
     offset = (int(ox - x), int(oy - y))
     return bool(mask.overlap(other_mask, offset))
コード例 #2
0
ファイル: main.py プロジェクト: gitter-badger/SKIPY
 def draw_stage_without_sprite(self, sprite):
     _rect = skip.bounds(sprite)
     (x, y) = self.pos_to_screen(rect.topleft)
     offset = (-x, -y)
     surface = pygame.Surface(_rect.size).convert_alpha()
     self.draw_sprite(self.project.stage, surface, offset)
     surface.blit(self.pen_surface, (0, 0))
     for actor in self.project.actors:
         if actor is not sprite:
             if isinstance(actor, kurt.Scriptable):
                 if actor.is_visible:
                     self.draw_sprite(actor, surface, offset)
     return surface
コード例 #3
0
ファイル: main.py プロジェクト: gitter-badger/SKIPY
    def draw_sprite(self, sprite, onto_surface, offset=None):
        surface = self.surfaces[sprite.costume.image]
        if isinstance(sprite, kurt.Stage):
            pos = (0, 0)
        else:
            pos = self.pos_to_screen(skip.bounds(sprite).topleft)
            #if sprite.direction != 90 and sprite.size != 100:
            angle = -(sprite.direction - 90)
            scale = sprite.size / 100.0
            surface = pygame.transform.rotozoom(surface, angle, scale)

        if offset:
            (ox, oy) = offset
            (x, y) = pos
            pos = (x + ox, y + oy)

        ghost = sprite.graphic_effects['ghost']
        if ghost != 0:
            opacity = (100 - abs(ghost)) * 2.55
            blit_alpha(onto_surface, surface, pos, opacity)
        else:
            onto_surface.blit(surface, pos)
コード例 #4
0
ファイル: main.py プロジェクト: gitter-badger/SKIPY
 def touching_mouse(self, sprite):
     mask = self.get_sprite_mask(sprite)
     (x, y) = self.pos_to_screen(skip.bounds(sprite).topleft)
     (mx, my) = pygame.mouse.get_pos()
     return bool(mask.get_at((int(mx - x), int(my - y))))