Commit graph

252 commits

Author SHA1 Message Date
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
e3864d8468 Implement LE, LT, GE, GT on Point 2023-03-05 14:24:44 -08:00
af3d93ba11 Fix up how Maps are rendered in MapWindows
There was a bug in how MapWindow was calculating the numpy array slices
when drawing the map. Redo how this works so that MapWindow can draw
maps of arbitrary size and center maps that are smaller than the window's
drawable area.
2023-03-05 13:37:51 -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
84e51a17ff Specify map size of 80x24 2023-03-05 13:35:47 -08:00
368f780fcd Enable UI debug logging 2023-03-05 13:35:35 -08:00
85928a938d Some geometry updates
- Add Point.numpy_index to simplify converting Points to indexes
- Update the doc string of Point.direction_to_adjacent_point
- Add a Rect.__contains__ implementation for another Rect
- Refactor the contains implementations above into helper methods
2023-03-05 13:35:25 -08:00
c488ef9c2b Add doc string for Configuration attributes 2023-03-05 10:49:02 -08:00
e2553cca3b Clean up RoomGenerator.Configuration 2023-03-04 11:08:11 -08:00
b9c45f44b2 Clean up the doc comment on Entity 2023-03-04 11:07:32 -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
be7198b16d Update the doc string of Rect.inset_rect 2023-02-20 18:00:41 -08:00
6aefff838d Implement Rect.__contains__ on a Point
Returns True if the Rect contains the point.
2023-02-20 18:00:29 -08:00
b8e7e3d059 Clean up log module documentation 2023-02-20 17:11:55 -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
445c600bf9 Add a doc string to Rect.corners 2023-02-19 19:08:32 -08:00
22ad73af0b Fix Rect.corners based on the unit test 2023-02-19 19:06:24 -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
885868f39e Add a test for RectangularRoom.wall_points 2023-02-19 18:18:40 -08:00
5470ea697c Add a test for Rect.corners 2023-02-19 18:18:09 -08:00
64844d124b A couple fixes in items.py
Reformat the items in items.py
Fix the type declaration of Item.background_color
2023-02-18 22:57:37 -08:00
30727ccac1 Add a test for Point.is_adjacent_to 2023-02-18 22:55:41 -08:00
37ffa423b6 Pass the whole Map into MapGenerator.generate 2023-02-18 22:55:20 -08:00
7428d95126 Fix the implementation of Point.is_adjacent_to 2023-02-18 22:51:58 -08:00
06d34a527b Add Point.manhattan_distance_to
Returns the manhattan distance to another Point.
2023-02-18 22:51:42 -08:00
462eebd95c Add Rect.corners
An iterator over the corners of the rectangle
2023-02-18 22:51:19 -08:00
306d6fd13f Add pytest unit tests 2023-02-18 10:49:35 -08:00
8fc5206e95 Ignore .venv directory in the VSCode workspace 2023-02-18 10:40:55 -08:00
292fa852f9 Add non-Sandbox launch target 2023-02-18 10:40:36 -08:00
d5e8891545 Add back some imports to map/room.py 2023-02-15 08:36:43 -08:00
e377b3d7b6 Change the name of the Sandbox scheme to indicate it's the Sandbox scheme 2023-02-15 08:26:01 -08:00
4050ac5c6f Add a bunch of doc strings and header comments to files 2023-02-15 08:25:40 -08:00
633580e27a Add Rect.edges
Iterates the minimum and maximum x and y edges for the Rect.
2023-02-15 08:22:32 -08:00
e6c4717e80 Let the Hero specify its own sight radius 2023-02-15 08:21:49 -08:00
77fc9467bc Fix accidentally breaking QuitAction
When I added some type safety to Engine.process_input_action, I just
dropped any action without an actor.
2023-02-12 19:48:45 -08:00
356e205f2c Implement viewport tracking for the MapWindow
As the player moves the hero, the MapWindow will try to keep the
hero in the middle of the view.
2023-02-12 19:47:27 -08:00
402e910915 Add Map.bounds 2023-02-12 19:45:12 -08:00
0a6ff23dcd Bigger maps! 2023-02-12 19:44:52 -08:00
b5f25822df Add a UI log 2023-02-12 19:44:41 -08:00
36206b5cc0 Clean up __add__ on Point; add __sub__
The dunder add method only ever had one overload, so you don't need to
declare an overload
2023-02-12 19:44:28 -08:00
7e00f58a40 Refactor Action into Action and ActionWithActor
The base class Actor doesn't declare a (optional) actor attribute.
The ActionWithActor has a non-optional actor attribute.

This makes the type checker happier, and means we can have some actions
that don't have actors.
2023-02-12 16:34:37 -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
ec28f984da Add a couple geometry methods
- Vector.from_point to convert a point to a vector
- Rect.width and Rect.height convenience properties
2023-02-12 15:52:26 -08:00