Temple of The Roguelike Forums

Announcements => Traditional Roguelikes (Turn Based) => Topic started by: Etinarg on July 07, 2010, 02:12:18 PM

Title: Roguelike Game Kit
Post by: Etinarg on July 07, 2010, 02:12:18 PM
Over the years I worked on so many game projects, and wrote code that might be useful for other game developers too. I want to release some of it under the GPL.

So I've set up a project at Sourceforge:
http://sourceforge.net/projects/rlgamekit/

At the moment there is a module for map data in the SVN (a layered map, e.g. ground, features, items, monster/player layer, but in a very generic fashion), and an example dungeon generator.

Also, a display module for such map data, showing funky colored ASCII characters in rectangular and isometric styles (sorry, couldn't resist).


(http://www.funkelwerk.de/data/roguelikegamekit/screens/rec_dungeon_01_t.png)
Click to view full size.
 (http://www.funkelwerk.de/data/roguelikegamekit/screens/rec_dungeon_01.png)


(http://www.funkelwerk.de/data/roguelikegamekit/screens/iso_dungeon_01_t.png)
Click to view full size.
 (http://www.funkelwerk.de/data/roguelikegamekit/screens/iso_dungeon_01.png)

I hope I can provide more of such modules, field of view calculation, generic item and monster data structures and the like.

Maybe the modules will be helpful for the one or other. For study, or to use for any kind of open source project, roguelike, crpg or just anything. The code is Java, and should work with Java v6.

It's a very early stage, the code needs more cleanup, but I have some hope that it will get somewhere.
Title: Re: Roguelike Game Kit
Post by: getter77 on July 07, 2010, 03:32:47 PM
Cool stuff, always nice to see more resources/something that could serve as the backbone to some future project somewhere out there.   8)   Thanks for taking the time and trouble to reckon and set up the lot of it, keep at it!
Title: Re: Roguelike Game Kit
Post by: Etinarg on July 08, 2010, 02:36:12 PM
It's sometimes difficult to make modules generic enough that they are still useful to other peoples projects, an still simple enough so that people can use them easily. But it's a good practice for myself, to split game dependent parts of the code from the game independent parts.

I've been working some more on it, and the Roguelike Game Kit now has a field of view (FOV) module in place. It should be a fairly efficient implementation of the shadowcasting algorithm (http://www.funkelwerk.de/site/index.php/articles/programming/shadowcasting), but I did not do any performance tests yet. I have used this with some success in former projects.


(http://www.funkelwerk.de/data/roguelikegamekit/screens/field_of_view_demo_2_t.png)
Click to view full size.
 (http://www.funkelwerk.de/data/roguelikegamekit/screens/field_of_view_demo_2.png)

I've kept the FOV module independent from the actual game data. It does also not depend on other modules of the Roguelike Game Kit.

The example MapDisplay class contains code that shows how to link the FOV calculation with the tile painting code, that is, which parts you need to implement to tell the FOV code what kind of things in your game actually block sight.
Title: Re: Roguelike Game Kit
Post by: ido on July 08, 2010, 03:46:43 PM
Neat!

I've looked at your IsometricTileLocator and I think I might use the same technique myself.

For some reason I thought it would be a lot harder but your solution seems really trivial and the result looks really good :)
Title: Re: Roguelike Game Kit
Post by: Etinarg on July 08, 2010, 07:43:25 PM
In my first tries, I had overcomplicated the isometric view calculations a lot too. I'm glad you like it, I'm also happy how nicely it shapes up.

After the map structure and the field of view code, I wanted to work on a module for game actions. That is, a structure that allows to bind a (generic) action to a key press. I think I have the basics of this module in place now, too, and also implemented an example "Move" action for the demonstrator program. So, it now is kind of a super-simple mini roguelike walkaround demo.

You can fetch the JAR file with demonstrator code included from Sourceforge:
http://sourceforge.net/projects/rlgamekit/files/

You can run the walkaround demo from the console by typing:

java -jar RoguelikeGameKit.jar

On Windows (and maybe other operating systems) the demo can also be started by a double click on the RoguelikeGameKit.jar if java is properly installed. It needs Java version 6 or newer to run. The demo will generate a random dungeon, display the dungeon and let you move the @ character around. You can move by WASD, HJKL and cursor keys.

Once I had a lockup in the demo (couldn't move anymore) and it might happen that the @ is not placed inside a room of the dungeon at start, but in a wall. In such a case, just restart the demo. I'll try to find out why it locked up this one time - I couldn't reproduce it anymore so far.

In order to avoid misunderstandings - this project is not meant to become a roguelike game itself, it just provides modules which help to write one. The walkaroudn demo is there to show how to use these modules.
 
Having said that, it was an exciting moment for me too, to move the @ the first time, and see the field of view update :)
Title: Re: Roguelike Game Kit
Post by: Etinarg on July 09, 2010, 10:13:41 AM
I've started to write some documentation for the Roguelike Game Kit. The field of view code might be the most interesting module for roguelike developers, so I started with that:

* How to use the field of view module (https://sourceforge.net/apps/mediawiki/rlgamekit/index.php?title=How_to_use_the_field_of_view_module.)
Title: Re: Roguelike Game Kit
Post by: ido on July 09, 2010, 01:12:59 PM
Why is the cursor location multiplied by 2 in the iso viewer code?
Title: Re: Roguelike Game Kit
Post by: Etinarg on July 09, 2010, 01:44:10 PM
if (dx,dy) be the distance from iso tile center to the next iso tile center, the size of such a tile is (dx*2, dx*2). Hard to explain without a sketch.

Code: [Select]
/\
/  \
\  /\
 \/  \
  \  /
   \/

The offset from tile to tile is (2,2) in this example, measured in screen coordinates, but the surrounding rectangle of a tile has the size (4,4). The "cursor" would be drawn as such a surrounding rectangle (not used in the demo code so far).



I've been trying to write more documentation, and now there is also a short introduction of the ideas of the layred map in place.

* How to use the layered map (https://sourceforge.net/apps/mediawiki/rlgamekit/index.php?title=How_to_use_the_layered_map)

I hope my writing is somewhat clear.
Title: Re: Roguelike Game Kit
Post by: Etinarg on July 10, 2010, 09:37:39 AM
I've expanded the example dungeon generator a bit. It now can place doors.


(http://www.funkelwerk.de/data/roguelikegamekit/screens/door_demo_t.png)
Click to view full size.
 (http://www.funkelwerk.de/data/roguelikegamekit/screens/door_demo.png)

The walkaround demo code was expanded too, to let the player open doors by bumping into them. The new jar file with the modules and the walkaround demo can be fetched from Sourceforge now:

:=> https://sourceforge.net/projects/rlgamekit/files/
Title: Re: Roguelike Game Kit
Post by: Etinarg on July 11, 2010, 11:14:38 AM
If doors can be opened, there should be example code how to close them as well. I've expanded the walkaround demo with a game action to close doors. Also, it has now a "Player" class that can tell where and how to store player specific data. Maybe some day the player class can be generalized and moved to the libraries.

https://sourceforge.net/projects/rlgamekit/files/

Press "c" followed by a movement command to close a door in the walkaround demo.
Title: Re: Roguelike Game Kit
Post by: Etinarg on July 12, 2010, 07:55:51 PM
There have been two notable additions since v.4:

- A simple menu system, with usage example in the walkaround demo.
- The walkaround demo now keeps track of seen ("remembered") squares.

That means, even in the demo you now need to walk around and explore the dungeon to see the full map layout. Also, you can quit the demo now by pressing Q, X or Escape.


(http://www.funkelwerk.de/data/roguelikegamekit/screens/menu_example_t.png)
Click to view full size.
 (http://www.funkelwerk.de/data/roguelikegamekit/screens/menu_example.png)

You can fetch the latest version from Sourceforge:

https://sourceforge.net/projects/rlgamekit/files/
Title: Re: Roguelike Game Kit
Post by: Etinarg on July 13, 2010, 09:27:58 PM
I've had some problems with this release, and I hope I've got everything packaged correctly.

There have been two notable additions since v.5:

- The walkaround demo now generates new levels when stepping on the "stairs up" symbol.
- Player now always spawns in a valid position in the walkaround demo.

All changes:

Quote
FIX: Multiple choice boxes are now always centered on window.
FIX: Fixed a wrong dependency between MapDisplay and ASCIITilePainter.
FIX: Better tracking of "ok" state for multiple choice boxes.
NEW: "Stairs up" symbol in walkaround demo now generates a new map if stepped onto.
NEW: LayeredMap got "spawn position" property.
CHG: Dungeon generator now sets "spawn position" with a suggestion for player spawn position.
CHG: Walkaround demo now uses player spawn position to set the player starting location.
You can fetch the latest version from Sourceforge:

https://sourceforge.net/projects/rlgamekit/files/
Title: Re: Roguelike Game Kit
Post by: Etinarg on July 14, 2010, 10:07:27 AM
I've written a brief summary about the walkaround demo (purpose of the demo, starting the demo, demo controls, quitting the demo):

https://sourceforge.net/apps/mediawiki/rlgamekit/index.php?title=The_walkaround_demo

Next module on my list to be included in the kit is pathfinding.
Title: Re: Roguelike Game Kit
Post by: ido on July 14, 2010, 01:04:20 PM
Any chance or releasing this under MIT/BSD/public domain?
Title: Re: Roguelike Game Kit
Post by: Etinarg on July 14, 2010, 01:11:22 PM
Should be alright. BSD style licenses tend to be pretty "free". I guess I can dual license the code (GPL and BSD)?

Edit: I'll try to allow use under the BSD and GPL licenses. I'm trying to set up files and wording for that.

Edit 2: This seems to mean that all future contributions must also become dual licensed. Will this be a problem? Should I stick to one license rather?
Title: Re: Roguelike Game Kit
Post by: ido on July 14, 2010, 03:38:02 PM
As long as a version is available under a BSD/MIT-like license it doesn't matter much to me.
Title: Re: Roguelike Game Kit
Post by: Etinarg on July 15, 2010, 12:55:08 PM
I was wondering if it matters to the project - e.g. if potential contributors will prefer to publish under GPL only, and be scared away by the dual license, which requires them to release their work also under the BSD license (or vice versa). I feel uncertain about the issue and will wait until I have a clearer picture of it.

Meanwhile I have written a page how to lift the map display code from the walkaround demo to a level that "real" roguelikes will need - e.g. to handle secret doors and hidden traps.

https://sourceforge.net/apps/mediawiki/rlgamekit/index.php?title=Separate_display_representation_from_map_representation

I hope the description is clear enough.
Title: Re: Roguelike Game Kit
Post by: ido on July 15, 2010, 12:59:15 PM
Since you hold the copyright you can always drop the BSD license in the future when/if it starts to bother potential contributors.

You won't be able to apply it retroactively for old versions but you will be able to release a GPL-only version.

So as long as all the code remains Copyright <your real name> 2010-20xx it is a non-issue.
Title: Re: Roguelike Game Kit
Post by: Etinarg on July 15, 2010, 01:02:13 PM
Ok, good. I think I have prepared things so that I can dual license the next release.
Title: Re: Roguelike Game Kit
Post by: ido on July 15, 2010, 01:08:09 PM
Great!

Just to make sure we are on the same page here: there are several BSD licenses, some of which are not GPL-compatible and only one of which is MIT-equivalent.

I was talking about the most recent one (that is also used by FreeBSD) which is the 2-clause license (http://en.wikipedia.org/wiki/BSD_licenses#2-clause_license_.28.22Simplified_BSD_License.22_or_.22FreeBSD_License.22.29) and is equivalent to the MIT license (http://en.wikipedia.org/wiki/MIT_License).

Alternatively, you can also just use the MIT License directly and avoid confusion :)
Title: Re: Roguelike Game Kit
Post by: Etinarg on July 15, 2010, 01:22:52 PM
Seems I had an older (?) BSD license text, which had three clauses. The third looked odd to me anyways, the two clause version that you linked should be just right. Thanks!
Title: Re: Roguelike Game Kit
Post by: Etinarg on July 17, 2010, 10:47:33 AM
I've updated the licensing data and files on Sourceforge, so this release is now available under the GPL and a BSD style license.

The pathfinding module is finally usable and there is a new demo application included (demo/pathfinding) which shows the pathfinder in action:


(http://www.funkelwerk.de/data/roguelikegamekit/screens/pathfinder_01_t.png)
Click to view full size.
 (http://www.funkelwerk.de/data/roguelikegamekit/screens/pathfinder_01.png)

You can start the pathfinder demo this way:

Code: [Select]
java -classpath RoguelikeGameKit.jar rlgamekit.demo.pathfinding.PathfindingMain

It can happen that the map is completely obstructed and the player symbol is stuck in the top left corner. In this case, just quit the demo and start again - it will generate a different "wilderness" map each time and most are good for showing the pathfinding in action.

The @ symbol will move automatically and collect the X symbols. The X are placed randomly, and the pathfinder guides the @ there each time. The demo will not place X in inaccessible places.

To quit the demo, just close the window.

Quote
NEW: Pathfinding demo (rlgamekit.demo.pathfinding.PathfindingMain).
NEW: Path class can now do 8-direction and 4 direction pathfinding.
NEW: Number of map layers to be generated can now be handed to
     dungeon generator via config values.
FIX: Fixed a bug in integer value parsing for dungeon config data.

You can fetch release 7 from Sourceforge:

http://sourceforge.net/projects/rlgamekit/files/
Title: Re: Roguelike Game Kit
Post by: Etinarg on July 20, 2010, 08:03:15 AM
A new version was released.

Changes Since Last Release:

The menu system got a simple message display area. It might need
some more finetuning, but the interface should not change anymore.

There have been some code cleanups for both the walkround and the
pathfinder demo. Also the walkaround demo was expanded to showcase
the new message display area.

A new package "objects" was introduced, with an object registry to
link integer values of the LayeredMap class to game objects. No test
or showcase exists for this yet, so it might have undiscovered bugs.

Change Log:

Quote
NEW: Object registry to link int values from maps to game objects.
NEW: "PathDestination" interface for pathfinding engine. This allows
     to check "destination reached" conditions in a very generic way.
NEW: ASCIITilePainter got setFont() Method.
NEW: MessageDisplayArea class in the menu package to display HTML
     formatted game messages.
CHG: TiledMapPainter now supports a painting strategy for transparent
     tiles, too (which need to be painted in bottom up order).
CHG: Moved "newMap" method from MapDisplay to MapControl class.
CHG: Set pathfidner demo thread to be a "deamon" thread (in order to
     let the VM exit correctly if the pathfinding demo window was
     closed by pressing escape).
CHG: Split MapControl class from MapDisplay class to have a better
     separation of display and control code.

You can fetch release 8 from Sourceforge:

http://sourceforge.net/projects/rlgamekit/files/
Title: Re: Roguelike Game Kit
Post by: Etinarg on July 21, 2010, 09:32:40 AM
I have generated java doc for the project, and uploaded it here:

http://www.funkelwerk.de/data/roguelikegamekit/javadoc/

I hope this will be helpful for those trying to use the Roguelike Game Kit in their projects. The quality of the documentation varies, but I hope I got at least the important parts done well.

It is a bit newer than the latest version in the SVN. E.g. the area finder class was not commited yet. That will happen later the day after more tests. Actually it was just a test if the javadoc generation works, and then I decided to upload it as is, since it looked good enough ...

Title: Re: Roguelike Game Kit
Post by: Etinarg on July 23, 2010, 08:04:12 AM
Release 9 is now available from Sourceforge.

Changes Since Last Release:

The display map was split from the game map, to allow the demo to implement features like hidden doors and monsters moving unnoticed in remembered but not visible areas. This is not showcased yet, just prepared.

See also:
http://sourceforge.net/apps/mediawiki/rlgamekit/index.php?title=Separate_display_representation_from_map_representation

A new showcase was added to the walkaround demo, though. Each map will have  up to 4 gold keys randomly distributed. The player can pick them up by pressing 'g'. A simple inventory view was also added. It can be opened by pressing 'i'.

This showcase was added to show how to implement items. The "generic item data containers" mentioned in the change log are not used in the walkaround demo yet, but the object registry now is.

Change Log

Quote
FIX: Fixed javadoc mistakes.
FIX: Fixed "door" config property for dungeon generator.
CHG: Dungeon generator can now also parse Angband style a:r codes.
CHG: Moved part of the color code parsing into ColorCodes class.
CHG: Split display map from game map.
NEW: Added generic item data containers (not used yet).
NEW: Area class to find all reachable cells in an area.
NEW: Simple player inventory for walkaround demo.
NEW: Simple player inventory UI for walkaround demo.
NEW: Multiple choice box can now easily be centered on a frame.
NEW: Showcase for object registy and game items in walkaround demo.
NEW: Added color codes for brown and steel blue.

You can download release 9 from Sourceforge:

http://sourceforge.net/projects/rlgamekit/
Title: Re: Roguelike Game Kit
Post by: Etinarg on July 26, 2010, 08:50:44 PM
I've added a simple wilderness generator to the Roguelike Game Kit. It creates an enclosed 'wilderness' area of a given size.


(http://www.funkelwerk.de/data/roguelikegamekit/screens/wilderness_01_t.png)
Click to view full size.
 (http://www.funkelwerk.de/data/roguelikegamekit/screens/wilderness_01.png)

The ~ are hills, ^ are mountains and the & are tree symbols.

The symbols and colors are configurable. I've started to write some documentation about it here:

https://sourceforge.net/apps/mediawiki/rlgamekit/index.php?title=The_Wilderness_Map_Generator

Well, basically you just tell the generator which symbols to use, and start it. The config example in the wiki just made the screenshot above. Sourcecode is in the SVN on Sourceforge, and the next release will have the wilderness generator included.


Title: Re: Roguelike Game Kit
Post by: Etinarg on August 01, 2010, 02:44:08 PM
Release 10 is now available from Sourceforge.

Changes Since Last Release

A wilderness type map generator and a mines type map generator have been added. The pathfinding demo now uses the wilderness generator to generate maps. The walkaround demo now randomly chooses mines or dungeon type maps for new levels.

The walkaround demo got a help action which is bound to F1 and will show the current key bindings (unsorted). Also there is now a "drop item" action to drop an item from the players inventory. It is bound to ctrl-d.

Some balance changes for the colors. Also the color set can now be customized by the application.

Change Log

Quote

2010/08/01
NEW: More items.
NEW: Walkaround demo now can generate mines and dungeon type
     maps.

2010/07/29
NEW: Drop action for items in walkaround demo.
CHG: Help action can now show ctrl and shift modifiers.
CHG: Expanded object registry with some useful methods.
CHG: Tried to make yellow, orange, brown and copper colors
     better distinguishable.

2010/07/28
NEW: Colors for rendering backend can be customized now.
FIX: Wilderness generator now calculates better spawn locations.
CHG: Pathfinding demo now uses wilderness map generator.
CHG: Added one more color, "copper".

2010/07/27
NEW: Mines type map generator.
NEW: All map generators now take a "seed" value in their
     properties.

2010/07/26
FIX: Fixed feature/color code parsing in dungeon generator for
     list structures.
CHG: Limited player inventory in walkaround demo to 22 items.
NEW: Added color code for light gray.
NEW: Wilderness map generator.

2010/07/25
NEW: Added MapUtils class with map processing utility methods.
NEW: Added insert() method for layered map class.
NEW: Game actions now got names, e.g. to show the player a
     comprehensive list of actions for key bindings.
NEW: HelpAction to show a the current list of key bindings.
     Help action is bound to F1.

You can download release 10 from Sourceforge:

http://sourceforge.net/projects/rlgamekit/files/
Title: Re: Roguelike Game Kit
Post by: Etinarg on August 01, 2010, 07:09:41 PM
I have generated java doc for release 10, and uploaded it here:

http://www.funkelwerk.de/data/roguelikegamekit/javadoc/

Also, I tried to write some documentation about the map display system, and how to customize it. I lost plenty of edits due to technical troubles, an I guess at some point this didn't help the quality of the page. Hopefully it's still helpful:

http://sourceforge.net/apps/mediawiki/rlgamekit/index.php?title=ASCII_Map_Display
Title: Re: Roguelike Game Kit
Post by: purestrain on August 02, 2010, 05:35:30 AM
Maybe you should use a blog and every users can subscribe to it if they think its interesting (as i do with some). Noone else is writing a posting about every commit.  ::)
Title: Re: Roguelike Game Kit
Post by: JayPC on August 24, 2010, 06:25:57 AM
Im interested in knowing, how do you store the map data? is it an Int array and the values are the diferent pieces? or is it more complicated then that?

EDIT: Sorry For posting in the wrong one! Got confused!
Title: Re: Roguelike Game Kit
Post by: Etinarg on August 25, 2010, 09:55:12 AM
Im interested in knowing, how do you store the map data? is it an Int array and the values are the diferent pieces? or is it more complicated then that?

Each map layer is an int array. The map itself is a vector (kind of dynamic length array) of layers.
Title: Re: Roguelike Game Kit
Post by: JayPC on August 26, 2010, 03:13:25 AM
Interesting, Never Heard of Vector before ill have to look it up, anything Like an ArrayList of int[]? kinda?
Title: Re: Roguelike Game Kit
Post by: Etinarg on August 26, 2010, 09:52:11 AM
In Java Vector was the older type, and synchronized, and since Java 1.2 the container classes were streamlined a bit and ArrayList was introduced, which basically the same as Vecor, just not synchronized.

Also, C++ has a vector type:
http://en.wikipedia.org/wiki/Vector_(C%2B%2B)

Each map layer is a "normal" array of int's though to keep overhead small. Just the map itself stores the layers in a vector type.