Код IT
← Каталог

Python — диаблоид — Этап 5 — тайлы и процедурная карта

Фрагмент из «Python — диаблоид»: Этап 5 — тайлы и процедурная карта.

python spinoffencyclopedia9-04-razrabotka-igr-praktikum-razrabotki-igr-6 embed URL статья в энциклопедии
Python main.py
from dataclasses import dataclass
from core.config import TileType


@dataclass
class Tile:
    type: TileType = TileType.VOID
    walkable: bool = False

    @classmethod
    def floor(cls) -> "Tile":
        return cls(TileType.FLOOR, True)

    @classmethod
    def wall(cls) -> "Tile":
        return cls(TileType.WALL, False)

    @classmethod
    def start(cls) -> "Tile":
        t = cls(TileType.START, True)
        return t

    @classmethod
    def exit(cls) -> "Tile":
        t = cls(TileType.EXIT, True)
        return t
from dataclasses import dataclass
from core.config import TileType


@dataclass
class Tile:
    type: TileType = TileType.VOID
    walkable: bool = False

    @classmethod
    def floor(cls) -> "Tile":
        return cls(TileType.FLOOR, True)

    @classmethod
    def wall(cls) -> "Tile":
        return cls(TileType.WALL, False)

    @classmethod
    def start(cls) -> "Tile":
        t = cls(TileType.START, True)
        return t

    @classmethod
    def exit(cls) -> "Tile":
        t = cls(TileType.EXIT, True)
        return t