Ejemplo n.º 1
0
    def __init__(self, x_pos: int, y_pos: int, mouse, *groups):
        super().__init__(*groups)

        spritesheet = SpriteSheet('res/sprite/spritesheet.png')
        self.sprites = [
            spritesheet.get_sprite(31, 12, 5, 5),
            spritesheet.get_sprite(37, 12, 5, 5),
            spritesheet.get_sprite(43, 12, 5, 5),
            spritesheet.get_sprite(49, 12, 5, 5),
            spritesheet.get_sprite(55, 12, 5, 5),
            spritesheet.get_sprite(61, 12, 5, 5)
        ]

        self.sprite_count: int = 0
        self.image = spritesheet.get_sprite(31, 12, 5, 5)
        self.image = pygame.transform.scale(self.image, (15, 15))
        self.mouse = mouse
        self.rect = pygame.Rect(x_pos, y_pos, 5, 5)

        self.pos_x = x_pos
        self.pos_y = y_pos

        self.ang = math.atan2(
            self.mouse[0] - self.rect.center[0],
            self.mouse[1] - self.rect.center[1]) - math.pi / 2
        self.ang_x = math.cos(self.ang) * 5
        self.ang_y = math.sin(self.ang) * 5
Ejemplo n.º 2
0
    def __init__(self, *groups):
        super().__init__(*groups)
        sprite_sheet = SpriteSheet('res/sprite/spritesheet.png')
        self.sprites = {
            'HeroRun': [
                sprite_sheet.get_sprite(1, 9, 7, 7),
                sprite_sheet.get_sprite(11, 9, 7, 7),
                sprite_sheet.get_sprite(21, 9, 7, 7), (28, 28)
            ],
            'HeroGun': [
                sprite_sheet.get_sprite(32, 22, 11, 9),
                sprite_sheet.get_sprite(44, 22, 11, 9),
                sprite_sheet.get_sprite(56, 22, 11, 9), (44, 36)
            ]
        }

        self.image = sprite_sheet.get_sprite(0, 9, 9, 9)
        self.image = pygame.transform.scale(self.image, [28, 28])
        self.rect = pygame.Rect(32 * 8, 32 * 8, 28, 28)

        self.sprite_anim = 'HeroRun'
        self.animations = {'Gun': False, 'GunPerma': False}

        self.lado_x = [True, True]
        self.lado_y = [True, True]

        self.speed: int = 5
        self.velocity = 4
        self.sprite_count: int = 1

        self.rotation = None
Ejemplo n.º 3
0
 def __init__(self, pos_x: int, pos_y: int, *groups):
     super().__init__(*groups)
     self.type: str = 'Gun'
     self.perma_item: str = 'GunPerma'
     spritesheet = SpriteSheet('res/sprite/spritesheet.png')
     self.sprites = [
         spritesheet.get_sprite(0, 0, 11, 7),
         spritesheet.get_sprite(12, 0, 11, 7),
         spritesheet.get_sprite(24, 0, 11, 7),
         spritesheet.get_sprite(36, 0, 11, 7)
     ]
     self.sprite_count: int = 0
     self.image = spritesheet.get_sprite(0, 0, 11, 7)
     self.image = pygame.transform.scale(self.image, [22, 14])
     self.rect = pygame.Rect(pos_x, pos_y, 35, 28)
Ejemplo n.º 4
0
 def __init__(self):
     image = SpriteSheet('res/sprite/spritesheet.png')
     self.tiles = {'Block': image.get_sprite(78, 0, 18, 18),
                   'Floor': image.get_sprite(77, 66, 18, 18)}