Added git-hash for better debugging
Added more pacman models Tried to animate them :D
This commit is contained in:
34
main.py
34
main.py
@@ -1,4 +1,6 @@
|
||||
import pygame
|
||||
import subprocess
|
||||
|
||||
|
||||
|
||||
pygame.init()
|
||||
@@ -36,14 +38,22 @@ pacman_posy = 0
|
||||
pacman_movespeed = 5
|
||||
pacman_startpoint = {0,0}
|
||||
pacman_size = 26
|
||||
pacman_animation = list()
|
||||
pacman_animation.append(pygame.image.load("models/pacman_1_1.png"))
|
||||
pacman_animation.append(pygame.image.load("models/pacman_1_2.png"))
|
||||
pacman_animation.append(pygame.image.load("models/pacman_1_3.png"))
|
||||
pacman_animation.append(pygame.image.load("models/pacman_1_4.png"))
|
||||
pacman_animation.append(pygame.image.load("models/pacman_1_5.png"))
|
||||
|
||||
#TODO Pacman Animation has to been added
|
||||
|
||||
|
||||
#Labels
|
||||
|
||||
short_hash = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).decode('ascii').strip()
|
||||
hash_label = font1.render(F"git-hash: {short_hash}", 1, SCHWARZ)
|
||||
|
||||
#Movement
|
||||
movedirection = {"up":False, "down":False, "left":False, "right":False}
|
||||
|
||||
map1 = list()
|
||||
movement_map = list()
|
||||
|
||||
@@ -79,6 +89,8 @@ 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
|
||||
|
||||
count = 0
|
||||
count2 = 0
|
||||
|
||||
while(gamestate==True):
|
||||
MAINSCREEN.fill(WEISS)
|
||||
@@ -128,8 +140,15 @@ while(gamestate==True):
|
||||
pacman_posx -= pacman_movespeed
|
||||
|
||||
|
||||
#print(pacman_animation)
|
||||
|
||||
MAINSCREEN.blit(pacman, (pacman_posx,pacman_posy))
|
||||
MAINSCREEN.blit(pacman_animation[count], (pacman_posx,pacman_posy))
|
||||
print(count2)
|
||||
|
||||
count += 1
|
||||
|
||||
if count == 5: count = 0
|
||||
|
||||
for row in map1:
|
||||
#print(row)
|
||||
MAINSCREEN.blit(row["object"], (row["x"],row["y"]))
|
||||
@@ -138,7 +157,10 @@ while(gamestate==True):
|
||||
if(movedirection[item]==True):
|
||||
print(F"Pacman-Position: x:{pacman_posx} y:{pacman_posy}")
|
||||
|
||||
|
||||
#Adds visual character for vaild movementpath (DEBUG ONLY)
|
||||
for coord in movement_map:
|
||||
tmp = font1.render("X", 1, ROT)
|
||||
MAINSCREEN.blit(tmp, (coord["x"], coord["y"]))
|
||||
|
||||
|
||||
pacman_pos_label = font1.render(F"x:{pacman_posx} y:{pacman_posy}", 1, SCHWARZ)
|
||||
@@ -146,9 +168,13 @@ while(gamestate==True):
|
||||
|
||||
MAINSCREEN.blit(pacman_pos_label, (CENTER_X,MAINSCREEN_SIZE[1]-40))
|
||||
MAINSCREEN.blit(fps_label, (CENTER_X - 150,MAINSCREEN_SIZE[1]-40))
|
||||
MAINSCREEN.blit(hash_label, (10, MAINSCREEN_SIZE[1]-40))
|
||||
|
||||
pygame.display.flip()
|
||||
clock.tick(60)
|
||||
count2 += 1
|
||||
if(count2 == 60):
|
||||
count2 = 0
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user