You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Подготовка экрана
stdscr.clear() # Очистка экрана
curses.curs_set(0) # Скрытие курсора
stdscr.nodelay(1) # Включение неблокирующего режима
# Параметры анимации
start_time = time.time() # Время начала анимации
animation_duration = 5 # Длительность анимации в секундах
while True:
stdscr.clear() # Очистка экрана для каждого кадра
elapsed_time = time.time() - start_time # Прошедшее время
# Расчет прогресса анимации (от 0 до 1)
progress = elapsed_time / animation_duration
if progress <= 1:
# Анимация постепенного появления текста логотипа
for i, line in enumerate(loading_text):
visible_chars = int(len(line) * progress) # Количество видимых символов
stdscr.addstr(
stdscr.getmaxyx()[0] // 2 - len(loading_text) // 2 + i, # Позиция Y
stdscr.getmaxyx()[1] // 2 - len(line) // 2, # Позиция X
line[:visible_chars] # Видимая часть строки
)
# Отрисовка прогресс-бара
bar_length = 30 # Длина прогресс-бара
filled_length = int(bar_length * progress) # Заполненная часть
bar = '█' * filled_length + '-' * (bar_length - filled_length) # Формирование прогресс-бара
# Вывод прогресс-бара
stdscr.addstr(
stdscr.getmaxyx()[0] // 2 + len(loading_text) // 2 + 2, # Позиция Y
stdscr.getmaxyx()[1] // 2 - bar_length // 2, # Позиция X
f"[{bar}] {int(progress * 100)}%" # Прогресс-бар и процент
)
else:
# Показ полного логотипа после завершения анимации
for i, line in enumerate(loading_text):
stdscr.addstr(
stdscr.getmaxyx()[0] // 2 - len(loading_text) // 2 + i,
stdscr.getmaxyx()[1] // 2 - len(line) // 2,
line
)
# Показ заголовка игры
if progress > 0.5: # Показ заголовка после половины анимации
title_progress = (progress - 0.5) * 2 # Ускорение анимации заголовка
visible_title_chars = int(len(game_title) * title_progress)
stdscr.addstr(
stdscr.getmaxyx()[0] - 2,
stdscr.getmaxyx()[1] // 2 - len(game_title) // 2,
game_title[:visible_title_chars]
)
# Обновление экрана
stdscr.refresh()
# Остановка анимации после завершения
if progress > 1:
stdscr.refresh() # Обновление экрана перед задержкой
time.sleep(1) # Задержка в 1 секунду
break
# Задержка между кадрами
time.sleep(0.05)
В этой функции происходит анимированная загрузка игры с ASCII-артом логотипа и прогресс-баром. Анимация длится 5 секунд и постепенно отображает логотип и прогресс-бар. После завершения анимации отображается заголовок игры.
The text was updated successfully, but these errors were encountered:
def animation_loading(stdscr):
"""
Функция анимированной загрузки игры
"""
# Определение ASCII-арта для логотипа
loading_text = [
" _____ _ _____ ",
" / | | | / | ",
" | ( __ _ _ __ | | ___ | | __ __ _ _ __ ___ ___ ",
" \ \ /
| '_ \\| __/ _ \\| | |_ |/ _
| ' ` _ \ / _ \"," ) | (| | | | | || /| || | (| | | | | | | /",
" |_/ \,|| ||\\| \|\,|| || ||\_|"
]
# Заголовок игры
game_title = "Игра про змейку высшего уровня"
В этой функции происходит анимированная загрузка игры с ASCII-артом логотипа и прогресс-баром. Анимация длится 5 секунд и постепенно отображает логотип и прогресс-бар. После завершения анимации отображается заголовок игры.
The text was updated successfully, but these errors were encountered: