Hallo,
ich arbeite gerade die Pygame-Tutorials auf dieser Seite durch, allerdings hänge ich nun an einer Stelle fest. Folgendes wird mir ausgegeben:
Traceback (most recent call last):
File "C:\Users\Administrator\Desktop\spiel.py", line 39, in <module>
main()
File "C:\Users\Administrator\Desktop\spiel.py", line 30, in main
_image = image.convert()
NameError: global name 'image' is not defined
Dabei habe ich 'image' doch schon in Zeile 27 benutzt?
|
Quellcode
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
import pygame
from pygame.locals import *
def main():
pygame.init()
screen = pygame.display.set_mode((800, 600))
pygame.display.set_caption("Test")
pygame.mouse.set_visible(1)
pygame.key.set_repeat(1, 30)
clock = pygame.time.Clock()
running = 1
while running:
clock.tick(30)
screen.fill((0, 0, 0))
for event in pygame.event.get():
if event.type == QUIT:
running = 0
if event.type == KEYDOWN:
if event.key == K_ESCAPE:
pygame.event.post(pygame.event.Event(QUIT))
_image = pygame.image.load("C:\\Users\\Administrator\\Desktop\\rot.jpg")
if _image.get_alpha() == None:
_image = image.convert()
else:
_image = image.convert_alpha()
screen.blit(_image, (0, 10))
pygame.display.flip()
if __name__ == '__main__':
main()
|