feat: table

This commit is contained in:
MlodyJ 2024-04-15 10:43:01 +02:00
parent 687a630576
commit e168f6d617
3 changed files with 23 additions and 1 deletions

7
app.py
View File

@ -2,6 +2,7 @@ import pygame
import prefs
from classes.beerKeg import BeerKeg
from classes.coffeMachine import CoffeMachine
from classes.table import Table
from pygame.locals import K_w, K_s, K_a, K_d
from classes.cell import Cell
from classes.agent import Agent
@ -33,6 +34,10 @@ def initBoard():
cells[6][4].interactableItem = BeerKeg(cells[6][4], "Beer Keg")
cells[4][10].interactableItem = CoffeMachine(cells[4][10], "Coffe Machine")
cells[9][10].interactableItem = Table(cells[9][10], "Table")
cells[8][2].interactableItem = Table(cells[8][2], "Table")
cells[6][2].interactableItem = Table(cells[6][2], "Table")
cells[4][2].interactableItem = Table(cells[4][2], "Table")
def draw_grid(window, cells, agent):
for i in range(prefs.GRID_SIZE):
@ -84,7 +89,7 @@ def get_neighbors(cell, cells):
#Wpisujemy miejsce w ktorym znajduje sie agent i miejsce docelowe do funkcji znajdujacej najkrotsza sciezke
start_cell = cells[5][5]
target_cell = cells[3][3]
target_cell = cells[11][7]
shortest_path = bfs(start_cell, target_cell, cells)

17
classes/table.py Normal file
View File

@ -0,0 +1,17 @@
from classes.interactable import Interactable
import pygame
import prefs
from classes.agent import Agent
class Table(Interactable):
def __init__(self, cell, name, sprite="sprites/table.png"):
super().__init__(cell, sprite)
self.sprite = pygame.image.load(sprite).convert_alpha()
self.sprite = pygame.transform.scale(self.sprite, (prefs.CELL_SIZE, prefs.CELL_SIZE))
self.name = name
def interact(self,agent):
if not isinstance(agent, Agent):
print("Agent must be of type Agent")
return

BIN
sprites/table.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 260 B