Author Topic: Java Roguelike Tutorials?  (Read 25256 times)

woperri

  • Newcomer
  • Posts: 10
  • Karma: +0/-0
    • View Profile
Java Roguelike Tutorials?
« on: February 01, 2012, 05:13:17 AM »
Hi, I'm looking to (make an attempt to) make a roguelike. The only language that I know most of the syntax for is Java (and even then, it's only about a year's worth of experience). I did some searching on the RogueBasin wiki and found that I could use "The Roguelike Library for Java" and/or the "Ng Java Roguelike Engine". However, I couldn't find any tutorials on using and implementing the aforementioned libraries and engines to make a game (there was documentation, but that tended to confuse me when I didn't know the first thing about where to even start with such a game). I did find a tutorial on the basics of making a Java roguelike (http://trystans.blogspot.com/2011/08/nameless-roguelike-for-tutorial.html), but this was with the author's own ASCII library, which I don't know if I plan on using based upon the final product (no offense to the maker of the tutorial; his guide is awesome and very informative, but the game had a tendency to flicker (I think he mentioned this once?) occasionally and lock up the display whenever I held down a key). Are there any great libraries/engines for roguelikes coded in Java that have tutorials for someone new? Alternatively, did I miss some tutorials for the aforementioned libraries/engines?

I really would like to make something despite my lack of experience, though, as I feel that I could make something great. At the very least, I could hone my skills and learn from my mistakes.

george

  • Rogueliker
  • ***
  • Posts: 201
  • Karma: +1/-1
    • View Profile
    • Email
Re: Java Roguelike Tutorials?
« Reply #1 on: February 02, 2012, 03:01:05 AM »
I asked recently about Java libraries, if you follow the links you'll find a few more examples (not tutorials unfortunately).

http://roguetemple.com/forums/index.php?topic=1941.0

woperri

  • Newcomer
  • Posts: 10
  • Karma: +0/-0
    • View Profile
Re: Java Roguelike Tutorials?
« Reply #2 on: February 02, 2012, 03:44:57 AM »
Wow, I didn't even notice some of the other ones. Yeah, there appear to be quite a few neat tools that people can use with Java out there, but unfortunately very, very few tutorials to go along with them, just small bits of documentation that don't really explain how to start from scratch with it, just the implementation of what it has to offer. If I may ask, what's your favorite Java library/engine, if you ended up choosing one? Even if there are few (if any) tutorials, maybe the library/engine will be popular enough so that I could ask questions to people who are already experienced in them and eventually understand what's going on.

george

  • Rogueliker
  • ***
  • Posts: 201
  • Karma: +1/-1
    • View Profile
    • Email
Re: Java Roguelike Tutorials?
« Reply #3 on: February 02, 2012, 06:05:50 AM »
I haven't really gone farther than looking for what's out there. If I had to choose right now I'd probably go with blacken, but to be honest I'm not so satisfied with any of them. I got started with libtcod and I haven't seen anything in Java approaching the usability of libtcod, but then again I'm pretty biased :).

That issue even gave me the crazy idea of creating a libtcod-like library for Clojure, but before I took that on I think I'd give the existing libs more of a chance.

My current plan for 7DRL is to use Clojurescript to create something for HTML5 that I can easily port to Java but we'll see how that goes.

Come to think of it Slash on the forums here has his project serf-engine, http://code.google.com/p/serf-engine/, which might be your best bet if you want to create a game.

As far as tutorials go I don't think it matters too much what language the tutorial is in, the basic concepts are still the same. I know the implementation details can be tricky with a new language but if you have questions on how to port something from one language to another you always can just ask on the forums.

woperri

  • Newcomer
  • Posts: 10
  • Karma: +0/-0
    • View Profile
Re: Java Roguelike Tutorials?
« Reply #4 on: February 03, 2012, 04:09:06 AM »
I see - maybe serf/blacken is the way to go. I don't really want to learn a new language at the moment - even if it's something similar to Java like C#. Just too many things going on all at once.  Are blacken and serf still in development or finished? If they're still in development, is it possible that some of my code would be obsoleted in a new version of these engines/libraries? Also, do you think there's anyone I could ask about using these if I run into issues (which I'm almost certain is going to happen)?

Also, when's this 7DRL thing? I probably won't be able to do anything for it but it would be nice to see what people make (especially that HTML5 thing you mentioned)
« Last Edit: February 03, 2012, 04:13:44 AM by woperri »

george

  • Rogueliker
  • ***
  • Posts: 201
  • Karma: +1/-1
    • View Profile
    • Email
Re: Java Roguelike Tutorials?
« Reply #5 on: February 03, 2012, 05:39:00 AM »
7DRL is in March, you can find the thread here or on the rgrd Usenet forum, or read about 7DRLs at roguebasin. It is a good opportunity to see a lot of short games, probably more than 50 people will make something.

