Commit graph

76 commits

Author SHA1 Message Date
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
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
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
a709f3fba5 Detect when Shift is pressed and don't return a WaitAction when Shift+. is pressed 2023-02-12 14:29:45 -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
84f7bdb947 Little grammar fix in RenderOrder's doc comment 2023-02-12 14:24:56 -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
df4df06013 Fix this import in ai.py 2023-02-10 22:37:26 -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
f05dfdef55 PEP8 formatter changes 2023-02-10 21:25:00 -08:00
727a0737c6 Use integer division for Rect.mid_y and Rect.mid_x 2023-02-10 21:13:49 -08:00
7b0b7ff5b6 Add Rect.intersects 2023-02-10 21:13:31 -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
d4c4b5d879 Reformat some heckin' long initializers in object.py 2023-02-09 21:08:11 -08:00
d8dfe5c497 Fix some PEP8 formatting issues 2023-02-09 21:07:42 -08:00
350876347b Correct some Direction type annotations
They should always have been Vectors.
2023-02-09 21:05:05 -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
dabc9e70dd PEP8 formatter changes 2023-02-09 16:12:46 -08:00
391f84b21b Fix up the type annotations for geometry.Direction 2023-02-09 16:09:58 -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
843aa2823f Some messing around with fonts and BDF files from long ago 2023-02-08 08:36:44 -08:00
1df7cea2ad Move map modules to their own directory 2023-02-08 08:36:00 -08:00
90994cafd7 Import Action and ActionResult from actions submodules 2022-05-29 21:24:31 -07:00
05eb5c4ade Add some docstrings to ai.py 2022-05-28 09:02:52 -07:00
ae1c7f5ce2 Refactor events into their own package
Most of the existing actions are game actions (they control the player character)
so they live in actions.game. Eventually, there will be modules for different
kinds of actions that only apply to, e.g. modal UI.
2022-05-28 08:52:54 -07:00
46af8863b1 Use a try/catch to check for the presence of actor/target.fighter in MeleeAction 2022-05-16 20:51:53 -07:00
99838cbd00 Convert the passive healing clock to a more granular tick mechanism
Instead of counting turns, count clock ticks. A WaitAction adds 10 ticks to the
passive healing clock and a WalkAction adds 5. So, you will heal while walking
but at a slower rate.
2022-05-16 20:50:23 -07:00