Resized models and started pathfinding system

This commit is contained in:
2024-07-09 20:09:27 +02:00
parent 891a90f90a
commit 93b38b6977
5 changed files with 49 additions and 18 deletions

29
main.py
View File

@@ -26,6 +26,7 @@ pacman_startpoint = {0,0}
movedirection = {"up":False, "down":False, "left":False, "right":False} movedirection = {"up":False, "down":False, "left":False, "right":False}
map1 = list() map1 = list()
movement_map = list()
def generate_map(*mapfile): def generate_map(*mapfile):
#Generate row #Generate row
@@ -37,15 +38,28 @@ def generate_map(*mapfile):
for byte in line: for byte in line:
#print(byte) #print(byte)
if(byte == "#"): if(byte == "#"):
map1.append({"id":id,"object": pygame.image.load("models/wall_1.svg"), "x":startpos_x, "y":startpos_y}) map1.append({"id":id,"object": pygame.image.load("models/wall_1.png"), "x":startpos_x, "y":startpos_y})
startpos_x +=60
if(byte == " "):
#movement_map.append({"x":startpos_x, "y":startpos_y})
movement_map.append({"id":id,"object": pygame.image.load("models/wall_1.png"), "x":startpos_x, "y":startpos_y})
startpos_x +=20
id += 1 id += 1
#print(line) #print(line)
startpos_x = 0 startpos_x = 0
startpos_y += 60 startpos_y += 20
def generate_movement_path():
pass
generate_map() generate_map()
pacman_posx = movement_map[0]["x"]
pacman_posy = movement_map[0]["y"]
while(gamestate==True): while(gamestate==True):
MAINSCREEN.fill(WEISS) MAINSCREEN.fill(WEISS)
PLAYGROUND.fill(WEISS) PLAYGROUND.fill(WEISS)
@@ -80,11 +94,11 @@ while(gamestate==True):
pacman_posy -= pacman_movespeed pacman_posy -= pacman_movespeed
if(movedirection["down"] == True): if(movedirection["down"] == True):
if(pacman_posy <= (MAINSCREEN_SIZE[1]-30)): if(pacman_posy <= (MAINSCREEN_SIZE[1]-18)):
pacman_posy += pacman_movespeed pacman_posy += pacman_movespeed
if(movedirection["right"] == True): if(movedirection["right"] == True):
if(pacman_posx <= (MAINSCREEN_SIZE[0]-30)): if(pacman_posx <= (MAINSCREEN_SIZE[0]-18)):
pacman_posx += pacman_movespeed pacman_posx += pacman_movespeed
if(movedirection["left"] == True): if(movedirection["left"] == True):
@@ -95,9 +109,12 @@ while(gamestate==True):
MAINSCREEN.blit(pacman, (pacman_posx,pacman_posy)) MAINSCREEN.blit(pacman, (pacman_posx,pacman_posy))
for row in map1: for row in map1:
print(row) #print(row)
MAINSCREEN.blit(row["object"], (row["x"],row["y"])) MAINSCREEN.blit(row["object"], (row["x"],row["y"]))
#for coordinate in movement_map:
# print(coordinate)
pygame.display.flip() pygame.display.flip()
clock.tick(60) clock.tick(60)

View File

@@ -1,3 +1,16 @@
######## ################################# ######################################################
########## ################# ########### ######### ###########
################################################# ######### ################################ ###########
######### ################################ ###########
######### ################################ ###########
######### ################################ ###########
######### ################################ ###########
######### ################################ ###########
######### ################################ ###########
######### ################################ ###########
######### ################################ ###########
######### ################################ ###########
######### ################################ ###########
######### ################################ ###########
######### ###########
######################################################

Binary file not shown.

Before

Width:  |  Height:  |  Size: 632 B

After

Width:  |  Height:  |  Size: 391 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 216 B

After

Width:  |  Height:  |  Size: 150 B

View File

@@ -2,9 +2,9 @@
<!-- Created with Inkscape (http://www.inkscape.org/) --> <!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg <svg
width="210mm" width="5.2916665mm"
height="297mm" height="5.2916665mm"
viewBox="0 0 210 297" viewBox="0 0 5.2916667 5.2916665"
version="1.1" version="1.1"
id="svg1" id="svg1"
inkscape:version="1.3.2 (091e20e, 2023-11-25, custom)" inkscape:version="1.3.2 (091e20e, 2023-11-25, custom)"
@@ -24,8 +24,8 @@
inkscape:deskcolor="#d1d1d1" inkscape:deskcolor="#d1d1d1"
inkscape:document-units="mm" inkscape:document-units="mm"
inkscape:zoom="0.72426347" inkscape:zoom="0.72426347"
inkscape:cx="396.95499" inkscape:cx="158.09164"
inkscape:cy="561.25984" inkscape:cy="188.46733"
inkscape:window-width="1920" inkscape:window-width="1920"
inkscape:window-height="1009" inkscape:window-height="1009"
inkscape:window-x="-8" inkscape:window-x="-8"
@@ -37,12 +37,13 @@
<g <g
inkscape:label="Ebene 1" inkscape:label="Ebene 1"
inkscape:groupmode="layer" inkscape:groupmode="layer"
id="layer1"> id="layer1"
transform="translate(-63.199261,-98.269371)">
<rect <rect
style="fill:#4d4d4d;stroke-width:0.264583" style="fill:#4d4d4d;stroke-width:0.0923575"
id="rect1" id="rect1"
width="14.977859" width="5.2916665"
height="15.343174" height="5.2916665"
x="63.199261" x="63.199261"
y="98.269371" y="98.269371"
inkscape:export-filename="wall_1.png" inkscape:export-filename="wall_1.png"

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB