Вот полная ошибка:
Traceback (most recent call last):
File "C:/Users/Yura7/PycharmProjects/SpaceInvaders/main.py", line 28, in <module>
run()
File "C:/Users/Yura7/PycharmProjects/SpaceInvaders/main.py", line 17, in run
stats = Stats()
File "C:\Users\Yura7\PycharmProjects\SpaceInvaders\stats.py", line 9, in __init__
self.high_score = int(f.readline())
ValueError: invalid literal for int() with base 10: ''
# файл stats
class Stats():
"""отслеживание статистики"""
def __init__(self):
"""инициализирует статистику"""
self.reset_stats()
self.run_game = True
with open('highscore.txt', 'r') as f:
self.high_score = int(f.readline())
def reset_stats(self):
"""статистика, изменяющаяся во время игры"""
self.guns_left = 2
self.score = 0
# файл main
import pygame, controlls
from gun import Gun
from pygame.sprite import Group
from stats import Stats
from scores import Scores
def run():
pygame.init()
screen = pygame.display.set_mode((500, 600))
pygame.display.set_caption('Космические защитники')
bg_color = (0, 0, 0)
gun = Gun(screen)
bullets = Group()
inos = Group()
controlls.create_army(screen, inos)
stats = Stats()
sc = Scores(screen, stats)
while True:
controlls.events(screen, gun, bullets)
if stats.run_game:
gun.update_gun()
controlls.update(bg_color, screen, stats, sc, gun, inos, bullets)
controlls.update_bullets(screen, stats, sc, inos, bullets)
controlls.update_inos(stats, screen, gun, inos, bullets)
run()