diff --git a/board b/board index 61d273c..0c91d78 100644 --- a/board +++ b/board @@ -2,9 +2,15 @@ import sys import pygame screen = [] +objectArray = [] +class Agent: + def __init__(self, name, xPos, yPos): + self.name = name + self.xPos = xPos + self.yPos = yPos -def draw(square_num): +def draw(square_num, objectArr): #następne dwie linijki do odkomentowania, jak będzie wgrane zdjęcie do tła #background = pygame.image.load("ścieżka do pliku").convert() #tu ścieżka do zdjęcia w tle #screen.blit(background, (0, 0)) @@ -26,22 +32,44 @@ def draw(square_num): pygame.draw.line(screen, grid_color, (a + grid_size, b), (a + grid_size, b + grid_size), 2) + ## tutaj rysujemy agenta i inne obiekty juz na gotowej mapie -def close(): #by móc zamnkąć okno iksem + ## RYSUJEMY AGENTA + agent_color = (255, 0, 0) + circleX = objectArr[0].xPos * square + square / 2 + circleY = objectArr[0].yPos * square - square / 2 + radius = 10 + pygame.draw.circle(screen, agent_color, (a + circleX, b + circleY), radius) + +def kb_listen(objectArray, gridLength): for event in pygame.event.get(): + if event.type == pygame.KEYDOWN: + if event.key == pygame.K_LEFT and objectArray[0].xPos > 0: + objectArray[0].xPos = objectArray[0].xPos - 1 + if event.key == pygame.K_RIGHT and objectArray[0].xPos < gridLength - 1: + objectArray[0].xPos = objectArray[0].xPos + 1 + if event.key == pygame.K_UP and objectArray[0].yPos > 1: + objectArray[0].yPos = objectArray[0].yPos - 1 + if event.key == pygame.K_DOWN and objectArray[0].yPos < gridLength: + objectArray[0].yPos = objectArray[0].yPos + 1 if event.type == pygame.QUIT: sys.exit() if __name__ == '__main__': pygame.init() #inicjalizacja modułów, na razie niepotrzebna + + #Tworzymy nowego playera, czy tam agenta + agent = Agent("smieciarka", 5, 7) + objectArray.append(agent) + width = 600 height = 530 screen = pygame.display.set_mode((width, height)) #ustalanie rozmiarów okna - c = (245, 12, 35) #tymczasowy kolor tła - do usunięcia, jak już będzie zdjęcie - screen.fill(c) while 1: - draw(10) - close() + c = (255, 255, 255) #tymczasowy kolor tła - do usunięcia, jak już będzie zdjęcie + screen.fill(c) + draw(15, objectArray) + kb_listen(objectArray, 15) pygame.display.update() #by krata pojawiła się w okienku - update powierzchni \ No newline at end of file