Commit graph

36 commits

Author SHA1 Message Date
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
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
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
7ee790e25e Remove all the old mouse point stuff from Engine 2023-03-07 22:27:21 -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
fd068268f5 Move the BSP implementation to BSPRectMethod 2023-03-06 19:33: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
47014d4e6e Move field of view updates to Map.update_field_of_view 2023-02-19 18:37:14 -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
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
b0b75f7e76 Use RandomRect room generator and Elbow corridor generator for the map 2023-02-12 14:32:32 -08:00
8aa329d368 Increase sight radius to 30 (from 8) 2023-02-12 14:30:53 -08:00
1aa6d14540 Fix some type checker errors by moving an assert above where the property is accessed 2023-02-12 14:30:40 -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
2f9864edd8 Start the hero on the down stairs of the level 2023-02-10 22:37:26 -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
dabc9e70dd PEP8 formatter changes 2023-02-09 16:12:46 -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
90994cafd7 Import Action and ActionResult from actions submodules 2022-05-29 21:24:31 -07:00
31bec25dcf Add a docstring to engine.Configuration 2022-05-16 20:49:42 -07:00
e5485300ef Rename interface.bar.Bar -> interface.percentage_bar.PercentageBar 2022-05-16 16:47:21 -07:00
18a068cff6 Add some more basic colors and some semantic colors for the Health Bar 2022-05-16 16:40:29 -07:00
85569595a9 FIX THE COLLISION DETECTION BUG 2022-05-15 19:58:39 -07:00
d4e4684694 Show Entity under mouse cursor in a line above the hit points 2022-05-15 16:50:24 -07:00
72cbd15fb0 Render the MessageLog and clean up the interface (lots of math errors here) 2022-05-15 13:58:26 -07:00
090272854d Add a turn count that increments after successfully handling actions for that turn 2022-05-15 13:13:12 -07:00
5a9df0a322 Add my first interface element: a Bar!
It renders a bar of a certain width and a percentage full. Use it to render HP.

Add a new Python package called interface. The Bar class lives there. Also add a
bunch of color defintions to a module called interface.color.
2022-05-15 00:12:05 -07:00
388754e5dd When the Hero dies, swap MainGameEventHandler for GameOverEventHandler 2022-05-14 23:43:38 -07:00
5b0b33782f Move handling hero actions and entity actions to the Engine 2022-05-14 23:41:43 -07:00
c44c4e7bc6 Move the event loop to Engine.run_event_loop() 2022-05-14 23:39:03 -07:00
ce63c825b0 Move all the logging to log.py and prefix all the log names with "erynrl" 2022-05-12 20:40:15 -07:00
f6fe9d0f09 Move the roguebasin package to erynrl 2022-05-12 09:05:27 -07:00
Renamed from roguebasin/engine.py (Browse further)