Refactor how maps, rooms, and corridors are generated
- Rect and Room method objects no longer need to know the map size up front - The Map object has lists of interesting map features (I don't like this) - Room and corridor generators take the map itself as an argument to their generate and apply methods - Create a Corridor object to hold a list of points - Add a bunch of documentation here and there
This commit is contained in:
parent
e1523cd9c0
commit
b0d91c9c5d
6 changed files with 111 additions and 62 deletions
|
@ -6,7 +6,7 @@ parts of a map.
|
|||
'''
|
||||
|
||||
import random
|
||||
from typing import Iterable
|
||||
from typing import Iterable, List
|
||||
|
||||
import numpy as np
|
||||
import tcod
|
||||
|
@ -14,6 +14,7 @@ import tcod
|
|||
from ..configuration import Configuration
|
||||
from ..geometry import Point, Rect, Size
|
||||
from .generator import MapGenerator
|
||||
from .room import Corridor, Room
|
||||
from .tile import Empty, Shroud
|
||||
|
||||
|
||||
|
@ -29,9 +30,6 @@ class Map:
|
|||
shape = map_size.numpy_shape
|
||||
self.tiles = np.full(shape, fill_value=Empty, order='F')
|
||||
|
||||
self.up_stairs = generator.up_stairs
|
||||
self.down_stairs = generator.down_stairs
|
||||
|
||||
self.highlighted = np.full(shape, fill_value=False, order='F')
|
||||
|
||||
# Map tiles that are currently visible to the player
|
||||
|
@ -44,6 +42,12 @@ class Map:
|
|||
|
||||
generator.generate(self)
|
||||
|
||||
# Map Features
|
||||
self.rooms: List[Room] = []
|
||||
self.corridors: List[Corridor] = []
|
||||
self.up_stairs = generator.up_stairs
|
||||
self.down_stairs = generator.down_stairs
|
||||
|
||||
@property
|
||||
def bounds(self) -> Rect:
|
||||
'''The bounds of the map'''
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue