ich habe gerade angefangen eine kleine Demoanwendung in Python zu schreiben und alles lief auch gut, bis ich versuchte einen Colorkey bei einem Bild zu setzen... Das ist ja nicht das Problem, jetzt mault IDLE nämlich an einer Zeile die sonst immer funktioniert hat rum:
Hier mal der gesamte code:
Code: Alles auswählen
# import pygame (all)
import pygame
from pygame.locals import *
# path to the images
bif = "background.jpg"
mif = "crosshair.png"
baif = "ballon.png"
# initialise pygame/screen
pygame.init()
screen = pygame.display.set_mode((640,480),0,32)
# loading the images
background = pygame.image.load(bif).convert()
crosshair = pygame.image.load(mif).convert_alpha()
ballon = pygame.image.load(baif).convert_alpha()
# making the normal cursor disappear
pygame.mouse.set_visible(False)
# setting colorkey for baloon image
#colorkey = ballon.get_at((0,0))
ballon.set_colorkey((255,255,255))
# the Gameloop
while True:
for event in pygame.event.get():
# if "exit" event close application
if event.type == QUIT:
pygame.quit()
# variables for the ballon coordinates
ballon_x,ballon_y = 100,100
# get mouse position
crosshair_x,crosshair_y = pygame.mouse.get_pos()
# correct to the middle of the image
crosshair_x -= crosshair.get_width()/2
crosshair_y -= crosshair.get_height()/2
# blitting all on the screen (first background, than baloon than crosshair)
screen.blit(background, (0,0))
screen.blit(ballon,(ballon_x,ballon_y))
screen.blit(crosshair, (crosshair_x,crosshair_y))
# update
pygame.display.update()
...ich werde daraus nicht schlau, erkennt ihr dort einen Fehler??Traceback (most recent call last):
File "C:\Users\Lennart\Desktop\shooter.py", line 37, in <module>
crosshair_x,crosshair_y = pygame.mouse.get_pos()
error: video system not initialized
mfg,
Lennart