inteligenty-traktor/program/tile.py
2024-03-09 20:02:19 +01:00

26 lines
653 B
Python

import os
import pygame
class Tile(pygame.sprite.Sprite):
def __init__(self, id, type, field):
super().__init__()
self.id = id
x = id%16
y = id//16
self.type = type
self.field = field
self.set_type(type)
self.rect = self.image.get_rect()
self.rect.topleft = (x * 64, y * 64)
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.transform.scale(self.image, (64, 64))