Sunday, June 27, 2010

It's 3am, do you know where all your threads are?

If you're using the MediaPlayer framework, it turns out that no you don't. Moreover, you can't know. It looks like every time a play action is triggered (this includes a looping Song looping or changing songs) two new threads are created. And they never get disposed.

I discovered this when I hit a memory exception after four hours of playing and had 1147 threads open. The MediaPlayer interface is convenient, but I can't use it if it has a memory leak. Problem is that crashes in any form are grounds for a XBLIG failing in review.

So I have some alternatives:
Manually trigger sound effects, basically roll my own framework. Then I *ought* to handle the user playing their own music. Also, sound effects don't get compressed.
Use the XACT framework. It's a real pain to work with, and all I really gain is compression over just using sound effects.
Try to kill the rouge threads. As nears as I can tell, this is impossible. Yay managed code.
Or, (and this is the one I like) just stop playing music when memory gets close to full. It's easy to implement, and the few players that run the game that long will probably just think it's a small bug.


So this leads me right into why I was playing the game for four hours. The game is playable start to finish. I have to work on a credits sequence and revise saving/loading code, but the game is there, I played it start to finish.

Well, when I say play, the AI controlled all my characters. It's literally 1 line of code to enable, and it makes debugging victory screens and other things so much easier. I wanted to get a good number for how long the game actually was. The AI is a lot faster than a player, but it took about three hours for the AI to beat the game. I'd expect another hour just for user input, more if you didn't know where you were going, and more if you lost more frequently. I think 4-5 hours to beat the game is a very safe gameplay estimate.

I'm also a bit more confident about the difficulty now. The AI is a bit brute force, so if it can manage, I think a player will be able to. This doesn't let me test the learning curve though. That is what testers are for.

It looked like I actually did get the difficulty curve about where I wanted. For about the first half of the game you can sort of bumble about. Even with a bad mix of characters you can still win. The second half requires some thought, as do the optional battles. The last three were challenging, but not impossible. If anything, the last fight was a little too easy.

Anyway, enough rambling, have a screenshot of the character select screen after I made some improvements earlier this week:

Monday, June 21, 2010

Update

I've basically settled on music for the game. Music and sound effects have always been a concern for me. I can just about scrape by on sound effects, but there is no way I can fake music. I'm ok with paying for some quality music, I was hoping to avoid it, but it's difficult to find free, quality, loopable music with anything approaching a consistent style.

Music is not an important part of my game, I just don't want to screw it up. Perfect music would get me an extra point or two, but bad music will kill everything else. In the end I settled on some very calm, inoffensive orchestral stuff. It's nothing to write home about, which is exactly what I need. If I was willing to contract out for some music, I'd like to try something a little more exotic. Maybe a few different tracks with some exotic instruments and a little more upbeat. I might try playing with some modern version of 8-bit music ala bit.trip games, but it's just not worth the risk when I don't really have that luxury.

I did decide that I needed multiple tracks for battles. Most of a players time is going to be spent there, and if there's only one track, that could be a problem. I might think my placeholder track is fine, but I know not everyone will agree. I read a review of an an xbox indie game I liked, and one of the negatives was the repetitive music. I don't want that to be me if I can avoid it.

Early on I found some great free music over at incomptech. Unfortunately I couldn't find enough looping music from there, but I did get one track that was perfect for one thing. I did find another great site with musicloops. The site is great for looping music which is exactly what I needed. $30 got me enough music to finish out the game. That's not a bad price when the XNA club membership is $100 a year (I need to get that again at some point to test on the 360 and put it on the marketplace). What's nice is I can use the music on future projects as well, go creative commons liscense go.

Anyway, this week has basically been spent tightening up the graphics on level three, I've just been doing graphics tweaks and finding music mostly. I've got a few more weeks of tweaks before I can really show the game off end to end.

The title screen and the name are still problematic. I really need a final name before I can do the title screen. Unfortunately (or fortunately, since it was going to be a lot of work) I can't do the 90's style title screen with a big piece of pixel art because of the resolution difference between widescreen and standard def, so I'll have to come up with something else.

Here, have a screenshot.

Tuesday, June 15, 2010

Holy cow, I think I can see the finish line

Just hit a milestone, all the levels are mapped. I thought it would take a lot longer. I also thought I needed a lot more art assets, but what few I needed didn't take long at all. I'm really pretty happy with almost all of the levels. There are a few that didn't turn out the way I'd imagined, but I think they'll grow on me.


This one was actually one I had no definitive plan for. Something in a swamp. Maybe there would be a big tree. Stared at it for five minutes and came up with this.

I also spent a good day just doing a little bit of math to balance the game. I had wanted to avoid trying to mathematically balance the game - just sort of out of principle, I guess. But then I realized that the AI was leaning on just a move or two per character, which was predictable, if effective. The characters that were the most fun to fight against were the ones that constantly changed up their moves. I did some math to get rough estimates of how the AI estimated each attack, and used that to even out some of the extremes. Adjust some costs here, and some damage there. This is good because the AI is more unpredictable and you get to see what their various moves do before you unlock the character.

Along the way, I had time to fix some camera glitches and add a free-look button, catch some bugs, and improve pathfinding.

So I'm totally done, right? I started a to-do list, but it was growing longer than the rest of this post on it's own. So yeah, no.