Esempio n. 1
0
    def __init__(self):
        x = randint(0, main_win_width - 20)
        self.rect = pygame.Rect(x, 0, 20, 20)
        self.image = pygame.Surface(self.rect.size)
        self.image.fill((220, 40, 40))
        pygame.draw.rect(self.image, (255, 255, 255), (8, 0, 4, 20))
        pygame.draw.rect(self.image, (255, 255, 255), (0, 8, 20, 4))
        pygame.sprite.Sprite.__init__(self)

        global MIXER
        self.soundchannel = MIXER.get_channel()
Esempio n. 2
0
    def __init__(self):
        x = randint(0, main_win_width - 20)
        self.rect = pygame.Rect(x, 0, 20, 20)
        self.image = pygame.Surface(self.rect.size)
        pygame.draw.circle(self.image, (160, 160, 180), (10, 10), 10)

        self.gathered = False
        self.timer = 0

        self.recharge_time = 100
        pygame.sprite.Sprite.__init__(self)

        global MIXER
        self.soundchannel = MIXER.get_channel()
Esempio n. 3
0
    def __init__(self,
                 rect,
                 image,
                 speed,
                 lifebar_rect,
                 life_capacity,
                 life_color=(0, 255, 0)):
        self.life_capacity = life_capacity
        self.life = life_capacity
        self.lifebar_rect = lifebar_rect
        self.lifecolor = life_color

        self.speed = speed
        self.score = 0

        global MIXER
        self.soundchannel = MIXER.get_channel()
        Solid.__init__(self, image, rect)
Esempio n. 4
0
def end_game(character,
             enemies,
             exploading_ships,
             stars,
             window=window,
             explosion_frames=explosion_frames):
    x_init = character.rect.left + character.image.get_width() // 2
    y_init = character.rect.top + character.image.get_height() // 2
    character.kill()

    global MIXER
    MIXER.play(MIXER.get_channel(), 'explosion')
    for image in big_explosion_frames:
        window.fill(background_color)
        draw_stars(stars, window)
        for enemy in enemies:
            enemy.update(character)
            enemy.draw(window)
        x = x_init - image.get_width() // 2
        y = y_init - image.get_height() // 2

        window.blit(image, (x, y))
        expload(exploading_ships)

        window.blit(score_word_surf, (10, 10))
        window.blit(
            score_text.render(str(character.score), True, (255, 255, 255)),
            (score_width + 10, 10))

        pygame.display.flip()
        pygame.time.delay(100)
    MIXER.play(explosion_channel, 'game_over')
    pygame.mixer.stop()
    window.fill(background_color)

    pygame.time.delay(1500)
Esempio n. 5
0
    pygame.image.load(os.path.join('explosion', 'frame_' + str(i) + '.png'))
    for i in range(12)
]
explosion_frames = [
    pygame.transform.scale(image,
                           (image.get_width() // 3, image.get_width() // 3))
    for image in big_explosion_frames
]

scaling_factor = 2

from soundhandler import MIXER

from directives import enemy_lazership_directive_0, enemy_blasterfighter_directive_3, enemy_blasterfighter_directive_2, enemy_blasterfighter_directive_1, enemy_blasterfighter_directive_0, serp_directive_0

explosion_channel = MIXER.get_channel()

background = pygame.image.load('images/b2.png')


def docollide(recta, imagea, rectb, imageb):
    i_x_s, i_x_e = max(recta.left, rectb.left), min(recta.right, rectb.right)
    i_y_s, i_y_e = max(rectb.top, recta.top), min(recta.bottom, rectb.bottom)

    arra = pygame.PixelArray(imagea)
    arrb = pygame.PixelArray(imageb)
    for i in range(i_x_s, i_x_e):
        for j in range(i_y_s, i_y_e):
            #if arra[i-recta.left][j-recta.top] != 0 and arrb[i-rectb.left][j-rectb.top] != 0:
            if arra[i - recta.left][j - recta.top] != 0 and arrb[
                    i - rectb.left][j - rectb.top] != 0: