При вычислении в школе мы должны сделать проект, шахты - сделать игру Space Invaders. Я все еще новичок в python и продолжаю получать эти две ошибки! Я не знаю, как их исправить, любая помощь будет высоко оценена.Python Display Sprites
C:\Python27\python.exe "C:/Users/Iain/Desktop/Computing Project/Galaxian.py"
Traceback (most recent call last):
File "C:/Users/Iain/Desktop/Computing Project/Galaxian.py", line 32, in <module>
player = Player()
File "C:/Users/Iain/Desktop/Computing Project/Galaxian.py", line 23, in __init__
self.image = pygame.image.load('images\user1.gif').convert()
pygame.error: No video mode has been set
Process finished with exit code 1
Вот мой код (его очень неаккуратно я знаю, и я извиняюсь: р)
import random
import pygame
# Colours
White = (255, 255, 255)
Black = (0, 0, 0)
Red = (255, 0, 0)
Green = (0, 255, 0)
Blue = (0, 0, 255)
Orange = (255, 255, 0)
Yellow = (0, 255, 255)
# Initialize the game and display
pygame.init()
pygame.mixer.init()
class Player(pygame.sprite.Sprite):
def __init__(self):
# type:() -> object
pygame.sprite.Sprite.__init__(self)
self.image = pygame.image.load('images\user1.gif').convert()
self.rect = self.image.get_rect()
self.speedx = 0
def update(self):
self.rectx += self.speedx
all_sprites = pygame.sprite.Group()
player = Player()
all_sprites.add(player)
pygame.mixer.music.load("C:\Users\Iain\Desktop\Computing Project\Audio\music\soundtrack.mp3")
pygame.mixer.music.play(-1)
display_width = 1280
display_height = 720
galaxianDisplay = pygame.display.set_mode((display_width, display_heightth))
clock = pygame.time.Clock()
Background = pygame.image.load("C:\Users\Iain\Desktop\Computing Project\images\Background.jpg").convert()
Background = pygame.transform.scale(Background, (1280, 720))
galaxianDisplay.blit(Background, [0, 0])
x = display_width/2
y = display_height/2
# Loop
crashed = False
while not crashed:
for event in pygame.event.get():
if event.type == pygame.QUIT:
crashed = True
print(event)
pygame.display.update()
clock.tick(60)
pygame.quit()
quit
Любая помощь будет здорово, спасибо.