Some changes
This commit is contained in:
14
main.py
14
main.py
@@ -7,11 +7,14 @@ import random
|
|||||||
pygame.init()
|
pygame.init()
|
||||||
MAINSCREEN_SIZE = (1440,900)
|
MAINSCREEN_SIZE = (1440,900)
|
||||||
MAINSCREEN = pygame.display.set_mode(MAINSCREEN_SIZE, pygame.RESIZABLE)
|
MAINSCREEN = pygame.display.set_mode(MAINSCREEN_SIZE, pygame.RESIZABLE)
|
||||||
#MAINSCREEN = pygame.display.set_mode(MAINSCREEN_SIZE, pygame.FULLSCREEN)
|
#Setup for fullscreen
|
||||||
|
#MAINSCREEN = pygame.display.set_mode((0,0), pygame.FULLSCREEN)
|
||||||
|
|
||||||
CENTER_X = MAINSCREEN_SIZE[0]/2
|
CENTER_X = MAINSCREEN_SIZE[0]/2
|
||||||
CENTER_Y = MAINSCREEN_SIZE[1]/2
|
CENTER_Y = MAINSCREEN_SIZE[1]/2
|
||||||
|
|
||||||
|
debug_mode = True
|
||||||
|
|
||||||
pygame.display.set_caption("PACMAN")
|
pygame.display.set_caption("PACMAN")
|
||||||
clock = pygame.time.Clock()
|
clock = pygame.time.Clock()
|
||||||
|
|
||||||
@@ -94,6 +97,7 @@ generate_map()
|
|||||||
|
|
||||||
movement_map_center = (map_space_size-pacman_size)/2
|
movement_map_center = (map_space_size-pacman_size)/2
|
||||||
print(F"Center correction: {movement_map_center}")
|
print(F"Center correction: {movement_map_center}")
|
||||||
|
#Spawn pacman on top of the map
|
||||||
pacman_posx += movement_map[0]["x"]+movement_map_center
|
pacman_posx += movement_map[0]["x"]+movement_map_center
|
||||||
pacman_posy += movement_map[0]["y"]+movement_map_center
|
pacman_posy += movement_map[0]["y"]+movement_map_center
|
||||||
|
|
||||||
@@ -127,6 +131,9 @@ while(gamestate==True):
|
|||||||
movedirection["right"] = True
|
movedirection["right"] = True
|
||||||
movedirection["left"] = False
|
movedirection["left"] = False
|
||||||
print("rechts")
|
print("rechts")
|
||||||
|
if (event.type == pygame.KEYDOWN):
|
||||||
|
if(event.key == pygame.K_ESCAPE):
|
||||||
|
gamestate = False
|
||||||
|
|
||||||
|
|
||||||
#TODO Check for wall-collision!!!!
|
#TODO Check for wall-collision!!!!
|
||||||
@@ -148,8 +155,6 @@ while(gamestate==True):
|
|||||||
pacman_posx -= pacman_movespeed
|
pacman_posx -= pacman_movespeed
|
||||||
|
|
||||||
|
|
||||||
#print(pacman_animation)
|
|
||||||
|
|
||||||
MAINSCREEN.blit(pacman_animation[count], (pacman_posx,pacman_posy))
|
MAINSCREEN.blit(pacman_animation[count], (pacman_posx,pacman_posy))
|
||||||
|
|
||||||
count += 1
|
count += 1
|
||||||
@@ -157,13 +162,13 @@ while(gamestate==True):
|
|||||||
if count == 5: count = 0
|
if count == 5: count = 0
|
||||||
|
|
||||||
for row in map1:
|
for row in map1:
|
||||||
#print(row)
|
|
||||||
MAINSCREEN.blit(row["object"], (row["x"],row["y"]))
|
MAINSCREEN.blit(row["object"], (row["x"],row["y"]))
|
||||||
|
|
||||||
for index, item in enumerate(movedirection):
|
for index, item in enumerate(movedirection):
|
||||||
if(movedirection[item]==True):
|
if(movedirection[item]==True):
|
||||||
print(F"Pacman-Position: x:{pacman_posx} y:{pacman_posy}")
|
print(F"Pacman-Position: x:{pacman_posx} y:{pacman_posy}")
|
||||||
|
|
||||||
|
if debug_mode:
|
||||||
#Adds visual character for vaild movementpath (DEBUG ONLY)
|
#Adds visual character for vaild movementpath (DEBUG ONLY)
|
||||||
for coord in movement_map:
|
for coord in movement_map:
|
||||||
tmp = font1.render("X", 1, ROT)
|
tmp = font1.render("X", 1, ROT)
|
||||||
@@ -173,6 +178,7 @@ while(gamestate==True):
|
|||||||
pacman_pos_label = font1.render(F"x:{pacman_posx} y:{pacman_posy}", 1, SCHWARZ)
|
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)
|
fps_label = font1.render(F"FPS: {int(clock.get_fps())}", 1, SCHWARZ)
|
||||||
|
|
||||||
|
if debug_mode:
|
||||||
MAINSCREEN.blit(pacman_pos_label, (CENTER_X,MAINSCREEN_SIZE[1]-40))
|
MAINSCREEN.blit(pacman_pos_label, (CENTER_X,MAINSCREEN_SIZE[1]-40))
|
||||||
MAINSCREEN.blit(fps_label, (CENTER_X - 150,MAINSCREEN_SIZE[1]-40))
|
MAINSCREEN.blit(fps_label, (CENTER_X - 150,MAINSCREEN_SIZE[1]-40))
|
||||||
MAINSCREEN.blit(hash_label, (10, MAINSCREEN_SIZE[1]-40))
|
MAINSCREEN.blit(hash_label, (10, MAINSCREEN_SIZE[1]-40))
|
||||||
|
|||||||
Reference in New Issue
Block a user