Do some changes and tests

This commit is contained in:
2023-12-25 11:37:22 +01:00
parent 13622322c1
commit c9d8a28683

View File

@@ -8,7 +8,7 @@ WEISS = ( 255, 255, 255)
active = True
clock = pygame.time.Clock()
#screen.fill(WEISS)
Testobjekt = {"name":"testobjekt",
"posx":0,
@@ -17,8 +17,33 @@ Testobjekt = {"name":"testobjekt",
# Definieren der Variablen
ballpos_x = 10
ballpos_y = 30
ballpos_y = 10
class GameObjekt():
__name = str()
__pos_x = int()
__pos_y = int()
__rectobjekt = pygame.Rect
def __init__(self, name:str, posx:int, posy:int, *rect:pygame.Rect) -> None:
self.__name = name
self.__pos_x = posx
self.__pos_y = posy
self.__rectobjekt = rect
pass
def move(self, x):
MOVE_SPEED = 5
#self.__rectobjekt.x += MOVE_SPEED
print(self.__rectobjekt)
background = pygame.Surface((640,480)) #Erstellt eine Obfläche mit der Größe des Fensters
rect2 = pygame.draw.rect(background,(0,255,255),(20,20,40,40))
rect1 = pygame.draw.ellipse(screen, (0,0,0), [ballpos_x, ballpos_y, 20, 20])
Player = GameObjekt("Test", 0,0,rect1)
#Fenster-Hauptschleife
while active == True:
@@ -28,29 +53,33 @@ while active == True:
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")
print(rect2.x)
background.get_rect()
#rect1.move(ballpos_x, ballpos_y)
Player.move(5)
ballpos_y -= 10
elif (event.key == pygame.K_DOWN):
print("Keydown")
#rect1.move(ballpos_x, ballpos_y)
ballpos_y += 10
elif (event.key == pygame.K_RIGHT):
print("Keydown")
#rect1.move(ballpos_x, ballpos_y)
ballpos_x += 10
elif (event.key == pygame.K_LEFT):
print("Keydown")
#rect1.move(ballpos_x, ballpos_y)
ballpos_x -= 10
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()
rect2.move(100, 10)
screen.blit(background,(0,0))
pygame.display.flip()
clock.tick(60)
pygame.quit()