3
1
inteligenty-traktor/src/tile.py

38 lines
1.0 KiB
Python

import os
import pygame
from kb import tractor_kb
import pytholog as pl
import random
from config import TILE_SIZE
class Tile(pygame.sprite.Sprite):
def __init__(self, id, field, type):
super().__init__()
self.id = id
x = id%16
y = id//16
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.faza = 'posadzono'
self.rect = self.image.get_rect()
self.rect.topleft = (x * TILE_SIZE, y * TILE_SIZE)
def draw(self, surface):
self.tiles.draw(surface)
def set_type(self, type):
self.type = type
# if self.type == 'grass':
# self.image = pygame.image.load("images/grass.png").convert()
self.image = pygame.image.load("images/grass.png").convert()
self.image = pygame.transform.scale(self.image, (TILE_SIZE, TILE_SIZE))