I think if you ask questions here about either blacken or serf someone will help you out. Even if the documentation is sparse now sometimes it just takes one person to get things rolling and that really helps everyone.

wire_hall_medic

  • Rogueliker
  • ***
  • Posts: 160
  • Karma: +0/-0
    • View Profile
Re: Java Roguelike Tutorials?
« Reply #6 on: February 04, 2012, 05:28:57 PM »
I'm also a hobby programmer who works in Java.  I haven't tried using any libraries that are floating around out there, but if you're having flicker problems, you're probably using Swing for output.

Swing is nice and easy to use, but slower than hell.  I recommend just using the paint() method.  Something like

public void paint(Graphics g)
{
   super();
   for(int x = 0; x < output.length; x++)
   for(int y = 0; y < output.length; y++)
   {
      g.setColor(outputColor
  • [y]);

      g.drawString(output
  • [y] + "", x * ICON_WIDTH, y * ICON_HEIGHT);

   }
}

Where output[][] is a char array, and outputColor is a Color array.

Every swing component has this method (which you can call indireclty by calling repaint()), and is MUCH faster than using setText() on JButtons etc.

Snargleplax

  • Rogueliker
  • ***
  • Posts: 50
  • Karma: +0/-0
  • snargleplax
    • View Profile
    • SnargleQuest dev log
Re: Java Roguelike Tutorials?
« Reply #7 on: February 24, 2012, 12:01:48 AM »
If you're a novice program experiencing problems with flickering, I wonder if perhaps your game is not doing double buffering.  Read up on that topic to make sure you understand it; whether or not it's the problem here, it's definitely something you should know about if you're doing game development.

yam655

  • Rogueliker
  • ***
  • Posts: 59
  • Karma: +0/-0
    • View Profile
Re: Java Roguelike Tutorials?
« Reply #8 on: March 21, 2012, 07:02:44 AM »
I'm the developer of Blacken.

It does use Swing, and it does suffer some in terms of the redraw speed. (It has zero flicker -- all updates are clean.) It gets around the speed issue to an extent by having drawing in a separate thread. It will also drop updates to the screen if need be, so in practice the speed isn't bad -- and it doesn't have any threading issues so you can resize the window to your heart's content and things still look good.

It takes a mixed approach to the issue of unlimited colors. You can use a predefined palette if you want. You can hand-code all of your colors if you want. With some limitations you can mix the two. When using a palette you can reference colors by name or by index and it has a number of default palettes available. (From xterm-256color to SVG/HTML5 named colors.) Custom palettes are easy and can be stored in text files.

It includes some simple examples, which (I would like to hope) would be enough to get started.

I'm less than happy about performance in terms of the impact it would have with the traditional ASCII-style animation, but -- as they say -- first make it work, then make it better.

Currently it has a rather rigid view of an "ideal screen size". It defaults to 80x25. When you resize the window (which it fully supports -- unlike some of the other options) it refuses to make fewer than that many columns and rows so it will shrink the text. When you make the window larger it does the reverse so the preference is always to be as close to 80x25 as possible. -- This means when designing the UI you design it once for your ideal screen size and things should "just work".

It also supports cell walls -- these are a part of the Curses spec but never implemented by either terminal emulator or curses. This means you can have zero-width walls. That, in turn, means when there's a window it's visually clear that the creature outside may reach in and grab you.

Anyway, I've been distracted from working on it for some time (otherwise I would have tried for the 7DRL). I'd love to see something somebody made using it.

wire_hall_medic, Outside of Swing or the AWT, what would a person use to create a desktop user-interface? I'd love to switch to something faster. It might inspire me to breath some more life in to it.

Cheers,
Steven Black

yam655

  • Rogueliker
  • ***
  • Posts: 59
  • Karma: +0/-0
    • View Profile
Re: Java Roguelike Tutorials?
« Reply #9 on: March 21, 2012, 07:11:11 AM »
Are there any great libraries/engines for roguelikes coded in Java that have tutorials for someone new? Alternatively, did I miss some tutorials for the aforementioned libraries/engines?

If I were to write an ideal tutorial for using Blacken, what would it need to have and how simple does it need to be?

When comparing Java roguelike UI libraries, what features were you most interested in? Those features should be documented and clear to use.

I mean, I know you probably found a solution to your issue for this year's 7DRL, but if there's a need out there, I should have this available before next year's 7DRL -- and that's a time-frame I think I can keep.

I tried to have a number of examples. I've frequently learned programming languages by way of example, so that tends to be what I think about first -- plus they have the benefit of failing when the code changes -- unlike written tutorials. ;)

Cheers,
Steven

george

  • Rogueliker
  • ***
  • Posts: 201
  • Karma: +1/-1
    • View Profile
    • Email
