added traps and HP-Postions

This commit is contained in:
Lukas Nöllemeyer 2024-08-21 18:14:56 +02:00
parent 96895c5ce5
commit 23d95c4b2f
2 changed files with 30 additions and 7 deletions

View file

@ -9,7 +9,7 @@ from tcod.map import Map
import g
from game.components import Action, Gold, Graphic, Position
from game.components import HP, Action, Gold, Graphic, Position
from game.tags import IsActor, IsItem, IsPlayer, IsWalllike
world_center: Final = Position(50, 50)
@ -51,7 +51,8 @@ def new_world() -> Registry:
components={
Position: player_pos,
Graphic: Graphic(ch=ord('@'), fg=(255, 0, 0, 255), bg=(255, 255, 255, 0)),
Gold: 0
Gold: 0,
HP: 100,
},
tags=[IsActor, IsPlayer]
)
@ -59,7 +60,8 @@ def new_world() -> Registry:
world.new_entity(
components={
Position: Position(0, 5),
Graphic: Graphic(ch=ord('G'), fg=(100,100,0, 255))
Graphic: Graphic(ch=ord('G'), fg=(100,100,0, 255)),
HP: 20,
},
tags=[IsActor]
)
@ -69,10 +71,19 @@ def new_world() -> Registry:
components={
Position: Position(rng.randint(0, 20), rng.randint(0, 20)),
Graphic: Graphic(ord("$"), fg=(255, 255, 0, 255)),
Gold: rng.randint(1, 10)
Gold: rng.randint(1, 10),
},
tags=[IsItem]
)
if rng.choice([True, False]):
world.new_entity(
components={
Position: Position(rng.randint(0, 10), rng.randint(0, 20)),
Graphic: Graphic(ord("t"), (255, 0, 0, 255)),
HP: rng.randint(-5, 5),
},
tags=[IsItem]
)
for i in range(20):
if i == 5 or i == 9: