Resized objects
Added fps an axis output for debbuging purposes
55
main.py
@@ -2,8 +2,11 @@ import pygame
|
|||||||
|
|
||||||
|
|
||||||
pygame.init()
|
pygame.init()
|
||||||
MAINSCREEN_SIZE = (1024,768)
|
MAINSCREEN_SIZE = (1440,900)
|
||||||
MAINSCREEN = pygame.display.set_mode(MAINSCREEN_SIZE)
|
MAINSCREEN = pygame.display.set_mode(MAINSCREEN_SIZE)
|
||||||
|
CENTER_X = MAINSCREEN_SIZE[0]/2
|
||||||
|
CENTER_Y = MAINSCREEN_SIZE[1]/2
|
||||||
|
|
||||||
pygame.display.set_caption("PACMAN")
|
pygame.display.set_caption("PACMAN")
|
||||||
clock = pygame.time.Clock()
|
clock = pygame.time.Clock()
|
||||||
|
|
||||||
@@ -12,17 +15,33 @@ SCHWARZ = (0,0,0)
|
|||||||
GRUEN = (0,255,0)
|
GRUEN = (0,255,0)
|
||||||
ROT = (255,0,0)
|
ROT = (255,0,0)
|
||||||
|
|
||||||
|
font1 = pygame.font.SysFont("Noto Sans 10pt", 25)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PLAYGROUND = pygame.Surface((1024,728))
|
PLAYGROUND = pygame.Surface((1024,728))
|
||||||
|
|
||||||
gamestate = True
|
gamestate = True
|
||||||
|
|
||||||
|
#Mapfiles for Mapgen
|
||||||
map_file = open("maps/map_1.txt")
|
map_file = open("maps/map_1.txt")
|
||||||
map_texture_map1 = pygame.image.load("models/wall_1.png")
|
map_texture_map1 = pygame.image.load("models/wall_1.png")
|
||||||
|
map_space_size = 30
|
||||||
|
map_wall_size = 30
|
||||||
|
|
||||||
|
#PACMAN_CREATURE_CONSTANTS
|
||||||
pacman = pygame.image.load("models/pacman_1.png")
|
pacman = pygame.image.load("models/pacman_1.png")
|
||||||
pacman_posx = 0
|
pacman_posx = 0
|
||||||
pacman_posy = 0
|
pacman_posy = 0
|
||||||
pacman_movespeed = 5
|
pacman_movespeed = 5
|
||||||
pacman_startpoint = {0,0}
|
pacman_startpoint = {0,0}
|
||||||
|
pacman_size = 26
|
||||||
|
|
||||||
|
|
||||||
|
#Labels
|
||||||
|
|
||||||
|
|
||||||
|
#Movement
|
||||||
movedirection = {"up":False, "down":False, "left":False, "right":False}
|
movedirection = {"up":False, "down":False, "left":False, "right":False}
|
||||||
|
|
||||||
map1 = list()
|
map1 = list()
|
||||||
@@ -44,20 +63,21 @@ def generate_map(*mapfile):
|
|||||||
#movement_map.append({"x":startpos_x, "y":startpos_y})
|
#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})
|
movement_map.append({"id":id,"object": pygame.image.load("models/wall_1.png"), "x":startpos_x, "y":startpos_y})
|
||||||
|
|
||||||
startpos_x +=20
|
startpos_x += map_wall_size
|
||||||
id += 1
|
id += 1
|
||||||
#print(line)
|
#print(line)
|
||||||
startpos_x = 0
|
startpos_x = 0
|
||||||
startpos_y += 20
|
startpos_y += map_wall_size
|
||||||
|
|
||||||
def generate_movement_path():
|
|
||||||
|
|
||||||
pass
|
|
||||||
|
|
||||||
generate_map()
|
generate_map()
|
||||||
|
|
||||||
pacman_posx = movement_map[0]["x"]
|
#Needs to center pacman into rendered lines
|
||||||
pacman_posy = movement_map[0]["y"]
|
|
||||||
|
movement_map_center = (map_space_size-pacman_size)/2
|
||||||
|
print(F"Center correction: {movement_map_center}")
|
||||||
|
pacman_posx += movement_map[0]["x"]+movement_map_center
|
||||||
|
pacman_posy += movement_map[0]["y"]+movement_map_center
|
||||||
|
|
||||||
|
|
||||||
while(gamestate==True):
|
while(gamestate==True):
|
||||||
@@ -89,16 +109,18 @@ while(gamestate==True):
|
|||||||
print("rechts")
|
print("rechts")
|
||||||
|
|
||||||
|
|
||||||
|
#TODO Check for wall-collision!!!!
|
||||||
|
|
||||||
if(movedirection["up"] == True):
|
if(movedirection["up"] == True):
|
||||||
if(pacman_posy >= 0):
|
if(pacman_posy >= 0):
|
||||||
pacman_posy -= pacman_movespeed
|
pacman_posy -= pacman_movespeed
|
||||||
|
|
||||||
if(movedirection["down"] == True):
|
if(movedirection["down"] == True):
|
||||||
if(pacman_posy <= (MAINSCREEN_SIZE[1]-18)):
|
if(pacman_posy <= (MAINSCREEN_SIZE[1]-pacman_size)):
|
||||||
pacman_posy += pacman_movespeed
|
pacman_posy += pacman_movespeed
|
||||||
|
|
||||||
if(movedirection["right"] == True):
|
if(movedirection["right"] == True):
|
||||||
if(pacman_posx <= (MAINSCREEN_SIZE[0]-18)):
|
if(pacman_posx <= (MAINSCREEN_SIZE[0]-pacman_size)):
|
||||||
pacman_posx += pacman_movespeed
|
pacman_posx += pacman_movespeed
|
||||||
|
|
||||||
if(movedirection["left"] == True):
|
if(movedirection["left"] == True):
|
||||||
@@ -112,10 +134,19 @@ while(gamestate==True):
|
|||||||
#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:
|
for index, item in enumerate(movedirection):
|
||||||
# print(coordinate)
|
if(movedirection[item]==True):
|
||||||
|
print(F"Pacman-Position: x:{pacman_posx} y:{pacman_posy}")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
pacman_pos_label = font1.render(F"x:{pacman_posx} y:{pacman_posy}", 1, SCHWARZ)
|
||||||
|
fps_label = font1.render(F"FPS: {int(clock.get_fps())}", 1, SCHWARZ)
|
||||||
|
|
||||||
|
MAINSCREEN.blit(pacman_pos_label, (CENTER_X,MAINSCREEN_SIZE[1]-40))
|
||||||
|
MAINSCREEN.blit(fps_label, (CENTER_X - 150,MAINSCREEN_SIZE[1]-40))
|
||||||
|
|
||||||
pygame.display.flip()
|
pygame.display.flip()
|
||||||
clock.tick(60)
|
clock.tick(60)
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
######################################################
|
###############################################
|
||||||
######### ###########
|
## ###########
|
||||||
######### ################################ ###########
|
## ########### #################### ###########
|
||||||
######### ################################ ###########
|
## ########### #################### ###########
|
||||||
######### ################################ ###########
|
## ########### #################### ###########
|
||||||
######### ################################ ###########
|
## ########### #################### ###########
|
||||||
######### ################################ ###########
|
## ########### #################### ###########
|
||||||
######### ################################ ###########
|
## ########### #################### ###########
|
||||||
######### ################################ ###########
|
## ########### #################### ###########
|
||||||
######### ################################ ###########
|
## ########### #################### ###########
|
||||||
######### ################################ ###########
|
## ########### #################### ###########
|
||||||
######### ################################ ###########
|
## ########### #################### ###########
|
||||||
######### ################################ ###########
|
## ########### #################### ###########
|
||||||
######### ################################ ###########
|
## ########### #################### ###########
|
||||||
######### ###########
|
## ###########
|
||||||
######################################################
|
###############################################
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 391 B After Width: | Height: | Size: 681 B |
@@ -2,13 +2,16 @@
|
|||||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||||
|
|
||||||
<svg
|
<svg
|
||||||
width="210mm"
|
width="26"
|
||||||
height="297mm"
|
height="26"
|
||||||
viewBox="0 0 210 297"
|
viewBox="0 0 6.8791663 6.8791668"
|
||||||
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 (091e20ef0f, 2023-11-25, custom)"
|
||||||
sodipodi:docname="pacman_1.svg"
|
sodipodi:docname="pacman_1.svg"
|
||||||
|
inkscape:export-filename="pacman_1.png"
|
||||||
|
inkscape:export-xdpi="96.739998"
|
||||||
|
inkscape:export-ydpi="96.739998"
|
||||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
@@ -24,12 +27,12 @@
|
|||||||
inkscape:deskcolor="#d1d1d1"
|
inkscape:deskcolor="#d1d1d1"
|
||||||
inkscape:document-units="mm"
|
inkscape:document-units="mm"
|
||||||
inkscape:zoom="0.94167964"
|
inkscape:zoom="0.94167964"
|
||||||
inkscape:cx="228.84641"
|
inkscape:cx="227.25351"
|
||||||
inkscape:cy="269.19983"
|
inkscape:cy="267.60693"
|
||||||
inkscape:window-width="1920"
|
inkscape:window-width="2560"
|
||||||
inkscape:window-height="1009"
|
inkscape:window-height="1412"
|
||||||
inkscape:window-x="-8"
|
inkscape:window-x="0"
|
||||||
inkscape:window-y="-8"
|
inkscape:window-y="0"
|
||||||
inkscape:window-maximized="1"
|
inkscape:window-maximized="1"
|
||||||
inkscape:current-layer="layer1" />
|
inkscape:current-layer="layer1" />
|
||||||
<defs
|
<defs
|
||||||
@@ -37,15 +40,16 @@
|
|||||||
<g
|
<g
|
||||||
inkscape:label="Ebene 1"
|
inkscape:label="Ebene 1"
|
||||||
inkscape:groupmode="layer"
|
inkscape:groupmode="layer"
|
||||||
id="layer1">
|
id="layer1"
|
||||||
|
transform="translate(-0.43445301,-0.43445301)">
|
||||||
<circle
|
<circle
|
||||||
style="fill:#ff9955;stroke-width:0.0409236"
|
style="fill:#ff9955;stroke-width:0.0354671"
|
||||||
id="path1"
|
id="path1"
|
||||||
cx="63.968754"
|
cx="3.8740363"
|
||||||
cy="63.968754"
|
cy="3.8740363"
|
||||||
inkscape:export-filename="pacman_1.png"
|
inkscape:export-filename="pacman_1.png"
|
||||||
inkscape:export-xdpi="96.739998"
|
inkscape:export-xdpi="96.739998"
|
||||||
inkscape:export-ydpi="96.739998"
|
inkscape:export-ydpi="96.739998"
|
||||||
r="3.96875" />
|
r="3.4395833" />
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 150 B After Width: | Height: | Size: 203 B |
@@ -2,13 +2,16 @@
|
|||||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||||
|
|
||||||
<svg
|
<svg
|
||||||
width="5.2916665mm"
|
width="30"
|
||||||
height="5.2916665mm"
|
height="30"
|
||||||
viewBox="0 0 5.2916667 5.2916665"
|
viewBox="0 0 7.9375005 7.9374997"
|
||||||
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 (091e20ef0f, 2023-11-25, custom)"
|
||||||
sodipodi:docname="wall_1.svg"
|
sodipodi:docname="wall_1.svg"
|
||||||
|
inkscape:export-filename="wall_1.png"
|
||||||
|
inkscape:export-xdpi="96"
|
||||||
|
inkscape:export-ydpi="96"
|
||||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
@@ -24,12 +27,12 @@
|
|||||||
inkscape:deskcolor="#d1d1d1"
|
inkscape:deskcolor="#d1d1d1"
|
||||||
inkscape:document-units="mm"
|
inkscape:document-units="mm"
|
||||||
inkscape:zoom="0.72426347"
|
inkscape:zoom="0.72426347"
|
||||||
inkscape:cx="158.09164"
|
inkscape:cx="136.00023"
|
||||||
inkscape:cy="188.46733"
|
inkscape:cy="-59.37066"
|
||||||
inkscape:window-width="1920"
|
inkscape:window-width="2560"
|
||||||
inkscape:window-height="1009"
|
inkscape:window-height="1412"
|
||||||
inkscape:window-x="-8"
|
inkscape:window-x="0"
|
||||||
inkscape:window-y="-8"
|
inkscape:window-y="0"
|
||||||
inkscape:window-maximized="1"
|
inkscape:window-maximized="1"
|
||||||
inkscape:current-layer="layer1" />
|
inkscape:current-layer="layer1" />
|
||||||
<defs
|
<defs
|
||||||
@@ -38,14 +41,14 @@
|
|||||||
inkscape:label="Ebene 1"
|
inkscape:label="Ebene 1"
|
||||||
inkscape:groupmode="layer"
|
inkscape:groupmode="layer"
|
||||||
id="layer1"
|
id="layer1"
|
||||||
transform="translate(-63.199261,-98.269371)">
|
transform="translate(-69.044281,-105.57565)">
|
||||||
<rect
|
<rect
|
||||||
style="fill:#4d4d4d;stroke-width:0.0923575"
|
style="fill:#4d4d4d;stroke-width:0.138536"
|
||||||
id="rect1"
|
id="rect1"
|
||||||
width="5.2916665"
|
width="7.9375"
|
||||||
height="5.2916665"
|
height="7.9375"
|
||||||
x="63.199261"
|
x="69.044281"
|
||||||
y="98.269371"
|
y="105.57565"
|
||||||
inkscape:export-filename="wall_1.png"
|
inkscape:export-filename="wall_1.png"
|
||||||
inkscape:export-xdpi="101.75021"
|
inkscape:export-xdpi="101.75021"
|
||||||
inkscape:export-ydpi="101.75021" />
|
inkscape:export-ydpi="101.75021" />
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |