2020-04-06 12:30:21 +02:00
|
|
|
from pathlib import Path
|
|
|
|
|
2020-04-03 19:36:13 +02:00
|
|
|
import pygame
|
|
|
|
|
2020-05-09 22:30:21 +02:00
|
|
|
# TODO: Relative coords
|
2020-04-03 19:36:13 +02:00
|
|
|
class TerrainTile(pygame.sprite.Sprite):
|
2020-04-25 23:33:55 +02:00
|
|
|
def __init__(self, x, y, texture, tileSize, cost):
|
2020-04-03 23:07:12 +02:00
|
|
|
super().__init__()
|
2020-04-06 12:30:21 +02:00
|
|
|
terrainTexturesPath = Path("./data/images/terrain").resolve()
|
|
|
|
self.image = pygame.image.load(str(terrainTexturesPath / texture)).convert()
|
2020-04-03 23:07:12 +02:00
|
|
|
self.image = pygame.transform.scale(self.image, (tileSize, tileSize))
|
2020-04-03 19:36:13 +02:00
|
|
|
self.rect = self.image.get_rect()
|
2020-04-05 19:08:08 +02:00
|
|
|
self.x = x
|
|
|
|
self.y = y
|
|
|
|
self.rect.x = x * tileSize
|
|
|
|
self.rect.y = y * tileSize
|
2020-04-25 23:33:55 +02:00
|
|
|
self.cost = cost
|
2020-04-25 23:18:29 +02:00
|
|
|
|