refactor(tile_init): set type based on random vegetable
This commit is contained in:
parent
8ce604df46
commit
7de410c59a
14
src/tile.py
14
src/tile.py
@ -6,22 +6,24 @@ import pytholog as pl
|
||||
import random
|
||||
|
||||
class Tile(pygame.sprite.Sprite):
|
||||
def __init__(self, id, type, field):
|
||||
def __init__(self, id, field, type):
|
||||
super().__init__()
|
||||
self.id = id
|
||||
x = id%16
|
||||
y = id//16
|
||||
|
||||
vegetable_types = tractor_kb.query(pl.Expr("warzywo(X)"))
|
||||
random_vegetable = vegetable_types[random.randint(0, len(vegetable_types)-1)]['X']
|
||||
|
||||
self.type = type
|
||||
self.field = field
|
||||
|
||||
vegetables = tractor_kb.query(pl.Expr("warzywo(Nazwa_warzywa)"))
|
||||
random_vegetable = vegetables[random.randint(0, len(vegetables)-1)]['Nazwa_warzywa']
|
||||
self.set_type(random_vegetable)
|
||||
self.rect = self.image.get_rect()
|
||||
|
||||
self.faza = 'posadzono'
|
||||
|
||||
# you can set TILE_SIZE in the .env file to adjust the window size
|
||||
load_dotenv(find_dotenv())
|
||||
TILE_SIZE = int(os.getenv("TILE_SIZE"))
|
||||
self.rect = self.image.get_rect()
|
||||
self.rect.topleft = (x * TILE_SIZE, y * TILE_SIZE)
|
||||
|
||||
def draw(self, surface):
|
||||
|
Loading…
Reference in New Issue
Block a user