Commit graph

275 commits

Author SHA1 Message Date
a650e1db49 Clean up the context.new call in __main__ 2023-03-11 01:11:17 -08:00
327cc90b2e Remove QuitAction and ActionWithActor!
Move quit event handling to the interface and flatten the Action class
hierarchy. There are no longer any actions that don't take an Actor. This has
the happy side effect of resolving some pylint errors too. :)
2023-03-11 01:11:09 -08:00
02ed3d1e4a Add a title to the window :) 2023-03-11 01:00:09 -08:00
def79386d8 Move the renderable part of Entity to a Renderable component
Move symbol, render order, foreground, and background properties on Entity
to a new Component called Renderable.
2023-03-11 00:58:58 -08:00
01b549bc6e Remove the RegenerateRoomsAction 2023-03-11 00:57:48 -08:00
f78bc39e3b Clean up a few type checker things 2023-03-11 00:57:15 -08:00
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
e1523cd9c0 Some logging level adjustments
Move some loggers up to INFO. Disable propagation on erynrl.ui.
2023-03-10 23:54:36 -08:00
078520678d Figure out (finally!) the mouse coordinates in the MapWindow 2023-03-10 23:53:08 -08:00
1018febeab Fix a bug in Rect.__contains_point!
It was comparing point.y with the Rect's min_x.
2023-03-10 22:56:50 -08:00
879e0c680d Pylint: allow masking the 'map' builtin 2023-03-10 22:56:00 -08:00
eda44a8792 Rename the Map's Point question methods to use "point" instead of "tile" 2023-03-08 08:57:20 -08:00
7ee790e25e Remove all the old mouse point stuff from Engine 2023-03-07 22:27:21 -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
a8bbc47668 Move all interface Windows to their own modules in interface.window 2023-03-07 21:44:19 -08:00
1e678ff47d Promote .ui and .visible logging to WARN 2023-03-07 21:30:04 -08:00
003aedf30e Restructure event handling
Events start in the Interface. The interface gets first crack at any incoming
events. If the interface doesn't handle the event, it is given to the
engine. The engine has an EngineEventHandler that yields actions just
like the event handler prior to this change.

The interface's event handler passes events to each window in the
interface. Windows can choose to handle events however they like, and
they return a bool indicating whether the event was fully handled.
2023-03-07 21:29:28 -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
040803fe61 Add Rect.from_raw_values 2023-03-06 19:23:43 -08:00
edbc76d2ff Catch the ValueError when an AI asks if an out-of-bounds tile is walkable 2023-03-05 18:48:51 -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
e6327deeef Geometry classes are no longer frozen 2023-03-05 16:53:34 -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
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