Sunday, 26 December 2010

Happy Noel!

Happy Noel from the Discretion team!

Noellephant says hello.

Thursday, 16 December 2010

Libgdx efforts, and Chapter 1 almost feature complete!

Yesterday I did lots of tidying up of my codebase, bringing the bits I wanted to add to libgdx up to that project's standard. The end of the day saw me commit a lot of stuff - read the libgdx blog for what I got up to.

Today saw a lot more tidying up and polishing, with Chapter 1 looking almost feature complete, and a decent start to loading and saving. I'm very happy with my progress this week, and am looking forward to recruiting some beta testers in the near future.

Here's another screenshot! Look out for an introduction to the main characters soon...







Wednesday, 8 December 2010

Discretion's first pre-alpha screenshot

So, despite a crazy week which included getting stranded in the UK due to the bad weather, Google breaking ADT (rendering me unable to do any coding) with the latest Android release, internet outages due to our ISP and other setbacks, I've actually made some progress on the game! Enough that I'm willing to release this very pre-alpha, very basic screenshot of the main character and one of the party characters wandering around Atnar Castle. More will follow in the coming weeks.


Tuesday, 7 December 2010

Modelling with DeleD

Some thoughts on a workflow within DeleD, the world editor I'm using to build my levels with for Discretion.

1. Build world
2. Triangulate world (divide non-triangular meshes into triangles)
3. Apply materials and fix U/V mapping where necessary
4. Export

It's important to do as much modelling as possible in 1. before proceeding to the next steps, because the easiest way to ensure everything is triangulated once and only once is to select all objects then do triangulate. It's necessary to do 2. before 3. because U/V mapping a non-triangular polygon doesn't always work too well.

The Wavefront .obj exporter for DeleD has an extremely useful 'scale' option which allows you to model at the scale DeleD was designed to be used at instead of at real world (game) scale (mine is 1 unit = 1 meter which in DeleD is way too zoomed in). The triangulator in the exporter is broken however, so make sure you triangulate using the geometry toolbox instead.

Hope this helps someone!

Monday, 29 November 2010

Getting FloatBuffer data: BufferUnderFlowException

When getting FloatBuffer data from a mesh, you must be sure to rewind your buffer before copying it if you already have before. I was iterating subsets of vertex data for the same mesh (I have "submeshes", which are equivalent to Wavefront .obj groups or objects) and trying to get the vertex data for each submesh for some processing, but the second iteration I was getting a BufferUnderFlowException.

It took me longer than it probably should have to realise I needed to "rewind" the buffer so I could copy the data again. To do this simply call FloatBuffer.position() with zero to set its internal position back to the start.

Of course if you need to be performant, you probably shouldn't be copying it twice anyway... :)

Thursday, 11 November 2010

Java.String memory leak

Or "How I just saved myself 3 meg of precious Android heap memory".

I always glazed over whenever I came across how Strings are implemented in higher level languages. The most important advice I ever came across concerning them was "use a library that does all that string stuff for you". Of course I can make reasonable assumptions about how Java does strings:

1. There's a char buffer somewhere in there storing sequences of raw characters
2. It probably does something clever with them along the lines of the same way I do textures

So what happened? A loader parses an entire object file into a string, then passes a tokenized element of that string into an object as the object's name. It all seemed fine till I ran the Eclipse Memory Analysis Tool, when I found at the top of my memory usage hitlist a bit more than 3 megabytes of char data. As in, a couple of raw char[]. Full of, guess what? My entire object file.

"What's happened here?", I thought, stroking my chin. A closer look at my object in the debugger (a Submesh) revealed that sure enough, its name (supposed to be something like "grp 1"), which is a String, has the entire object file in its buffer. The String object stores an offset and length into the character buffer. The garbage collector looks at the 3 meg buffer and says "well, this Submesh object here still has a reference to this sequence of data, so I can't delete it!".

The fix is trivial: construct a new string from the passed in string, which makes a new buffer and frees up the old one for the GC's unreferenced memory hit squad.

I thought I'd post this because without running the MAT I never would have known I was leaking 3 megs of memory. It's worth checking.

Monday, 25 October 2010

Looking for a freelance 3D Character Artist

3D Character Artist (Freelancer) required for Smartphone RPG project

Red Sky Forge is a new startup developing games for Android smartphones. It currently consists of Dave Clayton, a programmer with more than 6 years of experience in software development, including experience on two released games titles (PC and PS3).

Discretion is a Role-Playing Game with a release date of Q1 2011. We require assets for the 3D game environment including 3D character models, textures and skeletal animations. As Smartphones are low to medium resolution with small amounts of memory and graphics processing power, the assets must have a low resource footprint.

The project requires the following deliverables over two milestones:
* 13 low-poly rigged models (10 humanoid and 3 animal)
* 42 textures for the models (the game characters re-use models with different textures)
* 17 animations

The project deadline is January 2011.

Please contact creative@redskyforge.com for the creative brief with your portfolio and relevant experience.

Discretion Development Update!

