feat: cells have weight, you can see it
This commit is contained in:
parent
b7f186562b
commit
91a4e02c18
15
app.py
15
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
|
||||
|
@ -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
|
||||
@ -12,6 +14,13 @@ class Cell:
|
||||
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()
|
||||
preparedTexture = pygame.transform.scale(preparedTexture, (prefs.CELL_SIZE, prefs.CELL_SIZE))
|
||||
|
Loading…
Reference in New Issue
Block a user