Added keyevent loop
Added Model
This commit is contained in:
36
main.py
36
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)
|
||||
|
||||
|
||||
BIN
models/pacman_1.png
Normal file
BIN
models/pacman_1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 632 B |
51
models/pacman_1.svg
Normal file
51
models/pacman_1.svg
Normal file
@@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
width="210mm"
|
||||
height="297mm"
|
||||
viewBox="0 0 210 297"
|
||||
version="1.1"
|
||||
id="svg1"
|
||||
inkscape:version="1.3.2 (091e20e, 2023-11-25, custom)"
|
||||
sodipodi:docname="pacman_1.svg"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg">
|
||||
<sodipodi:namedview
|
||||
id="namedview1"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#000000"
|
||||
borderopacity="0.25"
|
||||
inkscape:showpageshadow="2"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pagecheckerboard="0"
|
||||
inkscape:deskcolor="#d1d1d1"
|
||||
inkscape:document-units="mm"
|
||||
inkscape:zoom="0.94167964"
|
||||
inkscape:cx="228.84641"
|
||||
inkscape:cy="269.19983"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1009"
|
||||
inkscape:window-x="-8"
|
||||
inkscape:window-y="-8"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="layer1" />
|
||||
<defs
|
||||
id="defs1" />
|
||||
<g
|
||||
inkscape:label="Ebene 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1">
|
||||
<circle
|
||||
style="fill:#ff9955;stroke-width:0.0409236"
|
||||
id="path1"
|
||||
cx="63.968754"
|
||||
cy="63.968754"
|
||||
inkscape:export-filename="pacman_1.png"
|
||||
inkscape:export-xdpi="96.739998"
|
||||
inkscape:export-ydpi="96.739998"
|
||||
r="3.96875" />
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
Reference in New Issue
Block a user