Something a little technical today, but I always like a chance to save people endless frustration:

Let’s say you write a program in Swing (the Java standard graphics library). Let’s say you have something you want done in the background, without interrupting the main program – for example, maybe you want to listen for input from a stream. Should you just create a thread like always, with a class that implements Runnable or extends Thread?

Absolutely not. And it’s a bit annoying that the official Java documentation does a very bad job explaining it – the official Java documentation tells you that this is how you create threads, by implementing Runnable or extending Thread, and nowhere does it mention that this method completely does not work with Swing. Not exactly some esoteric, unknown library – Swing, the library behind pretty much every non-web thing written in Java ever.

So, future Swing programmers, if you need to create threads, please note that it’s done differently in Swing. You need to extend the SwingWorker class. What happens otherwise? Absolutely nothing, it seems. You create what you think is a thread, you let it block while listening on a stream, and your whole application hangs. Because it turns out creating a thread is meaningless when you’re in the world of Swing. As you’ll find if you look specifically for creating threads in Swing, all you need is that SwingWorker and it’ll be fine. I hope this post can save someone the day of frustrated Googling I had for it.

I made myself a personal photo sharing page. Still a work in progress so it doesn’t look very nice and offers fairly limited functionality, but it does the basics (i.e share photos). Now, why would I do such a thing?

My photo management history is fairly unremarkable. I was never much of a photographer, and at first, after I became old enough to travel and take pictures, I just stored them on my computer for future reference. Then Facebook came, and I started sharing them there. However, not long ago I realized how much I hate Facebook, and thus decided to gradually minimize my interaction with it. I started exploring Flickr and Picasa to decide where I want to store my photos, but then I realized – why would I actually need them?

Photo sharing websites provide some very limited services – they give you server storage space, web pages to display your photos in, and a large community of people you don’t know and most likely don’t interact with in any way. The cost? You have little or no control over how the photos are presented, you have advertisements everywhere to things you don’t want to advertise, and there might be some privacy issues (usually people make privacy-related rants about these sites, I actually don’t particularly care about that so I don’t know if that’s legitimate).

I know most people don’t care, but I think it makes it boring. Everyone’s profile always looks exactly the same, you’re always limited to the kind of activity the company wants to allow you, and they don’t have any incentive to allow you more than the bare minimum they need to make money. In fact, for most people it might actually be an advantage – one of the common complaints against MySpace was that they gave people too much power over their profiles, and they used it to make them ugly. In my opinion – these are boring people’s complaints. When I go into a friend’s house it might be messy and not as clean and stylish as a hotel room, but it’s their house and I wouldn’t want everyone to live at identical hotel rooms. If I had my way, all social networking would be done with hand-crafted webpages offering ever-expanding socializing options.

However, I know I’m weird. This is not going to turn into the next Internet trend, but will just stay as my odd little photo album (and in the future, other DIY social network elements). But just in case, if anyone wants to do the same, my code (for now it’s simply the file album.html) is officially released to the public domain. Enjoy!

So… I’ve been doing a lot of complicated things lately. You know what I thought was not complicated? Getting two computers to talk to each other. Life is full of fun surprises.

The problem is, I was kind of cryogenically suspended for about a decade in terms of multiplayer video gaming and development, so my mind had that late-90′s thinking of “open a socket on some port at the server, connect to that with the client, start playing”. Seems like tutorials and explanations around the web are also stuck with that mindset. The problem is, it does not seem to work anymore.

The minor problem is that the days of “enter the IP address you want to connect to” are probably gone. Looks like you have to have some sort of matchmaking server to have a multiplayer game, which completely goes against my “have nothing to maintain” policy. But I can deal with that. Such a server shouldn’t be too complicated. Especially if I get someone else to do it for me (yes, you know who you are).

The bigger problem is firewalls, which all those kids today seem to be using. I can’t find any recommendation for the best way to deal with them. If I try a port other than 80, the firewall blocks it. And 80 itself, I’m pretty sure I can’t listen on it. Anyone knows what’s the best practice here?

Update (22.05.2013): The answer appears to be Hole Punching. More (and potentially awesome) details coming soon.

My month in Lisbon really brought me some inspiration for my first commercial game, so stay tuned – gameplay is nearly complete, and an initial private demo will soon be released to the playtesters (in other words – random selection of my friends). So there is still hope that soon you’ll get to see the actual game happening. Just wait a little more.

I’ve been fairly quiet lately, and there’s a good reason – I’m going into the money time of the first (and possibly last) stage of my indie developer carrier. I’ve let myself be very lenient with my time, branching off into many different projects all the time, and I like it that way, but the time has come where I need to start making money, or getting an actual job. So here we go – I’m dedicating this month to my one commercial project (and one more long-term project, still in early stages). If by the end of February I don’t have a demo to publish, nor feel like I’m ridiculously close to having one – I’ll know I’ve been defeated (at least for now) and go get a job. So, hopefully you’ll hear from me in a few weeks, with some good news.

Making good animation is hard. Good animation is beautiful. The combination of these two facts makes it highly desirable for me to find automatic, or otherwise easy, ways of making animation.

A while ago I thought about trying motion capture. The recording process is not very simple[1], but the result is so universal – there are many ways to design a character, but very few movements a character should make. How many different types of walking are there? of running? does it really make sense to redo all the animation for every character from scratch, when so many of them do the exact same things?

So, my hope was that, since I don’t currently have access to a motion-capture studio, perhaps someone who does have one was nice enough to make their results publicly available. And indeed, there was. TheĀ Carnegie Mellon University Graphics Lab turned out to have a very big database of motion capture available for public use. So I decided to try it.

