diff --git a/app.py b/app.py index 48fdcd4..4a66a71 100644 --- a/app.py +++ b/app.py @@ -19,7 +19,7 @@ def initBoard(): for i in range(prefs.GRID_SIZE): row = [] for j in range(prefs.GRID_SIZE): - cell = Cell(i, j) + cell = Cell(i, j, 1) row.append(cell) cells.append(row) @@ -39,12 +39,21 @@ def initBoard(): cells[6][2].interactableItem = Table(cells[6][2], "Table") cells[4][2].interactableItem = Table(cells[4][2], "Table") + + cells[9][9].waga = 2 + cells[9][8].waga = 2 + cells[9][7].waga = 2 + cells[10][6].waga = 2 + cells[7][7].waga = 2 + + def draw_grid(window, cells, agent): for i in range(prefs.GRID_SIZE): for j in range(prefs.GRID_SIZE): cells[i][j].update(window) if(cells[i][j].interactableItem): cells[i][j].interactableItem.update(window) + cells[i][j].blit_text(cells[i][j].waga, i*50+6, j*52+6, 12,window) font = pygame.font.SysFont('Comic Sans MS', 30) scoreText = font.render("Score: {}".format(str(round(agent.score,2))), 1, (0, 0, 0)) multiplierText = font.render("Multiplier: {}".format(str(round(agent.multiplier,2))), 1, (0, 0, 0)) @@ -81,9 +90,9 @@ agent = Agent(prefs.SPAWN_POINT[0], prefs.SPAWN_POINT[1], cells) #target_x, target_y = 5,2 #target_x, target_y = 7,2 #target_x, target_y = 8,2 -target_x, target_y = 4,8 +#target_x, target_y = 4,8 #target_x, target_y = 0,9 -#target_x, target_y = 9,11 +target_x, target_y = 9,11 #target_x, target_y = 4,11 #target_x, target_y = 6,3 #target_x, target_y = 11,11 diff --git a/classes/cell.py b/classes/cell.py index 9cdff30..57c40bb 100644 --- a/classes/cell.py +++ b/classes/cell.py @@ -1,9 +1,11 @@ import pygame import prefs + class Cell: - def __init__(self, x, y, blocking_movement=False, interactableItem=False, texture=None): + def __init__(self, x, y,waga, blocking_movement=False, interactableItem=False, texture=None): self.X = x self.Y = y + self.waga = waga self.rect = pygame.Rect(x * prefs.CELL_SIZE, y * prefs.CELL_SIZE, prefs.CELL_SIZE, prefs.CELL_SIZE) self.blocking_movement = blocking_movement self.interactableItem = interactableItem @@ -11,6 +13,13 @@ class Cell: self.prepareTexture(texture) else: self.texture = texture + + def blit_text(self,tekst, x, y, rozmiar_czcionki,window): + font = pygame.font.Font('freesansbold.ttf', rozmiar_czcionki) + text = font.render(str(tekst), True, (0, 255, 0), (0, 0, 128)) + textRect = text.get_rect() + textRect.center = (x,y) + window.blit(text, textRect) def prepareTexture(self, texture): preparedTexture = pygame.image.load(texture).convert_alpha() diff --git a/prefs.py b/prefs.py index fe43e61..d7aee39 100644 --- a/prefs.py +++ b/prefs.py @@ -3,5 +3,7 @@ HEIGHT = WIDTH GRID_SIZE = 12 CELL_SIZE = WIDTH // GRID_SIZE SPAWN_POINT = (5, 5) -COLORS = [(255, 0, 0), (0, 255, 0), (0, 0, 255), (255, 255, 0), (255, 0, 255), (0, 255, 255), (128, 0, 128), (255, 165, 0), (0, 128, 128), (128, 128, 0)] +COLORS = [(130, 200, 200)] + +