from settings import * class Tile: def __init__(self, tile_id, name, collidable, color, hardness=1.0, drop=None): self.id = tile_id self.name = name self.collidable = collidable self.color = color self.hardness = hardness self.drop = drop TILE_TYPES = { AIR: Tile(AIR, "Air", False, (0,0,0), hardness=0, drop=None), DIRT: Tile(DIRT, "Dirt", True, (139,69,19), hardness=0.4, drop=ITEM_STONE), GRASS: Tile(GRASS, "Grass", True, (34,177,76), hardness=0.4, drop=ITEM_STONE), STONE: Tile(STONE, "Stone", True, (100,100,100), hardness=0.8, drop=ITEM_STONE), WOOD: Tile(WOOD, "Wood", True, (160,82,45), hardness=0.5, drop=ITEM_WOOD), LEAVES: Tile(LEAVES, "Leaves", False, (34,139,34), hardness=0.2, drop=None), IRON_ORE: Tile(IRON_ORE, "Iron Ore", True, (180,180,180), hardness=1.2, drop=ITEM_IRON), GOLD_ORE: Tile(GOLD_ORE, "Gold Ore", True, (255,215,0), hardness=1.5, drop=ITEM_GOLD), COPPER_ORE: Tile(COPPER_ORE, "Copper Ore", True, (210,120,60), hardness=1.0, drop=ITEM_COPPER), COAL_ORE: Tile(COAL_ORE, "Coal Ore", True, (40,40,40), hardness=0.9, drop=ITEM_COAL), } # ---------------------------- # Compatibility for world.py # ---------------------------- TILE_PROPERTIES = { tile_id: { "solid": tile.collidable, "color": tile.color, "drop": tile.drop } for tile_id, tile in TILE_TYPES.items() } def get_tile(tile_id): return TILE_TYPES.get(tile_id, TILE_TYPES[AIR])