Re: Java Roguelike Tutorials?
« Reply #10 on: March 22, 2012, 05:41:30 AM »
What's up Steven, good to see you around again. I'll throw in my two cents to say that for tutorials Jotaf's Python tutorial at Roguebasin has got a lot of positive buzz. If you were to look at that and create something similar I think you would have a good framework to work from.

I took a decent look at the libraries available and I think blacken is the best one out there, so I think more work on it would be great.

yam655

  • Rogueliker
  • ***
  • Posts: 59
  • Karma: +0/-0
    • View Profile
Re: Java Roguelike Tutorials?
« Reply #11 on: March 22, 2012, 08:38:04 PM »
What's up Steven, good to see you around again. I'll throw in my two cents to say that for tutorials Jotaf's Python tutorial at Roguebasin has got a lot of positive buzz. If you were to look at that and create something similar I think you would have a good framework to work from.

<http://roguebasin.roguelikedevelopment.org/index.php/Complete_Roguelike_Tutorial,_using_python%2Blibtcod> ?

Yeah, I think I can pull something like that off.

Quote
I took a decent look at the libraries available and I think blacken is the best one out there, so I think more work on it would be great.

Excellent.

I'm thinking of switching from the GPL 3 license to an Apache/BSD license (the same as libtcod) specifically so I can steal features from it without worrying about licensing issues. I thought it might also be useful to provide a libtcod-like API as an option, at least as much as such a thing will make sense. libtcod is popular specifically because of the rich feature set. If I can get Blacken to feature-parity, that's the first step to driving improvements from my side. (When they are good features, it may make sense for libtcod to steal them from me. This will also be easier for them if we have compatible licenses.)

More immediately, I want to see if using JavaFX instead of Swing will help improve performance. Brogue's initial splash screen with the flaming background is kick-ass, and I know that sort of thing won't work with Blacken right now. If I get the performance to support that, then with my resizable windows I'm already one notch better. ;)

JavaFX looks like the next big thing for UI libraries. I have a hard requirement on pure Java solutions (otherwise you break cross-platform compatibility) so I don't want to link to external libraries via JNI. I've not seen a lot of options in terms of UI libraries. As near as I can tell, there's Swing, the thing Eclipse uses (I forget the name), and now JavaFX. JavaFX is still a little new, but the roadmap says that it is being folded in to Java 8 as a standard feature. (It also has "multi-touch and gesture" support -- and as Windows 8 spreads those features will slowly become the norm on all computing devices.)

Cheers,
Steven

XLambda

  • Rogueliker
  • ***
  • Posts: 208
  • Karma: +0/-0
    • MSN Messenger - tau_iota@live.de
    • View Profile
    • The Weird Rogue
Re: Java Roguelike Tutorials?
« Reply #12 on: March 22, 2012, 10:56:35 PM »
What's up Steven, good to see you around again. I'll throw in my two cents to say that for tutorials Jotaf's Python tutorial at Roguebasin has got a lot of positive buzz. If you were to look at that and create something similar I think you would have a good framework to work from.

<http://roguebasin.roguelikedevelopment.org/index.php/Complete_Roguelike_Tutorial,_using_python%2Blibtcod> ?

Yeah, I think I can pull something like that off.

Quote
I took a decent look at the libraries available and I think blacken is the best one out there, so I think more work on it would be great.

Excellent.

I'm thinking of switching from the GPL 3 license to an Apache/BSD license (the same as libtcod) specifically so I can steal features from it without worrying about licensing issues. I thought it might also be useful to provide a libtcod-like API as an option, at least as much as such a thing will make sense. libtcod is popular specifically because of the rich feature set. If I can get Blacken to feature-parity, that's the first step to driving improvements from my side. (When they are good features, it may make sense for libtcod to steal them from me. This will also be easier for them if we have compatible licenses.)

More immediately, I want to see if using JavaFX instead of Swing will help improve performance. Brogue's initial splash screen with the flaming background is kick-ass, and I know that sort of thing won't work with Blacken right now. If I get the performance to support that, then with my resizable windows I'm already one notch better. ;)

JavaFX looks like the next big thing for UI libraries. I have a hard requirement on pure Java solutions (otherwise you break cross-platform compatibility) so I don't want to link to external libraries via JNI. I've not seen a lot of options in terms of UI libraries. As near as I can tell, there's Swing, the thing Eclipse uses (I forget the name), and now JavaFX. JavaFX is still a little new, but the roadmap says that it is being folded in to Java 8 as a standard feature. (It also has "multi-touch and gesture" support -- and as Windows 8 spreads those features will slowly become the norm on all computing devices.)

Cheers,
Steven

