Nachfolgend ein ganz simpler Testcode für pygame. In der Pyton Umgebung ist noch Panda3D mit Python 3.7 Instaliert.
Ich benutze PyCharm und es ist ein Windows 10 System.
Wenn ich jetzt in der Console diesen befehl eingeb ,> python setup.py bdist_apps , so wird eine DIST erzeugt.
Das Problem ist die Pfad Angabe beim Mixer. Aber nicht wenn ich das über PyCharm starte.
Jemand ne Idee.
Code: Alles auswählen
import pygame
pygame.init()
crash_sound = pygame.mixer.Sound("FH.ogg")
pygame.mixer.Sound.play(crash_sound)
display_width = 1000
display_height = 300
black = (0, 0, 0)
white = (255, 255, 255)
red = (200, 0, 0)
green = (0, 200, 0)
bright_red = (255, 0, 0)
bright_green = (0, 255, 0)
block_color = (53, 115, 255)
gameDisplay = pygame.display.set_mode((display_width,display_height))
pygame.display.set_caption('PyGame Testumgebung')
clock = pygame.time.Clock()
def text_objects(text, font):
textSurface = font.render(text, True, black)
return textSurface, textSurface.get_rect()
def quitgame():
pygame.quit()
quit()
def button(msg,x,y,w,h,ic,ac,action=None):
mouse = pygame.mouse.get_pos()
click = pygame.mouse.get_pressed()
if x+w > mouse[0] > x and y+h > mouse[1] > y:
pygame.draw.rect(gameDisplay, ac,(x,y,w,h))
if click[0] == 1 and action != None:
action()
else:
pygame.draw.rect(gameDisplay, ic,(x,y,w,h))
smallText = pygame.font.SysFont("comicsansms",20)
textSurf, textRect = text_objects(msg, smallText)
textRect.center = ( (x+(w/2)), (y+(h/2)) )
gameDisplay.blit(textSurf, textRect)
def test_loop():
gameExit = False
while not gameExit:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
quit()
gameDisplay.fill(white)
largeText = pygame.font.SysFont("comicsansms", 80)
TextSurf, TextRect = text_objects("Pygame Testumgebung", largeText)
TextRect.center = ((display_width / 2), (display_height / 2)-50)
gameDisplay.blit(TextSurf, TextRect)
button("Quit", 550, 200, 100, 50, red, bright_red, quitgame)
pygame.display.update()
clock.tick(15)
test_loop()
quit()