Some tests with pygame module
This commit is contained in:
56
pygame-test.py
Normal file
56
pygame-test.py
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
import pygame
|
||||||
|
|
||||||
|
pygame.init()
|
||||||
|
screen = pygame.display.set_mode((640,480))
|
||||||
|
pygame.display.set_caption("Testgame")
|
||||||
|
|
||||||
|
WEISS = ( 255, 255, 255)
|
||||||
|
active = True
|
||||||
|
|
||||||
|
clock = pygame.time.Clock()
|
||||||
|
#screen.fill(WEISS)
|
||||||
|
|
||||||
|
Testobjekt = {"name":"testobjekt",
|
||||||
|
"posx":0,
|
||||||
|
"posy":0
|
||||||
|
}
|
||||||
|
|
||||||
|
# Definieren der Variablen
|
||||||
|
ballpos_x = 10
|
||||||
|
ballpos_y = 30
|
||||||
|
|
||||||
|
|
||||||
|
#Fenster-Hauptschleife
|
||||||
|
while active == True:
|
||||||
|
for event in pygame.event.get():
|
||||||
|
if (event.type == pygame.QUIT):
|
||||||
|
print("Programm wird geschlossen!")
|
||||||
|
active = False
|
||||||
|
elif (event.type == pygame.KEYDOWN):
|
||||||
|
if (event.key == pygame.K_UP):
|
||||||
|
#pygame.draw.rect(screen, (0,0,0), [180,20,100,100],1)
|
||||||
|
#Testobjekt["posx"] +=1
|
||||||
|
print("Keydown")
|
||||||
|
elif (event.key == pygame.K_DOWN):
|
||||||
|
print("Keydown")
|
||||||
|
elif (event.key == pygame.K_RIGHT):
|
||||||
|
print("Keydown")
|
||||||
|
elif (event.key == pygame.K_LEFT):
|
||||||
|
print("Keydown")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
pygame.draw.ellipse(screen, WEISS, [ballpos_x, ballpos_y, 20, 20])
|
||||||
|
|
||||||
|
# bewegen unseres Kreises
|
||||||
|
ballpos_x += 4
|
||||||
|
ballpos_y += 4
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#Displayflip sorgt dafür, dass das Fenster entsprechend der Tickrate aktualisiert wird
|
||||||
|
pygame.display.flip()
|
||||||
|
|
||||||
|
clock.tick(60)
|
||||||
|
pygame.quit()
|
||||||
Reference in New Issue
Block a user