After trying to make some sense from the clumsy w3c file format, I found their data has almost 50 markers, which is amazing. At first I thought I would have a very difficult time drawing something that looks like a human from that data, but with so many markers, even if I just draw a tiny square in every marker’s location, we get a nice “ghost-like” human form:

ghost

For some reason, WordPress screws up the screenshot I was going to put here, so here’s a picture of a kitten instead (from Wikipedia). You can see my results in the YouTube video or HTML5 demonstration.

Animating is makes quite a cool result. After achieving that, it was sitting in my code directory for a few months, waiting for when I’ll find the motivation to try and reach the next goal – turning it into a game-capable animation. That is, a cyclical animation (so it can go on for longer than the data is currently available), with a fixed location (so the animation can be synchronized with the actual game character). Yesterday the time came, and it was surprisingly easy. I used a very simple method to find similar animation frames near the beginning and near the end of the animation (so that it can be repeated indefinitely without the observer noticing), and to normalize the marker locations around a fixed point (to get the “treadmill” effect – the character walks but remains in the same place, thus the game engine can determine its final location).

Here’s a demonstration video, but its quality is poor[2] and does not do justice to the animation. I made an HTML5 example of this, please check it out here (left and right arrow keys to move).

Since the data is in 3D, I can draw it from whatever perspective I want – side-view, top-down, or isometric (or anything else, but these three seem the most useful). In case you were wondering – I know I can probably plug it into Blender and get 3D animation easily, but I don’t like 3D animation. I think it looks beautiful when huge teams of professionals do it, but anything below that looks ugly, whereas 2D (and especially isometric) can look nice without huge budgets.

Now, the question is what do I do with it. Any ideas? maybe a good way to draw a human figure around the markers without huge amounts of work? maybe a game that will benefit from awesome animations without having awesome graphics?

Only walking animation is available for now, but other things from the wide selection at Carnegie Mellon should not be very difficult.

[1] Shouldn’t be impossible though – theoretically, it might be reasonably simple to improvise a home-made motion capture studio with a webcam and some colored stickers or something. But that’s for another time.

[2] Is there a good, free video-recording software out there that offers reasonable framerate?

I’ve been working on another game for the Experimental Gameplay Project this week. As you may notice, the month ends today, and unfortunately – it doesn’t look like I’m going to have something serious to show on time. I’ll try to make a quick development session today and have at least something to show for it, maybe also work on it a little bit in a personally-declared overtime. Meanwhile, I thought I’d share some of the philosophy behind my project.

There are many game genres out there. We have shooters, real-time strategy, turn-based strategy, turn-based tactics, brawlers, puzzlers, management, and many others, all of which are drastically different from each other.

But wait – the word “genre” can mean several different things. In all these genres, the game mechanics are indeed drastically different from each other. But what about the content? What are these games “about”? In that case, suddenly almost all creativity disappears. All the different, clever mechanics are used almost always in the context of fighting. Anything from one-on-one fighting in Street fighter, to huge multiplanetary wars in Total Annihilation. Almost every game currently available that I can see, involves killing something, or trying to. In some rare cases we get two other possible goals – earning money (mostly in management-style games) and getting out of somewhere (in puzzle games). Often these are combined with killing things, and anyway – they’re limited to their own genres. Most genres have only one thing – killing stuff. So why is that, and is that the only possible direction for the gaming world to go?

I admit – fighting is, despite its horrible uses, an interesting thing. It allows a wide variety of options and strategies, requires many different skills, is inherently symmetrical and is very dynamic. However, is that really the reason so many games go for that? I think it’s quite obviously not. It’s becoming more and more outstanding in the recent 10-15 years – as graphics become more and more realistic, we see the game industry’s order of priorities – huge resources are put into things that don’t affect the gameplay and don’t improve the graphics, but simply make things more violent[1].

So if the industry is doing it because people like violence[2] and not because it’s the only option, could there be an additional option? Could we be missing an entire world of game worlds based on the same genres (in terms of game mechanics), but with different contexts than killing stuff[3]? I think it’s possible. And the game I’ve been working on for the past week is kind of a test of that. As you might expect from a week’s work it’s hardly polished and might not actually be very fun, but I hope it will turn out to have some potential. What exactly is the context? It’s something I think can fill an entire world of games, no less rich than war, and can be applied to almost every genre where war is currently used. I’ll wait until it’s ready before announcing it, but you can have a little hint – the Experimental Gameplay Project theme for this month is “temperature”.

Just to clarify – I don’t (entirely) have a problem with violence in video games. I do have a problem with evil in video games as I’ve explained before, but games based on fighting are fine – the problem is when *every* game is based on fighting. My problem here is the lack of creativity.

[1] This is seriously a quote (or at least a paraphrase) I personally heard in a talk by someone from the Total War franchise, introducing their next game: “We made animations so much more realistic [...] the soldiers will now have facial expressions of sadness as their fellow soldiers die”.

[2] Almost needless to say how self-fulfilling that prophecy is – companies assume something about the target audience, make the games for them, they buy the games, companies check data about the people who buy their games, and find their assumptions were correct. How shocking.

[3] Hopefully, even something you’ll be able to explain to non-gamers without cringing. I think the multiplayer mode of Assassin’s Creed is really cool in its mechanics, for example, but can you imagine showing that to a non-gamer, who is presumably a normal person, and offering them to try playing it? “Here is where you violently slit the throat of a innocent civilian, it causes you a minor inconvenience because it wasn’t who you were supposed to kill. And here you can kick someone’s dead body, you get 50 points for that”.