First steps
This commit is contained in:
parent
81190c687e
commit
1e731f5a80
191 changed files with 65 additions and 7 deletions
|
|
@ -4,16 +4,17 @@ from __future__ import annotations
|
|||
|
||||
from random import Random
|
||||
|
||||
from tcod.ecs import Registry
|
||||
import g
|
||||
|
||||
from tcod.ecs import Registry, Entity
|
||||
|
||||
from game.components import Gold, Graphic, Position
|
||||
from game.tags import IsActor, IsItem, IsPlayer
|
||||
from game.tags import IsActor, IsItem, IsPlayer, IsWall, IsDoor
|
||||
|
||||
|
||||
def new_world() -> Registry:
|
||||
"""Return a freshly generated world."""
|
||||
world = Registry()
|
||||
|
||||
rng = world[None].components[Random] = Random()
|
||||
|
||||
player = world[object()]
|
||||
|
|
@ -29,4 +30,21 @@ def new_world() -> Registry:
|
|||
gold.components[Gold] = rng.randint(1, 10)
|
||||
gold.tags |= {IsItem}
|
||||
|
||||
for i in range(20):
|
||||
if i == 5 or i == 9:
|
||||
door = world[object()]
|
||||
door.components[Position] = Position(10, i)
|
||||
door.components[Graphic] = Graphic(ord("\\"))
|
||||
door.tags |= {IsDoor}
|
||||
continue
|
||||
wall = world[object()]
|
||||
wall.components[Position] = Position(10, i)
|
||||
wall.components[Graphic] = Graphic(ord("#"))
|
||||
wall.tags |= {IsWall}
|
||||
|
||||
return world
|
||||
|
||||
|
||||
def unlock_door(door: Entity):
|
||||
door.components[Graphic] = Graphic(ord("_"))
|
||||
door.tags.discard(IsDoor)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue