Exemple #1
0
pygame.init()
sc = pygame.display.set_mode((WIDTH, HEIGHT), pygame.DOUBLEBUF)
clock = pygame.time.Clock()

sc_map = pygame.Surface(MAP_RES)
sprites = Sprites()
player = Player(sprites)
drawing = Drawing(sc, sc_map, player, clock)
interaction = Interaction(player, sprites, drawing)

drawing.menu()
pygame.mouse.set_visible(False)

while True:

    player.movement()
    drawing.background()
    walls, wall_shot = ray_casting_walls(player, drawing.textures)
    drawing.world(
        walls + [obj.object_locate(player) for obj in sprites.list_of_objects])
    drawing.mini_map()
    drawing.player_weapon([wall_shot, sprites.sprite_shot])
    interaction.interaction_objects()
    interaction.npc_action()
    interaction.clear_world()
    interaction.check_win()
    drawing.hud()

    pygame.display.flip()
    #clock.tick()
drawing.menu()
# запуск музыки
interaction.play_music()

while True:
    pygame.mouse.set_visible(False)
    player.movement()  # анализ нажатия клавиш
    drawing.background(player.angle)  # отрисовка неба и пола
    walls, wall_shot = ray_casting_walls(
        player, drawing.textures)  # улавливание стен лучами
    drawing.world(
        walls + [obj.object_locate(player)
                 for obj in sprites.list_of_objects])  # отрисовка мира
    drawing.fps(clock)  # счетчик фпс
    drawing.mini_map(player)  # миникарта
    drawing.player_weapon([wall_shot, sprites.sprite_shot])  # отрисовка оружия

    interaction.interaction_objects()
    interaction.npc_action(
    )  # анализ действия нпс. на данный момент бесполезно без ии
    interaction.clear_world(
    )  # удаление мертвых объектов из списка для анализа

    pygame.draw.circle(sc, (0, 255, 0), (HALF_WIDTH, HALF_HEIGHT), 5,
                       1)  # прицел

    interaction.check_win()

    pygame.display.flip()
    clock.tick(FPS)