Exemplo n.º 1
0
def draw_stars(stars, window):
    k = 0
    for i, j, n in stars:
        window.blit(
            pygame.transform.scale(
                star, (int(star_width / n), int(star_height / n))),
            (i, j - int(star_height / n)))
        stars[k][1] = (stars[k][1] + 1) % main_win_height
        k += 1
Exemplo n.º 2
0
def expload(exploading_ships):
    n = 0
    while n != len(exploading_ships):
        if exploading_ships[n][2] == 11:
            del exploading_ships[n]
            pass
        else:
            window.blit(explosion_frames[exploading_ships[n][2]],
                        (exploading_ships[n][0], exploading_ships[n][1]))
            exploading_ships[n][2] += 1
            n += 1
Exemplo n.º 3
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)
Exemplo n.º 4
0
 def draw(self, surface=window):
     window.blit(self.image, self.rect)
Exemplo n.º 5
0
 def draw(self, win=window):
     window.blit(self.image, self.rect)
     self.state = (self.state + 1) % len(self.frames)
     self.image = self.frames[self.state]
Exemplo n.º 6
0
 def draw(self, surface=window):
     self.draw_basic(surface)
     self.bullets.draw(surface)
     if self.shields:
         window.blit(self.shield_image, self.rect)
Exemplo n.º 7
0
    if c % s_t == 0:
        enemies.add(Station(0, 100))
        enemies.add(Station(100, 100))
        enemies.add(Station(200, 100))
        enemies.add(Station(400, 100))
        enemies.add(Station(500, 100))

    if character.life <= 0:
        print('Game Over')
        end_game(character, enemies, exploading_ships, stars)
        run = False

    character.draw(window)
    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.update()
    c += 1
    '''
    if c%400 == 0:
        t_b -= 10
        t_p_a -= 10
        t_p_b -= 10
    '''
    #X -= 1

pygame.quit()
sys.exit()
Exemplo n.º 8
0
    info_string.fill((150, 150, 150))

    """отображение героя"""
    hero.update(left, right, up, down)
    camera.update(hero)

    for e in sprite_group:
        screen.blit(e.image, camera.apply(e))

    """отрисовка строений"""
    for e in city_group:
        screen.blit(e.image, camera.apply(e))

    """отрисовка шрифтов"""

    ind = 0
    for e in city_group:
        screen.blit(e.image, camera.apply(e))
        screen.blit(city_font.render(city_name_list[ind], 1, (50, 50, 150)), camera.apply(e))
        ind += 1

    screen.blit(hero.image, camera.apply(hero))

    """Отрисовка холста на экране"""
    window.blit(info_string, (0, 0))
    window.blit(screen, (0, 30))

    """обновляем окно"""
    pygame.display.flip()
    timer.tick(45)