WIP
This commit is contained in:
parent
721fc3b41e
commit
2f7f2c3c4f
11
README.md
11
README.md
@ -2,16 +2,11 @@
|
||||
|
||||
## Concept
|
||||
|
||||
The "water meter" is always visible, and ticks down each time you take an action. When it hits zero, you die.
|
||||
"Fun value", inspired by Undertale, activates different secrets at different times.
|
||||
|
||||
This will probably see some iteration.
|
||||
|
||||
## Link
|
||||
## Links
|
||||
|
||||
https://python-tcod.readthedocs.io/en/latest/
|
||||
|
||||
I'm working from this:
|
||||
https://rogueliketutorials.com/
|
||||
|
||||
https://rogueliketutorials.com/tutorials/tcod/v2/part-4/
|
||||
|
||||
FUN value, 0-255?
|
@ -4,13 +4,15 @@ from tcod.context import Context
|
||||
from tcod.console import Console
|
||||
|
||||
from entity import Entity
|
||||
from floor_map import FloorMap #TODO: replace with "DungeonMap"
|
||||
|
||||
class Engine:
|
||||
def __init__(self):
|
||||
def __init__(self, floor_map: FloorMap):
|
||||
from event_handler import EventHandler
|
||||
self.event_handler = EventHandler(self)
|
||||
|
||||
self.player = Entity(0, 0, "@", (255, 255, 255))
|
||||
self.floor_map = floor_map
|
||||
|
||||
def handle_events(self, events: Iterable[Any]) -> None:
|
||||
for event in events:
|
||||
@ -22,11 +24,7 @@ class Engine:
|
||||
action.apply(Engine)
|
||||
|
||||
def render(self, context: Context, console: Console) -> None:
|
||||
#TODO: render map
|
||||
|
||||
#TODO: render entities
|
||||
# for entity in self.entities:
|
||||
# console.print(entity.x, entity.y, entity.char, fg=entity.color)
|
||||
self.floor_map.render(console)
|
||||
|
||||
console.print(self.player.x, self.player.y, self.player.char, fg=self.player.color)
|
||||
|
||||
|
17
source/floor_map.py
Normal file
17
source/floor_map.py
Normal file
@ -0,0 +1,17 @@
|
||||
import numpy as np
|
||||
|
||||
from tcod.console import Console
|
||||
|
||||
import tile_types
|
||||
|
||||
class FloorMap:
|
||||
def __init__(self, width: int, height: int):
|
||||
self.width = width
|
||||
self.height = height
|
||||
self.tiles = np.full((width, height), fill_value=tile_types.wall, order="F")
|
||||
|
||||
def in_bounds(self, x: int, y: int) -> bool:
|
||||
return 0 <= x < self.width and 0 <= y < self.height
|
||||
|
||||
def render(self, console: Console) -> None:
|
||||
console.rgb[0:self.width, 0:self.height] = self.tiles["dark"]
|
@ -1,6 +1,8 @@
|
||||
#!./bin/python
|
||||
import tcod
|
||||
|
||||
from floor_map import FloorMap #TODO: replace with "DungeonMap"
|
||||
|
||||
from engine import Engine
|
||||
|
||||
def main() -> None:
|
||||
@ -8,8 +10,8 @@ def main() -> None:
|
||||
tileset = tcod.tileset.load_tilesheet("assets/dejavu10x10_gs_tc.png", 32, 8, tcod.tileset.CHARMAP_TCOD)
|
||||
|
||||
context = tcod.context.new(
|
||||
columns = 40,
|
||||
rows = 20,
|
||||
columns = 80,
|
||||
rows = 45,
|
||||
tileset = tileset,
|
||||
title = "Stepwise Roguelike",
|
||||
vsync = True
|
||||
@ -17,15 +19,15 @@ def main() -> None:
|
||||
|
||||
w, h = context.recommended_console_size(min_columns=10, min_rows=10)
|
||||
|
||||
print(w, h)
|
||||
|
||||
console = tcod.console.Console(
|
||||
width = w,
|
||||
height = h,
|
||||
order = "F"
|
||||
)
|
||||
|
||||
engine = Engine()
|
||||
floor_map = FloorMap(80, 45) # same as context settings
|
||||
|
||||
engine = Engine(floor_map)
|
||||
|
||||
# game loop
|
||||
while True:
|
||||
|
39
source/tile_types.py
Normal file
39
source/tile_types.py
Normal file
@ -0,0 +1,39 @@
|
||||
from typing import Tuple
|
||||
|
||||
import numpy as np
|
||||
|
||||
#datatypes
|
||||
graphics_dt = np.dtype(
|
||||
[
|
||||
("ch", np.int32),
|
||||
("fg", "3B"),
|
||||
("bg", "3B"),
|
||||
]
|
||||
)
|
||||
|
||||
tile_dt = np.dtype(
|
||||
[
|
||||
("walkable", np.bool),
|
||||
("transparent", np.bool),
|
||||
("light", graphics_dt), #when this tile is in FOV
|
||||
("dark", graphics_dt), #when this tile is *not* in FOV
|
||||
]
|
||||
)
|
||||
|
||||
def new_tile(*, walkable: np.bool, transparent: np.bool, light: graphics_dt, dark: graphics_dt):
|
||||
return np.array((walkable, transparent, light, dark), dtype = tile_dt)
|
||||
|
||||
#list of tile types
|
||||
wall = new_tile(
|
||||
walkable=False,
|
||||
transparent=False,
|
||||
light=(ord('#'), (200, 200, 200), (0, 0, 0)),
|
||||
dark =(ord('#'), (100, 100, 100), (0, 0, 0)),
|
||||
)
|
||||
|
||||
floor = new_tile(
|
||||
walkable=True,
|
||||
transparent=True,
|
||||
light=(ord('.'), (200, 200, 200), (0, 0, 0)),
|
||||
dark =(ord('.'), (100, 100, 100), (0, 0, 0)),
|
||||
)
|
Loading…
x
Reference in New Issue
Block a user