diff --git a/main.py b/main.py index 27654f9..c03770e 100644 --- a/main.py +++ b/main.py @@ -16,6 +16,11 @@ PLAYGROUND = pygame.Surface((1024,728)) gamestate = True +pacman = pygame.image.load("models/pacman_1.png") +pacman_posx = 0 +pacman_posy = 0 +pacman_movespeed = 5 +movedirection = {"up":False, "down":False, "left":False, "right":False} while(gamestate==True): @@ -27,17 +32,48 @@ while(gamestate==True): gamestate = False if (event.type == pygame.KEYDOWN): if (event.key == pygame.K_UP): + movedirection["up"] = True + movedirection["down"] = False print("hoch") if (event.type == pygame.KEYDOWN): if (event.key == pygame.K_DOWN): + movedirection["down"] = True + movedirection["up"] = False print("runter") if (event.type == pygame.KEYDOWN): if (event.key == pygame.K_LEFT): + movedirection["left"] = True + movedirection["right"] = False print("links") if (event.type == pygame.KEYDOWN): if (event.key == pygame.K_RIGHT): + movedirection["right"] = True + movedirection["left"] = False print("rechts") + + + if(movedirection["up"] == True): + pacman_posy -= pacman_movespeed + + if(movedirection["down"] == True): + pacman_posy += pacman_movespeed + + if(movedirection["right"] == True): + if(pacman_posx != MAINSCREEN_SIZE[0]): + pacman_posx += pacman_movespeed + print(pacman_posx) + print(MAINSCREEN_SIZE[0]) + + if(movedirection["left"] == True): + if(pacman_posx != -1): + pacman_posx -= pacman_movespeed + + #print(pacman_posx) + #print(pacman_posy) + + MAINSCREEN.blit(pacman, (pacman_posx,pacman_posy)) + pygame.display.flip() clock.tick(60) diff --git a/models/pacman_1.png b/models/pacman_1.png new file mode 100644 index 0000000..dedad60 Binary files /dev/null and b/models/pacman_1.png differ diff --git a/models/pacman_1.svg b/models/pacman_1.svg new file mode 100644 index 0000000..2223b18 --- /dev/null +++ b/models/pacman_1.svg @@ -0,0 +1,51 @@ + + + + + + + + + +