26 lines
725 B
Python
26 lines
725 B
Python
import pygame
|
|
from settings import *
|
|
|
|
|
|
class Tile:
|
|
def __init__(self, id, name, solid, color, hardness=1.0, drop=None):
|
|
self.id = id
|
|
self.name = name
|
|
self.solid = solid
|
|
self.color = color
|
|
self.hardness = hardness
|
|
self.drop = drop # item id dropped when broken
|
|
|
|
|
|
# Register tiles here
|
|
TILE_TYPES = {
|
|
AIR: Tile(AIR, "Air", False, (0, 0, 0), hardness=0),
|
|
DIRT: Tile(DIRT, "Dirt", True, (139, 69, 19), hardness=0.3, drop=DIRT),
|
|
GRASS: Tile(GRASS, "Grass", True, (34, 177, 76), hardness=0.3, drop=DIRT),
|
|
STONE: Tile(STONE, "Stone", True, (100, 100, 100), hardness=0.8, drop=STONE),
|
|
}
|
|
|
|
|
|
def get_tile(tile_id):
|
|
return TILE_TYPES.get(tile_id, TILE_TYPES[AIR])
|