about summary refs log tree commit diff
path: root/src/Xanthous/Util
AgeCommit message (Collapse)AuthorFilesLines
2020-01-19 Switch to DelaunayTriangulation.NaiveGriffin Smith1-1/+4
Per https://github.com/noinia/hgeometry/issues/28, occasionally DelaunayTriangulation.DivideAndConquer loops infinitely - in this case, I was able to consistently use the seed 127624940715530481, to generate a dungeon which had the following room centroids: [ Point2 [38.5,3.5] :+ 0 , Point2 [67.0,33.0] :+ 1 , Point2 [46.0,45.5] :+ 2 , Point2 [55.5,42.0] :+ 3 , Point2 [36.0,25.0] :+ 4 , Point2 [76.5,12.0] :+ 5 , Point2 [29.0,26.5] :+ 6 , Point2 [55.0,10.5] :+ 7 ] and cause delaunay triangulation to loop indefinitely (or at least longer than I cared to wait for). Given the size of our graphs switching to naive generation should be fine performance-wise, and avoids the infinite loop.
2020-01-04 Add support for multiple levelsGriffin Smith1-0/+24
Add a data structure, based on the zipper comonad, which provides support for multiple levels, each of which is its own entity map. The current level is provided by coreturn, which the `entities` lens has been updated to use. Nothing currently supports going up or down levels yet - that's coming next.
2019-12-30 Add dungeon level generationGriffin Smith3-4/+86
Add a dungeon level generator, which: 1. generates an infinite sequence of rectangular rooms within the dimensions of the level 2. removes any duplicates from that sequence 3. Generates a graph from the delaunay triangulation of the centerpoints of those rooms 4. Generates the minimum-spanning-tree of that delaunay triangulation, with weights given by line length in points 5. Adds back a subset (default 10-15%) of edges from the delaunay triangulation to the graph 6. Uses the resulting graph to draw corridors between the rooms, using a random point on the near edge of each room to pick the points of the corridors
2019-12-30 Fix circle rendering, add filled circleGriffin Smith1-30/+51
Make raster circle rendering use the Rasterific package instead of attempting desperately to hand-roll it, and add a method for generating filled circles.
2019-11-30 Fail on all warnings in CIGriffin Smith1-1/+0
All the undefineds are gone, so it's time to enable -Werror in CI.
2019-11-29 Add DerivingVia newtype for generic arbitraryGriffin Smith1-1/+16
Add a newtype, GenericArbitrary, which can be used with -XDerivingVia to derive Arbitrary instances for types with Generic, via patching generic-arbitrary to expose the underlying typeclass it uses for surfacing the type information.
2019-11-29 Implement saving+loading the gameGriffin Smith2-0/+47
Implement ToJSON and FromJSON for all of the various pieces of the game state, and add a pair of functions saveGame/loadGame implementing a prism to save the game as zlib-compressed JSON. To test this, there's now Arbitrary, CoArbitrary, and Function instances for all the parts of the game state - to get around circular imports with the concrete entities this unfortunately is happening via orphan instances, plus an hs-boot file to break a circular import that was just a little too hard to remove by moving things around. Ugh.
2019-09-29 Gormlaks attack backGriffin Smith1-1/+1
When gormlaks see the character, they step towards them and attack dealing 1 damage when adjacent. Characters have hitpoints now, displayed at the bottom of the game screen, and when the game is over they die.
2019-09-20 Describe what you see when you walk over itemsGriffin Smith1-0/+15
Every step the character takes, describe the entities at that position excluding the character.
2019-09-15 Progressively reveal the map to the playerGriffin Smith1-0/+64
As the character walks around the map, progressively reveal the entities on the map to them, using an algorithm based on well known circle-rasterizing and line-rasterizing algorithms to calculate lines of sight that are potentially obscured by walls.