RogueSharp is a free library written in C# to help roguelike developers get a head start on their game. RogueSharp provides many utility functions for dealing with map generation, field-of-view calculations, path finding, random number generation and more.
It is loosely based on the popular libtcod or "Doryen Library" though not all features overlap.
- Visit the RogueSharp Blog for tips and tutorials.
- The quickest way to add RogueSharp to your project is by using the RogueSharp nuget package.
- If building the assembly yourself, the solution file "RogueSharp.sln" contains the main library and unit tests. This should be all you need.
- The solution file "RogueSharpPerformanceTests.sln" contains a wrapper for libtcod and was only used to test performance of similar functions between RogueSharp and libtcod
- The solution file "RogueSharpDocumentation.sln" requires Sandcastle Help File Builder to be installed. It can be used to generate documentation for the library from the XML comments on public methods.
Most interactions with RogueSharp is based around the concept of a Map
which is a rectangular grid of Cells
.
Each Cell
in a Map
has the following properties:
IsTransparent
: true if visibility extends through theCell
.IsWalkable
: true if a theCell
may be traversed by the playerIsExplored
: true if the player has ever had line-of-sight to theCell
IsInFov
: true if theCell
is currently in the player's field-of-view
To instantiate a new Map
you can use its constructor which takes a width and height and will create a new map of those dimensions with the properties of all Cells
set to false.
###Usage###
IMap boringMapOfSolidStone = new Map( 5, 3 );
Console.WriteLine( boringMapOfSolidStone.ToString() );
###Output###
#####
#####
#####
Notice that the ToString()
operator is overridden on the Map
class to provide a simple visual representation of the map. An optional bool parameter can be provided to ToString()
to indicate if you want to use the field-of-view or not. If the parameter is not given it defaults to false.
The symbols used are as follows:
%
:Cell
is not in field-of-view.
:Cell
is transparent, walkable, and in field-of-views
:Cell
is walkable and in field-of-view (but not transparent)o
:Cell
is transparent and in field-of-view (but not walkable)#
:Cell
is in field-of-view (but not transparent or walkable)
A more interesting way to create a map is to use the Map
class's static method Create
which takes an IMapCreationStrategy
. Some simple classes implementing IMapCreationStrategy
are provided with RogueSharp but this is easily extended by creating your own class that implements the strategy.
###Usage###
IMapCreationStrategy<Map> mapCreationStrategy = new RandomRoomsMapCreationStrategy<Map>( 17, 10, 30, 5, 3 )
IMap somewhatInterestingMap = Map.Create( mapCreationStrategy );
Console.WriteLine( somewhatInterestingMap.ToString() );
###Output###
#################
#################
##...#######...##
##.............##
###.###....#...##
###...##.#####.##
###...##...###..#
####............#
##############..#
#################
- Doryen Library (libtcod)
- This was a big inspiration for RogueSharp
- The binaries of libtcod are included only for performance testing to see how my algorithms performed compared to it. The main RogueSharp library does not use any source code from libtcod, nor does it reference or depend on the libtcod library.
- libtcod source code
- libtcod license
- MonoGame
- Similar Point and Rectangle classes are included in RogueSharp that are inspired by MonoGame
- MonoGame source code
- MonoGame license
- Princeton University Java Algorithms
- Several classes from RogueSharps Algorithms namespace are inspired by these Algorithms
- RogueBasin
- Sandcastle Help File Builder (SHFB)
- Used to automatically generate documentation from the XML comments in source code
- SHFB license
- Dice Notation .NET
- Significant portions of the code in RougeSharp DiceNotation namespace are taken directly from this great library
- Dice Notation .NET source code
- Dice Notation .NET license
The MIT License (MIT)
Copyright (c) 2014 Faron Bracy
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
See links to licenses in the credits for respective libraries