Commit graph

41 commits

Author SHA1 Message Date
b0d91c9c5d 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
2023-03-11 00:06:47 -08:00
eda44a8792 Rename the Map's Point question methods to use "point" instead of "tile" 2023-03-08 08:57:20 -08:00
2d82d9834f Do pathfinding from the hero to the mouse point
It works finally! And uses A*!
2023-03-07 22:18:31 -08:00
ee1c6f2222 Remove the RandomRectRoomGenerator 2023-03-06 19:33:50 -08:00
fd068268f5 Move the BSP implementation to BSPRectMethod 2023-03-06 19:33:34 -08:00
635aea5e3b Add cellular atomata to the map generator finally!
Use the new map generator mechanism to generate rooms via cellular
atomata. Create a new CellularAtomatonRoomMethod class that uses
the Cellular Atomton class to create a room. Add a FreefromRoom class
that draws a room based on an ndarray of tiles.

Along the way I discovered I have misunderstood how numpy arrays
organize rows and columns. The numpy array creation routines take an
'order' argument that specifies whether arrays should be in C order (row
major) or Fortran order (column major). Fortran order lets you index
arrays with a more natural [x, y] coordinate order, and that's what the
tutorials I've read have shown. So I've been using that. When I was
developing the Cellular Atomaton, I wrote some code that assumed row-
major order. I think I want to move everything to row-major / C-style,
but that will take a bit more time.
2023-03-05 18:40:02 -08:00
dd8b0364e0 Break RoomGenerators into Rect and Room methods
A RoomGenerator is now made up of two "method" classes that do separate
things:

1. A RectMethod takes the size of the area to generate and creates an
   iterable stream of Rects to fill that area.
2. A RoomMethod takes a Rect and creates a room inside of it.

These two components are composable in interesting ways, and allow a
more data-driven approach to map generation, though I don't yet have the
ability to make this mechansim entirely data-driven.
2023-03-05 16:53:00 -08:00
c17258bd73 Some x/y -> numpy_index changes 2023-03-05 14:26:52 -08:00
744c63bc85 Sort rooms before generating corridors between them 2023-03-05 14:26:20 -08:00
42cfb78ba3 Raise exceptions for out-of-bounds points that are passed into Map helper methods 2023-03-05 13:36:32 -08:00
4b09d467d1 Document map.grid 2023-03-05 13:36:04 -08:00
e2553cca3b Clean up RoomGenerator.Configuration 2023-03-04 11:08:11 -08:00
a83b85b7a0 Add one stray import to map.generator.room 2023-02-20 18:02:21 -08:00
a542bb956a Add CellularAtomataMapGenerator
First pass at a cellular atomata map generator.

Add map.grid and a make_grid function to make it easier to make
numpy arrays for Map purposes.

Add ca.py to test the generator.
2023-02-20 18:02:01 -08:00
09480e7499 Fix up some imports in map.room 2023-02-19 19:13:31 -08:00
706a244382 Fix up some imports in map.generator.room 2023-02-19 19:13:19 -08:00
47014d4e6e Move field of view updates to Map.update_field_of_view 2023-02-19 18:37:14 -08:00
9bd287dc9f Add Map.__str__ 2023-02-19 18:34:59 -08:00
21c3b5d94f Small bit of reformatting and type checking 2023-02-19 18:22:45 -08:00
37ffa423b6 Pass the whole Map into MapGenerator.generate 2023-02-18 22:55:20 -08:00
d5e8891545 Add back some imports to map/room.py 2023-02-15 08:36:43 -08:00
4050ac5c6f Add a bunch of doc strings and header comments to files 2023-02-15 08:25:40 -08:00
402e910915 Add Map.bounds 2023-02-12 19:45:12 -08:00
8efd3ce207 Refactor map rendering
- Move all map rendering to a new MapWindow class
- Clip map rendering to the bounds of the Window
- Pass in Entities list from the Engine and render them relative to the window

The map doesn't scroll yet, so it'll always be clipped on the bottom and
right.
2023-02-12 15:55:01 -08:00
d8275725b8 Allow many more (30) attempts at generating a random rect for the RandomRectRoomGenerator 2023-02-12 14:28:42 -08:00
cf31bcc272 Create a more semantic Size.numpy_shape property 2023-02-12 14:28:14 -08:00
06ae79ccd0 Redo the configuration metchanism
- Allow passing a font on the command line via --font
- Move the engine configuration to its own module
- Redo entirely the font configuration: move it to the configuration module
- Pass the configuration object to the Map in place of the size argument
2023-02-12 14:24:36 -08:00
6780b0495c Move all the interface stuff to interface.Interface
Draw three windows with frames:
- map window
- info window (hit point bar; turn count)
- message window

Clean up the UI code in the Engine.
2023-02-11 01:21:52 -08:00
6c9d01771f Draw a path from the hero to the current mouse point
Add a highlight grid to Map, with locations set to True if that point should be
drawn with a "highlight" treatment.

Add the highlight graphic_dtype to all Tiles.
2023-02-10 22:37:21 -08:00
f05dfdef55 PEP8 formatter changes 2023-02-10 21:25:00 -08:00
0d0c5a2b35 Remove this unused DefaultConfiguration class variable 2023-02-10 21:13:16 -08:00
85b059dbd4 Add two new room generators
- OneBigRoomGenerator
- RandomRectRoomGenerator
2023-02-10 21:12:42 -08:00
9d00f3b638 Promote BSPRoomGenerator.Configuration to RoomGenerator.Configuration
This configuration object can actually apply to all room generators.

Notably: copy the default configuration object before setting it to self.configuration.
2023-02-10 21:12:12 -08:00
c59dc1b907 Break up room and corridor generation into generate and apply phases
- Generate creates rooms and corridors, and apply applies them to a tile grid.
- Add up and down stairs generation to the Room Generators.
- Clean up Room.wall_points and Room.floor_points to make it easier to
  write a generic apply() method on RoomGenerator
2023-02-10 21:07:50 -08:00
771926088c Remove an unused import 2023-02-09 21:04:26 -08:00
fff3260d01 Give MapGenerator up_stairs and down_stairs properties 2023-02-09 21:00:51 -08:00
d9aa8097c5 Add StairsUp and StairsDown tile types 2023-02-09 20:57:51 -08:00
ac5efa7518 PEP8 formatting in map.tile 2023-02-09 20:57:37 -08:00
8e9b130ba7 Fix the ordering of imports in map/__init__.py 2023-02-09 20:54:40 -08:00
9a04692539 Refactor map generator package
- Move room generators to map.generators.room
- Move corridor generators to map.generators.corridor

Generators have a generate() method that generates the things they place,
and an apply() method that applies their objects to a grid of tiles.
2023-02-09 16:07:29 -08:00
1df7cea2ad Move map modules to their own directory 2023-02-08 08:36:00 -08:00