Hmm… Ninja parallel dimension warmup failed to launch…

Posted by (twitter: @jtgans)
December 11th, 2011 10:55 pm

As you can see from the title, my particular warmup theme was “parallel dimension”. So naturally, I came up with a crazy idea of using ninja smilies as a character and plotline. Essentially the idea was that your ninja master found a way into the shadow dimension of demons — unfortunately, he was captured, demons invaded your dojo, ghoulified some of your comrades, and have generally taken over. The idea was to have it as a kind of sneak and kill game, with you only killing the demons and saving your comrades. I was hoping to put something in there that allowed you to solve puzzles by swapping between the planes, but decided to keep it simple stupid for the first time around.

Well, I got close to something working — and then I got stuck. Apparently getting at the actual indexes of a BufferedImage‘s pixels is a serious PITA with Java2D. You can’t just use BufferedImage#getRGB(int x, int y) because it tries to return the actual RGB values. Worse, those values are packed RGB int values which are useless for indexing into an array of tiles and doubly useless for an efficient hashmap of colors to tiles because of autoboxing.

Dumb, dumb and dumb.

So looks like I get to assemble a small suite of utility classes and such to ease this pain a bit for the next time around. One of which is an int to E hashmap. The next is a stupidly simple GameMap class that does all the goo necessary to get an actual list of tile indexes from a bitmapped map. Sound a bit like reinventing the wheel? Probably, but I’m having fun with it, so nyah!

Also, I learned that the OpenJDK’s JVM does some very weird tricks with regard to “shared memory”. During this session of coding and getting stuck, I had a timelapse script running taking snapshots of the desktop every second, as well as webcam shots every five seconds. Unfortunately, that process managed to fill the entire root partition of my Linux install. Weirdly, the JVM started complaining about being out of shared memory space in /tmp. /tmp! Apparently something in there uses /tmp as a “shared memory space”, and when that’s filled up, things like ImageIO.read(URL url) start returning null. Once I cleaned up the droppings from my timelapse script, everything started working.

Weeeeird.

Oh, and the timelapse video is here. No actual game to post, though — never made it out of the “draw the ninja” prototype.


Leave a Reply

You must be logged in to post a comment.

[cache: storing page]