RogueSharp v4.1.0 Released

Version 4.1.0 of RogueSharp was released


New features:

  • Optimized cave map generator (Thanks to James Neal)
  • DijkstraShortestPath.FindPath method which terminates upon finding destination for improved speed (Thanks to flend for this update)
  • Added AppVeyor continuous builds (Thanks to Glenn Hoeppner)
  • New constructors for GoalMap and PathFinder to allow for paths which include diagonal movement
  • Map.GetCellsInCircle and Map.GetBorderCellsInCircle methods use midpoint circle algorithm to get cells within a radius
  • Multiple new “Try” methods which work like their normal counterparts except they return null instead of throwing exceptions
  • Path.TryStepForward and Path.TryStepBackward which will return null instead of throwing a NoMoreStepsException
  • PathFinder.TryFindShortestPath will return null instead of throwing a PathNotFoundException
  • GoalMap.TryFindPath will return null instead of throwing a PathNotFoundException

Breaking changes:

  • Bug fix (4.1.0) – selecting border Cells along edge of map no longer selects center Cell
  • Point and Rectangle classes are now structs (Thanks to James Neal)
  • Updated all the appropriate references to Cell with ICell (Thanks to Courtney Strachan)
  • Map.ComputeFov and Map.AppendFov both return a ReadonlyCollection<ICell> for the cells in the field-of-view instead of returning void.
  • The Path returned from PathFinder.ShortestPath now includes the source cell in the returned Path. This behavior is consistent with how the GoalMap pathfinder works
  • Map.GetCellsInArea was renamed to Map.GetCellsInSquare
  • Map.GetBorderCellsInArea was renamed to Map.GetBorderCellsInSquare
  • Map.GetCellsInRadius was renamed to Map.GetCellsInDiamond
  • Map.GetBorderCellsInRadius was renamed to Map.GetBorderCellsInDiamond

