All Projects → FaronBracy → Roguesharp

FaronBracy / Roguesharp

Licence: mit
A .NET Standard class library providing map generation, path-finding, and field-of-view utilities frequently used in roguelikes or 2D tile based games. Inspired by libtcod

Projects that are alternatives of or similar to Roguesharp

Umoria
Moria: a roguelike Dungeon Crawler game | Umoria Source Code
Stars: ✭ 167 (-47.15%)
Mutual labels:  game, roguelike
Rotten Soup
A roguelike built with Vue, Vuetify, Tiled, rot.js, and PixiJS! Playable at https://rottensoup.herokuapp.com/
Stars: ✭ 249 (-21.2%)
Mutual labels:  game, roguelike
Broguece
Brogue: Community Edition - a community-lead fork of the much-loved minimalist roguelike game
Stars: ✭ 185 (-41.46%)
Mutual labels:  game, roguelike
Magicallife
A 2d game that aspires to be similar to Rimworld, with more depth, magic, and RPG concepts.
Stars: ✭ 145 (-54.11%)
Mutual labels:  game, roguelike
Easystarjs
An asynchronous A* pathfinding API written in Javascript.
Stars: ✭ 1,743 (+451.58%)
Mutual labels:  pathfinding, game
Allure
Allure of the Stars is a near-future Sci-Fi roguelike and tactical squad combat game written in Haskell; please offer feedback, e.g., after trying out the web frontend version at
Stars: ✭ 149 (-52.85%)
Mutual labels:  game, roguelike
Ivan
Iter Vehemens ad Necem - a continuation of the graphical roguelike by members of http://attnam.com
Stars: ✭ 219 (-30.7%)
Mutual labels:  game, roguelike
Boohu
Break Out Of Hareka's Underground, a roguelike game.
Stars: ✭ 112 (-64.56%)
Mutual labels:  game, roguelike
09 Zombierunner Original
First person shooter with Unity terrain and AI pathfinding (http://gdev.tv/cudgithub)
Stars: ✭ 64 (-79.75%)
Mutual labels:  pathfinding, game
Zeps Gui
L'interface d'un outil de calcul d'itinéraires, principalement utilisé pour se repérer dans le Netherrail de Zcraft. Nécessite https://github.com/zDevelopers/ZePS-Core .
Stars: ✭ 5 (-98.42%)
Mutual labels:  pathfinding, map
Nethack
Official NetHack Git Repository
Stars: ✭ 1,860 (+488.61%)
Mutual labels:  game, roguelike
prestashop-shop-creator
Generate random demo data to test your PrestaShop shop.
Stars: ✭ 22 (-93.04%)
Mutual labels:  generator, random
Sleeping Beauty
Sleeping Beauty: a game created for the 7-day Roguelike 2014 challenge. Coffeebreak length.
Stars: ✭ 115 (-63.61%)
Mutual labels:  game, roguelike
Remixed Dungeon
Traditional roguelike game with pixel-art graphics and simple interface - Remixed Pixel Dungeon
Stars: ✭ 160 (-49.37%)
Mutual labels:  game, roguelike
Trw
The Royal Wedding – coffebreak roguelike with story, lighting, zombies and (sometimes) lutefisk!
Stars: ✭ 113 (-64.24%)
Mutual labels:  game, roguelike
Droneworld
droneWorld: a 3D world map and a three.js playground
Stars: ✭ 197 (-37.66%)
Mutual labels:  game, map
Geotic
Entity Component System library for javascript
Stars: ✭ 97 (-69.3%)
Mutual labels:  game, roguelike
Roguebot
My simple rogue-like game for Telegram
Stars: ✭ 100 (-68.35%)
Mutual labels:  game, roguelike
Burningknight
C# branch of BK
Stars: ✭ 251 (-20.57%)
Mutual labels:  game, roguelike
mapgen
map generator stuff
Stars: ✭ 26 (-91.77%)
Mutual labels:  map, roguelike

Tutorials: Github.io Documentation: Github.io Posts: Blog License: MIT

Build status Build status Nuget

Test status Code coverage

Build History

RogueSharp with SadConsole

What is RogueSharp?

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.

Getting Started

  1. Visit the RogueSharp Blog for tips and tutorials.
  2. The quickest way to add RogueSharp to your project is by using the RogueSharp nuget package.
  3. If building the assembly yourself, the solution file "RogueSharp.sln" contains the main library and unit tests. This should be all you need.
  4. Class documentation is located on Github Pages.

Features

Pathfinding

With or without diagonals

Pathfinding with Diagonals

/// Constructs a new PathFinder instance for the specified Map 
/// that will consider diagonal movement by using the specified diagonalCost
public PathFinder( IMap map, double diagonalCost )

/// Returns a shortest Path containing a list of Cells 
/// from a specified source Cell to a destination Cell
public Path ShortestPath( ICell source, ICell destination )

Cell Selection

Select rows, columns, circles, squares and diamonds with and without borders.

Cell Selection

/// Get an IEnumerable of Cells in a circle around the center Cell up 
/// to the specified radius using Bresenham's midpoint circle algorithm
public IEnumerable<ICell> GetCellsInCircle( int xCenter, int yCenter, int radius )
  
/// Get an IEnumerable of outermost border Cells in a circle around the center 
/// Cell up to the specified radius using Bresenham's midpoint circle algorithm
public IEnumerable<ICell> GetBorderCellsInCircle( int xCenter, int yCenter, int radius )

Weighted Goal Maps

Set multiple goals weights for desirability. Add obstacles to avoid.

Weighted Goal Maps

/// Constructs a new instance of a GoalMap for the specified Map 
/// that will consider diagonal movements to be valid if allowDiagonalMovement is set to true.
public GoalMap( IMap map, bool allowDiagonalMovement )

/// Add a Goal at the specified location with the specified weight
public void AddGoal( int x, int y, int weight )

/// Add an Obstacle at the specified location. Any paths found must not go through Obstacles
public void AddObstacle( int x, int y )

Field-of-View

Efficient field-of-view calulation for specified distance. Option to light walls or not.

Field of View

/// Constructs a new FieldOfView objec for the specified Map
public FieldOfView( IMap map )

/// Performs a field-of-view calculation with the specified parameters.
public ReadOnlyCollection<ICell> ComputeFov( int xOrigin, int yOrigin, int radius, bool lightWalls )

/// Performs a field-of-view calculation with the specified parameters
/// and appends it any existing field-of-view calculations.
public ReadOnlyCollection<ICell> AppendFov( int xOrigin, int yOrigin, int radius, bool lightWalls )

Creating a Map

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 the Cell.
  • IsWalkable: true if a the Cell may be traversed by the player
  • IsExplored: true if the player has ever had line-of-sight to the Cell
  • IsInFov: true if the Cell 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-view
  • s: 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

#################
#################
##...#######...##
##.............##
###.###....#...##
###...##.#####.##
###...##...###..#
####............#
##############..#
#################

Credits

License

RogueSharp

MIT License

Copyright (c) 2014 - 2020 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.

Other Licenses

See links to licenses in the credits for respective libraries

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].