habe mich heute an Pygam versucht (win vista) und habe ein paar Fragen an euch. Erstens folgendes Problem: weshalb funktioniert bei mir die input(events) - funktion nicht ? Soweit ich verstanden habe, sollte diese bewirken, dass das Programm beendet wird, sobald ein Quit-event eintritt - ein Klick aufs x oben rechts /Alt,F4 ? -. Wenn ich per x schließe gibt Python mir folgendes aus & das Prog hängt:
Traceback (most recent call last):
File "C:\Users\Kevin\Desktop\erstesgame.py", line 27, in <module>
input(pygame.event.get())
File "C:\Users\Kevin\Desktop\erstesgame.py", line 22, in input
sys.exit(0)
SystemExit: 0
Code habe ich von: http://rene.f0o.com/mywiki/LectureThreeCode: Alles auswählen
#import modules import pygame, sys, os from pygame.locals import * #initializing pygame pygame.init() #setting up the screen window = pygame.display.set_mode((468, 60)) pygame.display.set_caption("Monkey Fever") screen = pygame.display.get_surface() #constructing the monkey filename monkey_head_file_name = os.path.join("C:\Python26\Lib\site-packages\pygame\examples\data", "chimp.bmp") #loading the monkey head image monkey_surface = pygame.image.load(monkey_head_file_name) #drawing the monkey onto the screen screen.blit(monkey_surface, (0,0)) #fliping the display(makes u see the graphic) pygame.display.flip() #adding a way to quit def input(events): #funktioniert nicht for event in events: if event.type == QUIT: sys.exit(0) else: print event #the main loop while True: input(pygame.event.get()
2. Kann mir jemand den genauen Zusammenhang von def input(events) und der Schleife "while true: ..." erklären und die Funktion selbst und weshalb ist sie lila hinterlegt... wie würdet ihr das Stük für Stück in die deutsche Sprache übersetzen... ist vllt viel verlangt aber würde mir wirklich helfen, bin mir manchma noch nicht 100%ig sicher wie ich bestimmte Sachen interpretieren muss ! ; )
3.wenn ich
import pygame
help(pygame)
eingebe, dann wirft er aus:
Warning (from warnings module):
File "C:\Python25\lib\inspect.py", line 49
return isinstance(object, types.ClassType) or hasattr(object, '__bases__')
RuntimeWarning: use sndarray: no module named numpy or Numeric found
(ImportError: no module named numpy or Numeric found)
Warning (from warnings module):
File "C:\Python25\lib\inspect.py", line 49
return isinstance(object, types.ClassType) or hasattr(object, '__bases__')
RuntimeWarning: use surfarray: no module named numpy or Numeric found
(ImportError: no module named numpy or Numeric found)
ist bei meiner Python Installation alles ok, resultiert eines der Probleme (1. & 2.) daraus ?
Bin sehr dankbar für alle hilfreichen Antworten!
Mit freundlichen Grüßen
bluna