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))