18 thoughts on “RogueSharp v4.1.0 Released

  1. Andrew Hodges

    Hey, been using 4.1 for a while now and I have to admit I really love all the improvements you have been putting into this. I’m currently using 4.1 with Monogame for my WIP game. One advance thing that has been really nagging me is I can’t seem to find a nice way to get tiled walls to be drawn correctly as shown on that old feature screen-shot: The most intuitive way to do this would be to simply call a function that checks the ICells adjacent to the current cell in the loop on if .IsWalkable is true, however, this method will fail miserably if you set actor’s or object’s positions to !isWalkable or your method for this check accidentally check out of bounds of the array. Is there a better way to do common advance stuff like this?

    Another one that has been getting at me is lighting areas farther away from your FOV as slightly dimmer the further the cell is away from the player. Thanks for the help in advance.

    1. Faron Bracy Post author

      These are really good questions! Regarding the first question, I believe I used multiple maps when tiled walls. One that includes actors and objects and one that is just the walls and floors. You can make a copy of a map using In my case I had a non-destructible environment so once I figured out the correct orientation of every wall it was not necessary to ever recompute it.

      For the second question you’ll have to do something like compute the distance from the actor holding the light source to every cell in the FOV. Once you have the distance you’ll have to render the sprite in monogame to be darker than intended if it further away. I think you can call Draw using different shades of gray for the tint color.

      Hope this helps. If I get time I may create a demo to show this off as I think it would make a good blog post.

      1. Andrew Hodges

        That does help on the first one, thank you. I know what I need to do now.

        I’m still in the dark on the second one. I’m not exactly sure on how to write an algorithm to calculate from the max FOV to the player that works nicely with RogueSharp, is there anything I should be using to calculate the distance from the player? I do know XNA/Monogame has some nice math and drawing methods and I did find this online: however it doesn’t have a proper write-up.

      2. Faron Bracy Post author

        You probably already know this but to get the field of view for a certain distance call `ReadOnlyCollection ComputeFov(int xOrigin, int yOrigin, int radius, bool lightWalls)`

        This will return the list of visible cells within the specified radius. Then you’ll need to use a foreach to iterate through those cells to calculate the distance. The distance can be calculated using the Pythagorean Theorem. Here is an example.

        RogueSharp should probably have a method on the Map class that calculates the distance between two cells. You should be able to do it with something like this though: `Math.Sqrt( Math.Pow( x2 – x1, 2 ) + Math.Pow( y2 – y1, 2 ) );`

  2. Faron Bracy Post author

    I hacked some code together to get the effect where cells further away are dimmer.

    You can see it in action here.

    Hope this helps

    1. Andy Hodges

      That helps a ton. You did a much better job at implementing then I. Thanks again for all these guides as I wouldnt be as fair along on this projects without them.

  3. Andy Hodges

    Oh, quick question. Can this be tweaked to support the colored tiles with a blend function? This code works fantastic with the ground and walls. Does the preview video use RLNET as the API? And will you be uploading the feature demo on git? I would love to dive into your code for learning purposes.

    1. Andy Hodges

      Yeah, sorry to be a burden but I just can’t get this to work in DungeonMap.CS on the example project. (I’m currently basing my work on the RLNET one since the MonoGame one is extremely outdated.

      I’m currently running into problems with setting _mapConsole correctly on DungeonMap’s UpdatePlayerFieldOfView() function. Am I missing something obvious or do I need to refactor the code a bit?

      1. Faron Bracy Post author

        First for the questions about the video. It is done using RLNET and it would support colored tiles, I just happened to use shades of gray. The door doesn’t properly dim because I didn’t bother to blend that for the quick demo. Unfortunately I can’t make the repo public because it also includes sprites that I purchased from and would be against the terms of use to share them publicly.

        For your other question I would need you to upload your code to Github to be able to diagnose it. It might also take me a few days before I get a chance to go through it. You can refactor things for fun and learning, but if you are ever in doubt about something I would recommend that you use the link at the end of each tutorial post. It has the exact code that I used and it will run. You can then compare that against your own to find differences. Hope this helps. Good luck!

  4. Andy Hodges

    Thanks for the quick response. I can certainly wait a few days for help on these two features. I decided to upload feature work thus far in a .zip since I don’t feel the code is ready to be on a repo just yet. It follows the RLNET tutorial so it should be easy to get a grip on things. I haven’t quite gotten around to porting over what I did for tiled walls on Monogame just yet since the RLNET code base is a bit more complex and requires the changes you pointed out but I did figure out how to draw the box drawing characters to get started with the tiled walls on console.

    My early WIP on my project can be found here: I intend to really iron out those two features this weekend before I think about branching the game to monogame. Thanks again for all the help.

  5. Andy Hodges

    Hey, still waiting on a response. I still would like input on how to implement these two features well on the RLNET example game. I can do them in dumb down projects easily, but adding them to the example game is a different story.

    I updated my project which can still be found here: and I’m almost ready to upload it to github after my next bugtest and hopefully after getting these two features finally in. Would really appreciate your help on this as I put quite a bit of effort into expanding the example game so that it has a lot of things you see in finished roguelikes projects.

    1. Faron Bracy Post author

      I didn’t look at your project yet. You’ll have to put it on Github so that I can give feedback. It’s totally fine to put things up there that are still a work in progress.

      1. Andrew Hodges

        I went with blend as that is obviously the better solution of the two. Now onto tile mapping walls based on what they are connected to. I have a few good console compatible assets for that, so I definitely want to add that in before I think about doing a mono-game port. I will probably commit in a few days.

    1. Faron Bracy Post author

      RLRootConsole is a part of the RLNET library not RogueSharp. It is just one of many display options that RogueSharp is compatible with. (SadConsole, Unity, MonoGame and Malison to name a few others). The author of RLNET, Travis, has the repository here ->
      I did a couple of small bug fix pull requests that he accepted, but have otherwise not been involved in that project. If it is something that you are interested in contributing to, you could take a shot at the scaling feature and open up a pull request.

      1. Andy Hodges

        That was poorly worded. I was getting at if you could write about a simple method on changing the scale with the demo project on the fly. Like hit f6 to toggle from 2x to 1x scale since that is quite common

        Seems that might actually not be allowed at all on rlnet since closing and reopenning a window raises an exception. I will contact him

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.