#importuje potřebné knihovny
import pygame, json
from pygame.locals import *


#loading
passLock = None
while passLock == None:
    mapLocation = input("Vložte umístění vašeho .TXT souboru s mapou: ")
    try:
        mapFile = open(mapLocation, "r")
        passLock =1
        fileType = "txt"
    except:
        print("Zadej prosím platné umístění")
        passLock = None





row = []
if fileType == "txt":
    counter = 0
    for line in mapFile:
        print(line)
        counter = counter + 1
        print(counter)

        hhh = line.split(",")
        if counter == 1:
            MatrixSize = [hhh[0], hhh[1]]
        elif counter == 2:
            StartCoordinates = [hhh[0], hhh[1]]
            Energy = hhh[2]
        elif counter == 3:
            FinishCoordinates = [hhh[0], hhh[1]]
       
        else:
            row.append(line)
            
        
    


#Započne hru a nastaví vlastvosti okna
pygame.init()

size = (int(MatrixSize[0])*32, int(MatrixSize[1])*32)
display = pygame.display.set_mode(size)
pygame.display.set_caption("Pac-Man")
bgColor = (255, 255, 255)
display.fill(bgColor)
pygame.display.update()

#Vytvoříme třídu objekt, ze které můžeme vytvořit pacmana, jídlo atd.
class PacMan:
    def __init__(self, position):
        self.image = pygame.image.load('pellet32.jpg')
        self.position = position

class Cake:
    def __init__(self, position, value):
        self.image = pygame.image.load('cake32.jpg')
        self.position = position
        self.value = value

class Bomb:
    def __init__(self, position, damege):
        self.image = pygame.image.load('bomb32.jpg')
        self.position = position
        self.damege = damege

class Wall:
    def __init__(self, position, height):
        self.image = pygame.image.load('wall32.jpg')
        self.position = position
        self.height = height
class Finish:
    def __init__(self, position):
        self.image = pygame.image.load('finish32.jpg')
        self.position = position
        
def displayObject(object):
    display.blit(object.image, (object.position[0], object.position[1]))
    pygame.display.update()

    
#hra
PacMan = PacMan(StartCoordinates)
Finish = Finish(FinishCoordinates)
displayObject(PacMan)
displayObject(Finish)

print("End")