It's only been 2 weeks since I began developing Discretion but already a lot has been done! First of all, I decided to use LibGdx as my low-level game engine. It's a nice open source Android library that's also cross-platform, which has some great productivity benefits. The project is very active and the lead developer, Mario, posts lots of extra information over on the Badlogic Games blog. The key reasons I decided to use LibGdx are:
  • Cross-platform: the library has multiple Java backends for Android, desktop and applet. This means you can essentially develop your app as a standalone Java desktop application, which means no more emulator! The productivity benefits are excellent: everything on the desktop is much faster to load and display so you don't waste lots of time waiting around when you could be coding the next bit of work. Developing in C++ for the PS3 taught me just how many man-hours it's possible to waste waiting around for things to build and run...
  • Skeletal animation: LibGdx loads MD5 files from the Doom 3 engine. This is a relatively modern model/animation format that allows smooth, lifelike animation to be used. It's also relatively costly. If you're interested in the guts of interpolation, quarternions and Java vs. C optimisations I recommend reading Mario's posts on md5!
  • Music, sound and input layers: it's important in development; it's even more important for development on a startup project with a limited budget and timeline: don't reinvent the wheel. Re-use code, including that kindly made available by other devs. The main reason to use 3rd party libraries in general is so you have more time to focus on coding stuff that makes your software unique. Of course LibGdx doesn't just offer music, sound and input layers. Go read the LibGDX project page to find out what else it does!
So I'm pretty happy with my library. But what about the code I've written myself? Have I actually done anything this past fortnight besides drink coffee and read Reddit? Well, I've probably not done anything that's interesting to the outside world. A lot of it has been working on my own framework layer sitting on top of LibGdx: a lightweight graphical user interface (a wheel reinvented but it's a wheel that turns exactly how I want it to!), game world and objects, high level animation, procedural terrain generation (for prototyping) and a start on the actual in-game menus. Although I don't have any models yet, you can equip a character with invisible weapons and armour! Fun, hey?

So far I'm very happy with my development environment. Eclipse runs nicely and besides some minor differences was a painfree transition from Visual Studio, the IDE I've been using for the past God knows how long. LibGdx's desktop backend minimises the "thumb twiddling" time, and my HTC Desire periodically shows me just how small and fiddly those buttons are on a 2.5" 800 x 480 screen... I've got an SVN repo I'm happy with and now I just need to find a freelance 3D character artist to do my assets, and soon this ship will be well and truly sailing! Three sheets to the wind, of course!

Saturday, 11 September 2010

The Terror of Scope

I've been working on putting some game design documents together since I came away to India. At first in Manali, a week after I arrived; then here in Goa, towards the end of my trip, I picked up my pen again and opened the exercise book I'd been using to make my notes.

Working on game development isn't new to me. I've worked on two titles, one at a small startup and one at a medium sized company with a respectable back catalog. Both titles made it to release and I was pleased to have worked on a variety of game development programming tasks, from AI to multiplayer, to low level script compilation and execution, to 3D animation and 2D GUI systems. I believe I'm capable of programming a game by myself.

What I didn't realise, when I decided I wanted to make a Role Playing Game (RPG) for the Android Platform, was the true scope of what I was attempting. I've never worked on game design before, so when I started writing my design documents it was new, exciting territory. I enjoyed it immensely. I got to writing it up onto a private wiki. Then my partner, who is also in IT, suggested I should write a functional specification. I've done this kind of thing before too, in enterprise, and thought it was a great idea: from a functional spec, architecture is clearer, and so is the true size of your project. For those not in IT, a functional spec basically describes everything the application (the game) needs to do, in exhausting detail. It doesn't describe how - that's in a technical spec if you write one, or up to the programmer. But it shows you everything you need to do.

So I started on my functional spec. I'm making an RPG. It started off with the basics: how gameplay flowed between the title screen, the main "roaming the world" mode, cut scenes, combat. Then it exploded.

I don't mean it exploded as in, what happened when Luke fired his photon torpedoes into the Death Star's exhaust vent. I mean it got bigger; like a hungry octopus, stretching out its tentacles in every direction; like cancer. Before I knew it, I had multiple documents describing different functional parts of the game: scripting, combat, skills.

A few days into this, however, I was pleased with my progress: I'd gotten huge parts of the functional spec finished, and was even precisely specifying how each episode of the game (there are nine in total) progressed. Then one day I thought it was a good time to start putting feelers out to some friends who were artists and seeing if any of them were interested in doing some 3D art for me. I'm making a 3D game, but I'm not an artist. Even if I learned how to use 3D Studio or Maya, I don't have time to make the creative stuff too. I've already realised how full my hands will be just with programming. But to get any kind of accurate quote for creative assets, I need to figure out how many I need!

I start counting: first how many different "character classes" are in the game. (This doesn't include "extras" that might populate the world but not be directly involved in the story). "Kingdom Warrior", "Queen", "King". "Enemy Kingdom Captain". "Tiger". "Noble". The list expands before my eyes. I gulp.

I write down which character classes could re-use the same models with a different texture. The list still ain't small: 14 models, 51 textures. Oh shit. I have difficulty sleeping that night: I really, passionately want to develop this game, more than any other game I've worked on in my life. Yet I've badly underestimated its scope. The reason there seems to be a gap in the market for RPGs on Android becomes clearer: RPGs are BIG.

How many people worked on Final Fantasy 6, my standard for a good RPG? The game I'm most inspired by? Almost 50. I won't be making a game with anywhere near as many gameplay hours as FF6, but still. That's scary.

I still want to do this, but I've learned a valuable lesson: spec as early as you can. Derive some roadmaps estimating your project's lifespan as early as you can. Figure out a ballpark figure of how many man hours that adds up to. As early as you can.

Then do it anyway.