Yes, libtcod is popular because it's essentially an all-round carefree package for the average roguelike dev - it handles UI as well as sophisticated FOV algorithms (most newcomers don't even understand these). It's extremely easy to use and lets you focus on the actual game. So when I made the decision to use Java, I was rather devastated to find that a) there was no Java port of libtcod and b) there wasn't any comparable Java library at all.
The 7DRL I wrote this year uses two separate libraries - one for UI and one for FOV calculation. Both were satisfying, but libjcsi has its limits (though I really appreciate its simplicity). I'd love to have a more... comprehensive solution. Especially with regards to some of the cool toolkits libtcod has.

I completely agree with you on keeping things purely java-based. JNI has been pretty much replaced by JNA, which is less cumbersome to use, but it's still the bottleneck and breaks portability anyways, so sticking with Java is IMO the only option if you are going for performance.

I know that we roguelike people tend to do things on our own, but if you need a helping hand, I'd be more than willing to contribute. There's a lot of stuff to do if you really want to catch up with libtcod, and it's going to take a while. I might be able to help out a bit, my fingers are itching to rewrite some of the libtcod stuff.
« Last Edit: September 16, 2013, 01:10:30 PM by XLambda »

yam655

  • Rogueliker
  • ***
  • Posts: 59
  • Karma: +0/-0
    • View Profile
Re: Java Roguelike Tutorials?
« Reply #13 on: March 25, 2012, 03:36:44 AM »
The 7DRL I wrote this year uses two separate libraries - one for UI and one for FOV calculation. Both were satisfying, but libjcsi has its limits (though I really appreciate its simplicity). I'd love to have a more... comprehensive solution. Especially with regards to some of the cool toolkits libtcod has.

Before I started work on Blacken, I looked at libjcsi.

Had you looked at Blacken before you decided to go with libjcsi? If so, why did you pick libjcsi?

I basically hadn't done any Swing-based work when I started. I started looking at libjcsi and trying to get it to do what I wanted. Eventually I realized it was going to be entirely rewritten.

Was it the license issue that made you pick libjcsi?

I know that we roguelike people tend to do things on our own, but if you need a helping hand, I'd be more than willing to contribute. There's a lot of stuff to do if you really want to catch up with libtcod, and it's going to take a while. I might be able to help out a bit, my fingers are itching to rewrite some of the libtcod stuff.

I am interested in gaining other contributors. Send me a PM with your email.

First look over the existing Blacken code. If you have any experience in Swing, you may be able to tell me I'm doing something blatantly stupid.

I am going to roll a release, branch it, then update the license. This means the source repository will have a version that it licensed for the GPL v3, but the version I'll work on going forward will not. If someone really wants that license, they'll be able to fork it starting from there.

By using an identical license as libtcod we'll basically be able to add features by porting the libtcod stuff to Java. This will be much easier than when I added the Navier-Stokes stuff to Blacken -- when I did that, I looked up the source of their algorithm and rolled my own based upon the same source material.

XLambda

  • Rogueliker
  • ***
  • Posts: 208
  • Karma: +0/-0
    • MSN Messenger - tau_iota@live.de
    • View Profile
    • The Weird Rogue
Re: Java Roguelike Tutorials?
« Reply #14 on: March 25, 2012, 03:16:15 PM »
The 7DRL I wrote this year uses two separate libraries - one for UI and one for FOV calculation. Both were satisfying, but libjcsi has its limits (though I really appreciate its simplicity). I'd love to have a more... comprehensive solution. Especially with regards to some of the cool toolkits libtcod has.

Before I started work on Blacken, I looked at libjcsi.

Had you looked at Blacken before you decided to go with libjcsi? If so, why did you pick libjcsi?

I basically hadn't done any Swing-based work when I started. I started looking at libjcsi and trying to get it to do what I wanted. Eventually I realized it was going to be entirely rewritten.

Was it the license issue that made you pick libjcsi?

Truth be told, it was the roguebasin article. I didn't really do a lot of research, I went online a few weeks before the challenge and of the libraries listed at roguebasin it was the only suitable (meaning pure Java) one, so I went with it.

I know that we roguelike people tend to do things on our own, but if you need a helping hand, I'd be more than willing to contribute. There's a lot of stuff to do if you really want to catch up with libtcod, and it's going to take a while. I might be able to help out a bit, my fingers are itching to rewrite some of the libtcod stuff.

I am interested in gaining other contributors. Send me a PM with your email.

First look over the existing Blacken code. If you have any experience in Swing, you may be able to tell me I'm doing something blatantly stupid.

I am going to roll a release, branch it, then update the license. This means the source repository will have a version that it licensed for the GPL v3, but the version I'll work on going forward will not. If someone really wants that license, they'll be able to fork it starting from there.

By using an identical license as libtcod we'll basically be able to add features by porting the libtcod stuff to Java. This will be much easier than when I added the Navier-Stokes stuff to Blacken -- when I did that, I looked up the source of their algorithm and rolled my own based upon the same source material.

Will do! Looking forward to it. :)