I don’t know if any of you have ever seen the slick little ASCII graphics game called Angband. (A derivative of UMoria if anybody knows that one instead) It’s a fun little game and I figured it was a good candidate for conversion into Java. I’m having just one little problem.
I can’t print text with any kind of speed. I need to be able to print out a roughly 100x50 grid of characters with each character possibly being a different color than the one next to it. I have explored the following options.
1 - Graphics.drawString for each character. Very slow. About 3 fps.
2 - Graphics.drawString for each line, which would be an AttributedString. That works too, but setting attributes for each character is ALSO freakin’ slow. I may be able to optimize that, but if there’s not much to optimize, I might be screwed.
3 - Haven’t tried this yet, but using a bunch of offscreen “layers”. Draw the dungeon on a Buffered image, then just cut & paste appropriate parts each frame. I’m sure that will be at least decent speed, but that means if my users want to scale their window size up, I could be having to paste images in excess of 1280x1024. That’s not an appealing thought for a simple text game.
I figure there HAS to be an easy solution I’m just not coming up with. Again, there’s a lot of optimizations I could make. for example, on average, out of that whole 100x50 grid, only 2 or three characters will ever change. That’s easy enough to just change those, but I should be able to COMPLETELY redraw the screen at a rate faster than 3 FPS.
Am I approaching this wrong? Does anybody have any suggestions? I have a few niftly little tricks I could try if I were doing this in C++ and had pointers to play with. Is there anything even SLIGHTLY comparable here?
Suggestions?
-Nate